React-native-onesignal: OneSignal/OneSignal.h file not found

Created on 24 Jan 2017  ·  44Comments  ·  Source: OneSignal/react-native-onesignal

There was and issue already opened and closed, but this is still and issue. See issue 133.

My comment on the issue describes the problem.

React Native 0.40.0 OneSignal 3.0

Most helpful comment

Merged, tested and fixed.

All 44 comments

So basically it means that the framework is not updated on the module, if you choose not to use CocoaPods. Am I correct?

Yes, I think that is correct. I am not using CocoaPods.

I see. The current problem is that I can't find any way to make the library recognize the framework if it's outside the library, for example in the Frameworks group on the Xcode project. That makes the library dependent on a specific version of the framework, rather than adding it manually.

Hey, found a repo with hints for you. Made my code work again.
https://github.com/eriksape/react-native-onesignal#faq-repeating-issues

@avishayil,

I not really familiar with objective-c, I really wish I could help solve the problem.
Could there be an update to the documentation to let people know about the issue?

In the mean time I copied the OneSignal.framework directory into my ios project with the right "Header" directory and "OneSignal" file and changed the "Framework Search Paths" to point to it.

I will have to keep and eye for updates, but this works for me for now. Thanks!

@haxtrujillo Also running into this issue when not using CocoaPods. Which Header file and OneSignal file did you change to make this work via direct import instead of the official README instructions? Thanks!

@dguillamot make sure to set the "Header Search Paths" and "Header Search Paths", copy the files from version "B" (Current) two levels up.

screen shot 2017-01-25 at 11 13 26 pm

I'm still wondering how to solve it without this "ugly" way. @jkasten2 can you help here?

I have the same issue, plus React/<...>.h not found.
screen shot 2017-01-26 at 2 31 54 pm

screen shot 2017-01-26 at 7 37 18 pm

I also have same issue with React-Native 0.4.0,

After install some plugin(react-native-firestack), suddenly it happens.

@rustykey @bitsal

I had to do 2 separate things to get it working:

0 - I created a subfolder in my main project folder (where the xcode workspace file is) called /ios/OneSignal

1 - Then, similar to what haxtrujillo said above, in the node_modules/react-native-onesignal/ios/Frameworks folder, you can double-click / expand the OneSignal.framework file. Inside there is a Versions/B subfolder. Select the 'Headers' and 'OneSignal' files in there, copy ( CMD-C ) and then select the OneSignal.framework 'file' again and paste .

Then, I copied this new OneSignal.framework file into the /ios/OneSignal folder I made above in step 0.

2 - Next, I copied the node_modules/react-native-onesignal/ios/RCTOneSignal.xcodeproj file and the RCTOneSignal folder over to the ios/OneSignal folder I made in step 0.

Then in Xcode, I added the OneSignal.Framework file into the Frameworks folder of my xcode workspace, and added the RCTOneSignal.xcodeproj to the Libraries folder. Then, I selected the xcodeproj file in my Libraries folder in xcode. Checking that the target was RCTOneSignal, I went to BuildSettings, and changed Framework Search Paths to be '$(PROJECT_DIR)/OneSignal' .. That way it could find the new OneSignal.framework I made. I also changed Header Search Paths in the same Build Settings area to make sure that it was picking up React. In my case, it was easiest to do it relative to PROJECT_DIR as '$(PROJECT_DIR)/../node_modules/react-native/React'

After these changes, everything is now in my ios/OneSignal folder and I don't really need the node_modules folder at all. I am still using it though, for Android. But if you are ios only, you don't need the node_module folder as this workaround has basically made a local copy.

This is definitely not a good long term solution and should be undone once the author has updated this package. It's just short-cutting the node module by copying the project over so you can change the Build Settings. Once the node module is modified to fix this issue, these changes should be undone.

Thank you @dguillamot !

I've done it in a bit different way but sense is the same I guess
package.json:

"scripts": {
     ...
    "fix-onesignal-ios-issue-161": "cd node_modules/react-native-onesignal/ios/Frameworks/OneSignal.framework && cp -R Versions/B/* . && cd ../../../../..",
    "run-ios": "npm run fix-onesignal-ios-issue-161 && echo '.env.local' > /tmp/envfile && react-native run-ios",
     ...
}

P.S.:
@avishayil
I noticed in RCTOneSignal project's Header Search Paths a line like this "$(SRCROOT)/../../../ios/Pods/Headers/Public/OneSignal".
It seems library requires me to have node_modules and ios folders on the same level. In some cases (when project structure is a bit different) it won't work because there is no folder $(SRCROOT)/../../../ios.

P.S. 2:
Also, I had an issue like React/RCT<...>.h file not found. I've fixed by building React first from the XCode (see https://github.com/facebook/react-native/issues/12042#issuecomment-275025960).

react-native run-ios doesn't work yet (, only from XCode.

