react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

RCTOneSignal.m fails to compile in Xcode

Open 0xpatrickdev opened this issue 8 years ago • 4 comments

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

  1. 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)

  2. How did you add the SDK to your project (eg. npm) yarn add react-native-onesignal react-native link react-native-onesignal cd ios then pod install (also did a pod update when attempting to debug) (CocoaPods version is 1.5.3)

Steps to Reproduce Issue:

Followed the Guide Here: https://documentation.onesignal.com/docs/react-native-sdk-setup

  1. yarn add react-native-onesignal and react-native link react-native-onesignal
  2. Generate Cert using OneSignal Provisionator Tool (pretty nifty btw!)
  3. 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?

0xpatrickdev avatar May 29 '18 21:05 0xpatrickdev

@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)?

Nightsd01 avatar May 30 '18 15:05 Nightsd01

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.

Nightsd01 avatar May 31 '18 20:05 Nightsd01

same issue

ejswenson15 avatar Jul 12 '18 07:07 ejswenson15

same issue for me here as well. Anyone found a solution yet? @pcooney10 @ejswenson15

varqasim avatar Oct 25 '18 11:10 varqasim