Solvedreact native onesignal Unable to add Notification Service Extension

Description:

On iOS I am able to setup the SDK to work with notifications, however, after adding the Notification Service Extension I run into an error, notably the symbol(s) not found for architecture x86_64 found in the troubleshooting guide and several other issues opened here.

My main issue is this: I can't add the framework libRCTOneSignal.a because it doesn't exist...? I think I am missing something here? πŸ€·β€β™‚οΈ

Environment

  1. OneSignal React-Native SDK 3.2.4
  2. npm install --save react-native-onesignal
  3. react-native link react-native-onesignal
  4. pod version 1.4.0
  5. Expo detached app

Steps to Reproduce Issue:

  1. npm install
  2. exp detach
  3. npm install --save react-native-onesignal
  4. react-native link react-native-onesignal
  5. cd ios/ and run pod install
  6. Configure XCodeProject following the official setup guide
  7. At this point if I build and run on my device, I am able to receive the notifications.
  8. Following the setup guide to add Notification Service Extension
  9. libRCTOneSignal.a cannot be added to the framework since it is not found resulting in the symbol(s) not found for architecture x86_64 build failed error

Anything else:

screen shot 2018-06-20 at 6 01 00 pm

26 Answers

βœ”οΈAccepted Answer

@jdegger that approach seems to have worked for me also, nice one πŸ‘

I used abstract_target to tidy up my Podfile slightly:

abstract_target 'MyAppAbstractTarget' do
  pod 'React',
    :path => "../node_modules/react-native",
    :inhibit_warnings => true,
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "CxxBridge"
    ]
  pod 'yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga",
    :inhibit_warnings => true
  pod 'DoubleConversion',
    :podspec => "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec",
    :inhibit_warnings => true
  pod 'Folly',
    :podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec",
    :inhibit_warnings => true
  pod 'glog',
    :podspec => "../node_modules/react-native/third-party-podspecs/glog.podspec",
    :inhibit_warnings => true
  
  
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
  
  post_install { |installer| perform_post_install_tasks(installer) }
  
  target 'MyOneSignalNotificationsApp' do
    pod 'ExpoKit',
      :git => "http://github.com/expo/expo.git",
      :tag => "ios/2.6.5",
      :subspecs => [
        "Core",
        "CPP",
        "GL"
      ],
    :inhibit_warnings => true
  end
  
  target 'OneSignalNotificationServiceExtension'
end

I defined perform_post_install_tasks as a separate method to tidy up the target block further, it contains the same auto-generated content as posted in @yirui94's earlier post

I then amended the Build Settings of my OneSignalNotificationServiceExtension target, setting both Search Paths > Header Search Paths and Search Paths > Library Search Paths to $(inherited).

In Build Phases, under Link Binary With Libraries, I removed all except:

screen shot 2018-06-27 at 15 03 25

I then ran pod install, which links the pod libraries to both targets.

At this point, I was able to build successfully and send out notifications πŸŽ‰

Other Answers:

I seem to have fixed something similar by adding a target completely separate from my main target with all the react stuff included. Probably way too much, but I'm not sure what I can leave out at this point.

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'alarmPrototype' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  
  pod 'Firebase/Core'
  
  # Your 'node_modules' directory is probably in the root of your project,
  # but if not, adjust the `:path` accordingly
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Pods for alarmPrototype
  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  pod 'react-native-battery', :path => '../node_modules/react-native-battery'
  pod 'RNI18n', :path => '../node_modules/react-native-i18n'
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'

  # Calling
  pod 'TwilioVoice', '~> 2.0.0'
  pod 'RNTwilioVoice', :path => '../node_modules/react-native-twilio-programmable-voice'
  pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'

end

target 'OneSignalNotificationServiceExtension' do

  # Pods for sevice extension
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
  ]

  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # pods
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'

end

This is more of a problem with our documentation (for using OneSignal after detaching with Expo) than a bug with our SDK, sorry for the inconvenience this has caused you.

We'll update our documentation to better explain how the SDK should be used in Expo projects (which usually use Cocoapods to manage dependencies as opposed to React's more traditional Xcode sub-project model).

I'll mark this issue as resolved once I've updated our docs, also @yirui94 please let me know if the approach described above by @atothewest resolves the problem for you

Related Issues:

