RCTOneSignal.m fails to compile in Xcode
Description:
I am attempting to set up OneSignal with an ExpoKit project. The build command that compiles RCTOneSignal/RCTOneSignal.m seems to fail. Opening up Xcode it says "'React/RCTDefines.h' file not found" on the 10th line, #import <React/RCTDefines.h>.
Environment
-
What version of the OneSignal React-Native SDK are you using?
"react-native-onesignal": "^3.2.4""expo": "^27.0.1","react-native": "https://github.com/expo/react-native/archive/sdk-27.0.1.tar.gz",(based on RN 55) -
How did you add the SDK to your project (eg. npm)
yarn add react-native-onesignalreact-native link react-native-onesignalcd iosthenpod install(also did apod updatewhen attempting to debug) (CocoaPods version is1.5.3)
Steps to Reproduce Issue:
Followed the Guide Here: https://documentation.onesignal.com/docs/react-native-sdk-setup
yarn add react-native-onesignalandreact-native link react-native-onesignal- Generate Cert using OneSignal Provisionator Tool (pretty nifty btw!)
- Enable Capabilities in Xcode (Push Notifications, Background Notifications, & Groups)
4a. Add Notification Service Extension (OneSignalNotificationServiceExtension) in Objective-C
4b. Update Header Search Paths in OneSignalNotificationServiceExtension
4c. Link binaries in Build Phases - only UIKit.framework & SystemConfiguration.framework available
4d. Copy RCTOneSignal.xcodeproj from node_modules folder into Libraries folder, then added newly available libRCTOneSignal.a to linked binaries.
4e. Overwrite NotificationServiceExtension.m per instructions on OneSignal website
5a.react-native run-ios --simulator='iPhone 8 Plus'
5b. Build Fails, with this message:
** BUILD FAILED **
The following build commands failed:
CompileC /Users/myusername/myApp/ios/build/Build/Intermediates.noindex/RCTOneSignal.build/Debug-iphonesimulator/RCTOneSignal.build/Objects-normal/x86_64/RCTOneSignal.o RCTOneSignal/RCTOneSignal.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/myApp.app
Launching com.something.myApp
com.something.myApp: 6063
6a. App runs fine on iOS Simulator (unsure if OneSignal is installed at some capacity at this point). 6b. Uncomment the following:
componentWillMount() {
OneSignal.setLogLevel(6, 0)
OneSignal.init('my-app-id')`
}
6c. RN errors out on refresh with: Cannot read property 'initWithAppId' of undefined
Anything else: From some of the more recent issues I read through, it seems like you guys are updating the install process? I believe I am following the documentation pretty well, so hopefully something here pops out.
Edit - Also- should I have pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal' in my Podfile?
@pcooney10 if you manually copy the RCTOneSignal.xcodeproj project into your Xcode project, you’re essentially duplicating what pod install is doing.
I would suggest running pod deintegrate, then remove any references to OneSignal from your podfile. Then run pod install again. If RCTOneSignal.xcodeproj doesn’t show up in your project, copy it again, and make sure to add libRCTOneSignal.a as a linked binary for both your main app and the Notifications extension service.
PS: can you tell me how it went when you were developing with Expo? Did it cause confusion for you that RCTOneSignal didn’t work (since it can’t load native code until you detach)?
Assuming that fixed your issue, this looks like a duplicate static lib issue. If not, please feel free to reply and I'll be happy to reopen the issue and investigate.
same issue
same issue for me here as well. Anyone found a solution yet? @pcooney10 @ejswenson15