Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No such module 'OneSignal' - XCode Swift Compiler Error

I'm currently trying to add OneSignal to my react native expo (bare) IOS build and have followed OneSignal's guide as shown here: https://documentation.onesignal.com/docs/react-native-sdk-setup

However, Xcode has flagged up a compiler error of: No such module 'OneSignal'

Compiler Error

Here is my Podfile that includes the OneSignalXCFramework import:

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

platform :ios, '12.0'

require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

target '<NAME>' do
  use_expo_modules!
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'
  )

  # Uncomment to opt-in to using Flipper
  #
  # if !ENV['CI']
  #   use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
  # end

  post_install do |installer|
    react_native_post_install(installer)

    # Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
    # Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
    installer.pods_project.targets.each do |target|
      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
    
    target.build_configurations.each do |config|
    # some older pods don't support some architectures, anything over iOS 11 resolves that
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end

end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end

As a side note, I've already tried to add pod 'OneSignal' or use_frameworks! into the PodFile. Has anyone else experienced this issue before?

like image 766
MartynFItz Avatar asked Mar 14 '26 23:03

MartynFItz


1 Answers

Xcode 14.0.1 update & Swift 5.7 - Using SPM(Swift Package Manager)

Recently I have integrated one signal into my project using SPM. it worked fine until I tried to upload the build to app store connect and it started showing me the same error. Here's how I fixed this issue.

Step 1: Removed the one signal dependency

Step 2: added again one signal Notification framework as a dependency.enter image description here

On the Choose package products popup.

  1. Select OneSignal to add to the project as a target.
  2. Select OneSignalExtension to be added to the oneSignalNotificationService extension as a target.
  3. Now go to "NotificationService.swift" file in OneSignalNotificationExtension and replace > import Onesignal with >import OneSignalExtension.
  4. Also replace oneSignal in code with OneSignalExtension.
  5. Add Package and build.
like image 144
MALIKK HABIB UR REHMAN Avatar answered Mar 16 '26 14:03

MALIKK HABIB UR REHMAN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!