67
react native onesignal IOS pod install is failing
Can you try pod update? Hello I have problem installing this library ...
60
react native onesignal Could not find firebase-iid.aar...
@rodrigofbm In your android/build.gradle in your repositories section try moving google() ABOVE jcen...
58
react native onesignal com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzas;
Update 2018-11-07 This looks to be conflict with another plugin including a different interdependenc...
42
react native onesignal OneSignalNotificationServiceExtension causes sharedApplication build issues
Went through this exact same issue and like @indapublic did I had added the extension to my Podfile ...
32
react native onesignal Google Play Services Library Error
@brunoandradebr @DaniloCouto @ifanfaizal I fix Description: The registred device returns an error on...
30
react native onesignal Not working on React Native 0.60
I had same problem and just removed the following lines from package.json in node_modules/react-nati...
22
react native onesignal Get the current playerid/userid
The goal was to recieve PlayerID from Onesignal on application launch So in App.js for me worked the...
18
react native onesignal Unable to find libRCTOneSignal.a
Turns out react-native link did not work correctly as usual :D I just had to manually add the RCTOne...
6
react native onesignal OneSignal OneSignalNotificationExtension build fail on Xcode 12 related to cocoapods / architecture / simulator issues
I’m having some issues too with Xcode 12 I can successfully build the project on Xcode 11 ...
5
react native onesignal Unable to add Notification Service Extension
@jdegger that approach seems to have worked for me also Description: On iOS I am able to setup the S...
3
react native onesignal RN 0.40.0 iOS Won't Build: ld: 102 duplicate symbols for architecture arm64
@dwilt @Ouadie As of version 3.0.3 the OneSignal iOS native SDK is now part of it You will need to r...
750
react native keychain SDK Build Tools revision (23.0.1) is too low for project :react-native-keychain.
Ok I found a solution to this For people facing the same problem in the future Hey there ...
748
material components android Manifest merger failed : Attribute application@appComponentFactory
I had similar problem We're transitioning from github issues to a public buganizer component Rather ...
746
expo Error: fsevents unavailable (this watcher can only be used on Darwin)
Possible solution: I had installed watchman via npm install -g watchman but apparently this installs...
459
flutter Multiple commands produce '/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework
I was able to fix it by opening the Runner workspace project in Xcode 10 Then navigate to File ...
449
flutter App Store iOS submission fails: The bundle Runner.app/Frameworks/App.framework does not support the minimum OS Version specified in the Info.plist
After doing a flutter clean changing MinimumOSVersion (inside /ios/Flutter/AppframeworkInfo.plist) t...
418
flutter 'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (27.0.1) classpath
is like this i receive an error when i run flutter run My gradle.build file is: flutter doctor: ...
409
flutter Why does my text not wrap?
You have to wrap Column in a flexible Without flexible the column's width is not constrained to the ...
383
flutter Unexpected top padding in ListView put inside scaffold with no appBar
Yeah this is intentional If you put a widget before the ListView you should wrap the ListView with a...
315
flutter Missing xcode dependency: Python module "six"
try python2.x -m pip install six by @humblerookie's suggest or brew reinstall python@2 pip install s...
306
expo exp build:android fails
This works exp start Cancel ctrl c then do exp build:android. Running exp build:android errors fails...
285
flutter flutter messaging: set the notification icon
Hey guys I fought with this for the better part of a day For some strange reason there are no tutori...
281
flutter Issue with cloud_firestore - Cannot fit requested classes in a single dex file.
As a workaround you can try enabling mutlidex for Android App by following Enable multidex for apps ...
265
flutter D8: Program type already present: io.flutter.BuildConfig
@smrucv I received the same error but after flutter clean and flutter packages get everything works ...
250
238
flutter Introduction of characters package causes crash on flutter run for preexisting Flutter applications
In my case I resolved the issue with flutter clean After e0ed12c I get this error when building: @ju...
222
nativescript cli TNS doctor doesn't recognize Xcode (High Sierra)
HI @philipfeldmann Can yhou please run xcodebuild -version and paste the output? May be Xcode is ins...
221
flutter Making Network http error SocketException: Failed host lookup
@hoc081098 Double-check / make sure you have <uses-permission android:name=android.permission.INTERN...
216
flutter Support inlining Android/iOS views
iOS view embedding support has landed on master This is still just a preview There are multiple open...
207
flutter βœ— Android license status unknown.
Hi everyone Steps to Reproduce Please tell us what you were doing and what went wrong If you are run...
195
react native mapbox gl No static method toHumanReadableAscii
here is workaround: build.gradle got the following error on runtime: java.lang.NoSuchMethodError: No...
185
flutter idevice_id cannot run on catalina
When you're developing on Catalina Steps to Reproduce Run flutter doctor on macOS Catalina I get the...
181
flutter type 'List<dynamic>' is not a subtype of type 'List<String>'
The problem is your fromMap constructor is reading from a Map<String dynamic> ...
178
flutter TextField is hidden by keyboard inside of a Modal Bottom Sheet
This may not work for all situations but I have a modalBottomSheet that contains only a TextField ...
173
retrofit Kotlin & @Body
You can still use Map just suppress its wildcardness with @JvmSuppressWildcards ...
169
NativeBase Needs to tap twice to fire onPress function when keyboard is open
@bm-software Use keyboardShouldPersistTaps={'handled'} and will works fine. react-native ...
162
react native firebase πŸ”₯(Android) Program type already present: io.invertase.firebase.BuildConfig
I think I found my ultimate error here In my package.json file I had at some point earlier ...
160
flutter Dismissing keyboard programatically
This is a better way as it also clears the focus: FocusScope.of(context).requestFocus(new FocusNode(...
157
flutter How to solve: Android license status unknown and also Android sdkmanager tool not found? Tried everything(as i think)
The answer is here Uncheck Hide Obsolete Packages and you'll see Android SDK Tools (Obsolete) 26.1.1...
156
flutter MissingPluginException: No implementation found for method
@mravn-google Yeah turned out I had to quit the flutter run process and start it up again Just a ful...
156
flutter firebase_auth: ^0.8.0+1 crashes on Android
Here i put this in file: android/gradle.properties: and changed targetSdkVersion to 28 and it worked...
156
react native modal The statusbar turns white when the modal is open (only on certain devices)
statusBarTranslucent property has been added to Modal of RN 0.62 I think this problem has been solve...
153
flutter Android sdkmanager tool not found (C:...\Local\Android\sdk\tools\bin\sdkmanager)
This worked for me: open Android Studio's SDK Manager go to the Android SDK tab under SDK Tools ...
149
flutter 1.22.2 - Flutter plugin not installed; this adds Flutter specific functionality.
Hey @bhanuka96 try this line of code How do I fix this android plugin error? This error is being com...
145
cli pod install failure with glog
what helped me: sudo xcode-select --switch /Applications/Xcode.app Ask your Question I have been try...