During the iOS linking phase, I started seeing errors for my React Native project.
React Native version: 0.41.2, 0.40, 0.39
All worked fine, I edited the Android version, React Native code didn't change, when this kind of linking errors started showing up with headers on /node_modules/react-native/React/Base/{RCTHeaderName.h} path not being found:
In file included from /Users/user/ReactNativeProject/node_modules/react-native-vector-icons/RNVectorIconsManager/RNVectorIconsManager.h:9:
../react-native/React/Base/RCTBridgeModule.h:12:9: fatal error: 'React/RCTDefines.h' file not found
#import <React/RCTDefines.h>
^
In the Link Binary With Libraries I include the core React library
(libReact.a).
The location of the RCTLog.h is
PROJECTROOT/node_modules/react-native/React/Base/RCTLog.h, but the
import is #import <React/RCTLog.h>
Newly adding React.xcodeproj into Libraries doesn't help, Xcode's Product > Clean doesn't help, neither does restarting Xcode
react-native run-android works, react-native run-ios shows the error
File permissions set to the user executing react-native run-ios
Do you have Parallelize build option unchecked and React listed first in your build targets?
You can find this window in Xcode => Your project icon near the run button => Edit scheme => Build tab
Update:
solution on Facebook React-Native
https://github.com/facebook/react-native/issues/11813
============
This issue happened to me also.
It seems React.xcodeproj only recognise configuration Debug and Release. All of output of React.xcodeproj is written into Debug-iphonesimulator or Release-iphonesimulator.
That means if you have some configurations other than "Debug/Release", the output will still be written into Debug-iphonesimulator or Release-iphonesimulator, that is not what we want.
So the solution is to add a same configuration in React.xcodeproj to match the one of your own project.
For example, if you have "Debug/Release/Test/AppStore" 4 configurations in your own project, you have to make sure React.xcodeproj also has the same 4 configurations.
please click the "+" button of Configurations, then "Duplicate Release Configuration", and rename it according to you need.
It seems like there are a lot of reasons to be getting these 'missing headers' errors and I've tried a lot of things posted on Stack Overflow and nothing would work. Finally I stumbled upon the solution below that did work for me. Posting in case anyone else has the same issue ... its a bit obscure. For me it was caused by a build locations setting in Xcode that is apparently incompatible with vanilla React Native. The build locations setting that fixed this issue is shown here:
in XCode->Settings>Locations->Advanced... make sure your Build Location is not set to Legacy, it should be set to Unique
Note: the vanilla React Native application may have to be reinitialized from scratch with react-native init ... after changing this setting.
Add path/project folder/ios/Pods/Headers/Public in your Library's Build Settings -> Header Search Path. The issue will get resolved
Related
I have created a new react native project and when I try to run the app within an iOS emulator it always crashes.
When I open the .xcworkspace within Xcode I get the following error.
I have tried to update the search paths but this has not worked, I have also tried to reinstall pods but this hasn't worked.
This must be fixed on the framework side, however, the solution is the following steps:
On the Xcode bring the Build Settings tab
Find the Search Paths and then try to modify Library search paths
Add ${inherited} to the first of the list. It's important to be the first
Delete the build folder inside the ios folder of the project
Try to run the project again
It must fix the issue
This issue is basically related to the wrongly linking classes. Please follow these steps:
check make sure, you have install all the pods.
Please check your .js files, and check your import statements. To be make sure , every import statement package is installed in your project
clean project
Rebuild again
I can see that you state you have already checked search paths, but I had this same issue, and it was resolved by adding "${PODS_CONFIGURATION_BUILD_DIR}" as recursive to my Library Search Paths, under <Project> > Build Settings > Library Search Paths. However, now I'm stuck on the linker instruction -lcrypto, so it's not a complete solution.
I'm a beginner in iOS development. I cloned a repo containing working code. I opened up the project in xcode, but when I build the project I receive the error Module 'Subscriptions' not found.
In my build settings, the Subscriptions.framework framework is in Linked Frameworks and Libraries. From what I've researched about module not found errors in xcode, this should be the fix for my problem. However, this is not fixing my problem. This project should normally be able to be built and compiled. Is there something I'm missing here?
Update
Here is the xcode file tree view.
Main
|-Main
|-MainTests
|-Products
|-Frameworks
|-Subscriptions.xcodeproj
|-Subscriptions
|-Products
|-Subscriptions.framework
|-Frameworks
|-Pods
Pods
Ok. I finally figured out what was going on. I dove into the directory I thought that the Susbcriptions.framework was being installed in, and it wasn't there. The directory in the build products path was set to Products/Debug-iphoneos but the Subscriptions.framework was instead being installed into Products/Debug. This made me realize that somewhere in XCode I had the build setting set to build for MacOS instead of iOS. I found the setting and rebuilt my project for an iPhone XS simulator and the module was imported successfully.
I'm stuck on manually install RN-onesignal on iOS
already followed the instructions but I got an error RCTOneSignalExtensionService.h is not found
after some research, I found this issue that tell me to manually create bridge header, but I don't know the right way to create a bridge header itself (because this is my first time using macOS)
I've tried this step :
in Xcode project go to File->New->File
choose Swift file and Targeting to MyProject and OneSignalNotificationServiceExtension then finish
add #import "RCTOneSignalExtensionService.h" in OneSignalNotificationServiceExtension-Bridging-Header.h
add $(SRCROOT)/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension-Bridging-Header.h at build setting OneSignalNotificationServiceExtension target
but i got an error Bridging header 'MyProjectPath/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension-Bridging-Header.h' does not exist
FYI : at this step OneSignalNotificationServiceExtension-Bridging-Header.h file is on my project folder
so i decided to drag n drop the OneSignalNotificationServiceExtension-Bridging-Header.h to OneSignalNotificationServiceExtension folder, but the error still persist
anyone can help me to fix the error?
BTW my Xcode version is Version 8.3.2
Same problem, trying to solve this 3 hours.
Make sure you not missing this step:
I was working on my first React Native NativeModule. A simple 'Hello, World!' Objective-C function just to get an idea of how it worked. Things were going relatively smoothly, however, it seems xcode lost reference to all React Native files. I thought this problem was probably project specific, so I started a new TestApp using react-native init TestApp, but when I open that .xcodeproj file I have the same issue.
The first error in this new TestApp is in the AppDelegate.m file: 'React/RCTBundleURLProvider.h' file not found but as you might expect it avalanches from there.
I spent the most of yesterday trying out all sorts of potential solutions to no avail.
This might be a false lead, but maybe not, however I noticed Header Search Paths is empty whenever I first open .xcodeproj on a newly initialized project. That being said, I have tried numerous search paths based on answers I have found here on StackOverflow, GitHub, etc, the latest being $(SRCROOT)/../node_modules/react-native/React
I know this problem might be a little vague, but any help would be greatly appreciated. As an iOS developer, I am trying my best to be open to React Native, but continually running into issues such as this is really putting a damper on that.
Thanks!
ps. At this point I wonder if reinstalling xcode, node, npm, and react native altogether would be the surest solution.
Edits for clarity
First I run react-native init TestApp and cd TestApp followed by npm install. I've tried running react-native link at this point as well.
I then open ios/TestApp.xcodeproj. After xcode does its usual indexing I will inevitably be greeted by a red 'React/RCTBundleURLProvider.h' file not found in AppDelegate. Sometimes 'React/RCTRootView.' file not found' happens too. Most of the time, even if this second warning doesn't happen, The RCTRootView * in didFinishLaunchingWithOptions is not colored.
If I try to create a native module like so:
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#interface Test : NSObject <RCTBridgeModule>
#end
I get an immediate 'RCTBridgeModule.h' file not found.
In other words, Xcode is not finding anything RCT. Autocomplete doesn't suggest anything RCT.
Even with these warnings, I can run the app from Xcode or by running react-native run-ios.
This extra bit, may or may not be relevant:
If I have import { NativeModules } from 'react-native' in my App.js, NativeModules turns out to be undefined.
My current feeling is that there is a crucial step in set up that is not listed in the RN Docs, and for some reason other tutorials aren't touching either. I tried on another computer to the same result.
"Header search paths" being empty is perfectly normal. RN is exposing its headers from the React project. If you go to React.xcodeproj (under Libraries) you can see that the React target has a "Copy Headers" Build Phase, and these headers are being exposed when packaging the library as public headers.
To make sure that your app can use the headers, go to your app's scheme and into the Build section - the React target should be in the list and before your app's target. Also, the Parallelize Build checkbox needs to be OFF. It should be set-up like this out of the box in new RN projects, but maybe something was changed in your project so it's worth checking.
When the build is just starting, and especially on a freshly initialized project, you can expect to see some errors in the IDE during the build regarding public React headers, but they should be gone and resolved once all React third-party libraries finish building and React itself is packaged.
If everything is set-up correctly and it's still not working, delete the DerivedData folder and build again.
Finally linking native code with react-native!
So, I haven't really solved the precise issue, but I managed a workaround.
Previously I was trying to initialize a react-native project and then modifying the Xcode project that was built in the initialization.
I decided instead to approach the problem from the opposite angle of linking react-native to an existing xcode project by following this documentation: https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
I've been able to repeatedly link native code (both swift and objc) to react-native after react-native init TestApp by erasing the contents of TestApp/ios and following the process in the link above.
Thanks #Artal for providing some valuable info on the way it is supposed to work.
Following the instructions outlined here:
http://docs.phonegap.com/en/2.1.0/guide_upgrading_ios_index.md.html
I am attempting to upgrade an existing iOS project from Cordova 1.9 to 2.0.
After following the instructions line by line I'm still getting the following error when attempting to run:
Lexical or Preprocessor Issue -- "#import <Cordova/CDVPlugin.h>" File Not Found
The line generating this error reads:
#import <Cordova/CDVPlugin.h>
I have already done the following in an attempt to solve this:
Ensured I am importing the CordovaLib project correctly into my parent project
Double checked that I'm using the correct import syntax with brackets, instead of the quotes
Ensured my CORDOVALIB directory is accurate
Did a project clean and a clean build folder
Tried adding my CORDOVALIB folder to User Header Search Paths, recursively. Did nothing
I have a project I created via command line to harvest the cordova-2.0.0.js file. That project runs fine and I've nearly gone line by line through the Build Settings comparing it to my existing project and can't come up with anything different.
I am having a similar problem, one fix for many people is to make sure the Xcode preference "Xcode Preferences -> Locations -> Derived Data -> Advanced…" is set to "Unique"
(Note: Phonegap 2.9.1 (Nov 2013))
I encountered the same problem while trying to make an open source "C" phone gap plugin work. The solution was to add the Cordovalib.xcodeproj to the target project, once done,
click on your_project.xcodeproj - you will need to look in the Target Settings, under the Build Phases Tab, make sure that Cordovalib is added in Target Dependencies.
Once done it should allow the statement #import to work.