12

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?

1

4 Answers 4

11

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.
Sign up to request clarification or add additional context in comments.

3 Comments

In order to see both of the Package Products, you must be using github.com/OneSignal/OneSignal-iOS-SDK instead of github.com/OneSignal/OneSignal-XCFramework
This was annoying and preventing me from distributing my app. Thank you!
I'm surprised they didn't update their setup documentation yet to mention this
0

In my case, which may not be the reason for many of you but may help someone, the first time I've added it, all works well, but after merging the code into my main branch I get this error. My problem was that I have added podfile to .gitignore so it was working the first time but after merging it, podfile of course doesn't have the needed last section which is

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

So make sure you have it.

Comments

0

If you're like me and use an Apple Silicon Mac i.e M1/M2 and the Pros, you would need to turn on Rosetta. To do this, in your Xcode menu, select Product > Destination > Destination Architectures > Show Rosetta Destinations. Build in Rosetta after running the following command:

pod deintegrate && pod install

2 Comments

finally it's worked!!
I don't see the option for the Destination Architectures in the Destination dropdown. I am using xcode version 14.2
0

If you're working with Flutter, have followed all the steps and solutions, and are still experiencing an issue.

Ensure you've opened the iOS project in Xcode using Runner.xcworkspace instead of Runner.xcodeproj.

Runner.xcodeproj and Runner.xcworkspace directories in a Flutter project

As stated in the updated OneSignal documentation

You must exclusively use the .xcworkspace file to open the project.


Similar issues may occur in other libraries if you didn't open the project using Runner.xcworkspace.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.