There hasn't been a Versions/B folder since version 2.1.5 of the native iOS OneSignal SDK. Can you check to make sure your pulling in the latest OneSignal.framework? Currently 2.3.5 is that latest.

@jkasten2 right, 2.3.5 version now
I'm sure because I many times run

rm -rf node_modules/react*
rm -rf ios/build/* && rm -rf ios/Pods/*
rm -rf ~/Library/Developer/Xcode/DerivedData/*

BTW,

react-native-cli: 2.0.1
react-native: 0.40.0

Podfile:

pod 'OneSignal', '~> 2.0'

but actually it installs 2.3.5, I see it in the console output

@jkasten2,
I am using React Native 0.40.0, OneSignal 3.0 and no CocoaPods.

@jkasten2
You are right. There is no Versions/B folder in ios/Pods/OneSignal/iOS_SDK/Framework/OneSignal.framework/Versions/:

Current -> A

but Versions/B is still here node_modules/react-native-onesignal/ios/Frameworks/OneSignal.framework/Versions/

package.json
"react-native-onesignal": "3.0.0",

The issue seems to be missing symlinks from the 3.0.0 release tag.

@avishayil I noticed that the v3.0.0 tag is missing them but master has them.
https://github.com/geektimecoil/react-native-onesignal/tree/v3.0.0/ios/Frameworks/OneSignal.framework
https://github.com/geektimecoil/react-native-onesignal/tree/master/ios/Frameworks/OneSignal.framework

The native iOS SDK repo also has symlinks here.
https://github.com/OneSignal/OneSignal-iOS-SDK/tree/2.3.5/iOS_SDK/Framework/OneSignal.framework

Can you release an update with these missing files?

@jkasten2 There you go, in this project at the examples branch:
https://github.com/geektimecoil/react-native-onesignal/tree/examples/examples/RNOneSignalFramework

Try to build this project, it says it's missing the header files.

@avishayil I did a fresh clone and following the instructions below but didn't run into a missing .h issue.
https://github.com/geektimecoil/react-native-onesignal#running-example-project

Note: The instructions should be cd OneSignalRN instead of cd OneSignalRNExample.

Ran the project from both the terminal as the instructions noted and built from Xcode directly by opening the RNOneSignal.xcworkspace file.

Hi @jkasten2, no problem when building a project with CocoaPods. Problem is when trying to build a project with the framework without CocoaPods.

I mentioned this before, forgive me if this is a duplicate but: One of the problems is that the header file OneSignal.h IS in the repo, but they are not under a folder called "OneSignal" which is how they are referenced.

@avishayil is still the problem without cocoa?, sorry for didn't notice it, let me see guys and am going to let you know :)

@eriksape yep

@avishayil I don't know what happen, my method to insert is still Ok, as I see cocoa pods do the same thing but automatically and downloading a lot of packages with the last version of OneSignal-iOS-SDK as said by @jkasten2 is the 2.3.5, know you downgrade the version of the sdk now?

Guys I have the header issue when using v2 and Cocoapods :/ Any hint on why? Should I create a dedicated issue?

I'll have a look on v2 this week.

I am on RN40 and OneSignal3.0, using the Framework and still getting "OneSignal/OneSignal.h not found". My header / framework paths are correctly set, the library has been linked with react-native link, so I don't see any issue regarding setup.

I had the same with Cocoapods though.

I was having this error for v3.0.0 and react native 0.41. I got it to build by running the command react-native link.

Correction: still getting a build error :(

Are you guys using CocoaPods?

@avishayil No, I'm not using Cocoapods and will not be using it. I just got your latest changes in 3.0.2 and it's still not building. Any updates on fixing this?

@larryranches This is still something i'm looking at alongside OneSignal's team. @jkasten2 and I will update when we have a solution for this.

@avishayil Thanks for looking into this! Would be nice to get this working as we have to upgrade to the latest React Native 0.41. Please let us know once there's a fix.

Same issue when running with Xcode. App starts with node node_modules/react-native/local-cli/cli.js run-ios but crashed because RNOneSignal is undefined.

@avishayil I have tried to use Coca and the Framework, same result.

@edo1493 can you share a repo with the error reproduced?

This pull-request worked for me ✌️:
https://github.com/geektimecoil/react-native-onesignal/pull/184

Interesting, how did you build it? From scratch or to an existing project?

@avishayil into a existing project (with the problem described here) and followed the updated README at https://github.com/jkasten2/react-native-onesignal.
(Had to remove Podfile and related files)

PR #184 works for me as well

Merged, tested and fixed.

i have done all the things still its not found :(

I have this error too with Cacaopods ... RN 0.50 and react-native-onesignal ^3.0.5

anyone fix this bug ? i am facing on RN 0.51 and react-native-onesignal ^3.0.5

Reinstalling one signal from scratch helped me fix this issue.

Was this page helpful?
0 / 5 - 0 ratings