Delete node modules, then run npm install (or better yet yarn) and after everything has finished downloading, run react-native upgrade which should give you the option to replace old files with the template ones, by doing so you re-link your native dependencies in react-native which should fix your problem. Of course don't forget to clean your project in Xcode.
Scanning 554 folders for symlinks in /Users/..../work/..../react_tutorial/AwesomeProject/node_modules (15ms)
┌────────────────────────────────────────────────────────────────────────────┐
│ Running packager on port 8081. │
│ │
│ Keep this packager running while developing on any JS projects. Feel │
│ free to close this tab and run your own packager instance if you │
│ prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
/Users/..../work/...../react_tutorial/AwesomeProject
Loading dependency graph... ERROR Packager can't listen on port 8081
Most likely another process is already using this port
Run the following command to find out which process:
lsof -i :8081
I found that package manager can't run when another packager process is running.
I found the process running with:
lsof -i :8081
Than I kill 9 ... the process.
After than I closed Xcode, run:
npm install
And started Xcode again, from this moment everything work as expected!!
None of the other suggestions were fixing my error but this one did it.
1 - Create Podfile
Create a file named ios/Podfile inside your react-native app with the following contents:
# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target '<YOUR_APP_NAME>' do
# Fixes required for pod specs to work with rn 0.42
react_native_path = "../node_modules/react-native"
pod "Yoga", :path => "#{react_native_path}/ReactCommon/yoga"
pod "React", :path => react_native_path, :subspecs => [
'Core',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]
pod 'GoogleMaps' # <~~ remove this line if you do not want to support GoogleMaps on iOS
# when not using frameworks we can do this instead of including the source files in our project (1/4):
# pod 'react-native-maps', path: '../../'
# pod 'react-native-google-maps', path: '../../' # <~~ if you need GoogleMaps support on iOS
end
2 - Install Podfile
Run the command pod install from inside the ios folder.
For all those are using React Native 0.40.0 or higher, Header Imports have a major change from RN 0.40.0 and result in lots of .h file not found errors. react-native-git-upgrade fixed the issue for me while in debug but build fails in release/archive.
I am using RN 0.42.3 with cocoapods and Xcode 8.2.1
To completely fix this go to Xcode>Product>Scheme>Edit Scheme>
Untick Parallelize Build
Click on + button in Targets and add React
Drag the added React to top of the List in Targets.
I found that my fix to this issue after upgrading React was to change the declaration of #import "RCTBundleURLProvider.h" to #import <React/RCTBundleURLProvider.h>
I ran into this problem after my first try running a React build in XCode, and all I had to do was actually build and run to make the error go away (after picking a team and proper provisioning). Sometimes XCode shows errors that aren't really errors until it compiles and links things the first time.
I tried all the suggestions and none of them worked at the i deleted the repo and clone it again and that work for me, so my suggestion is commit your changes back them up and clone the repo again that worked for me.
For my case, I couldn't delete node_modules and re-install and I also couldn't do react-native-git-updgrade or react-native upgrade because I wanted to stay on RN-0.59 because .60 causes problems for my dependencies.
Anyway my situation was that I was missing 'React/RCTBundleURLProvider.h' file. I already had React available in my schemas. It was not in my libraries directory. I checked my target's build settings.
Inside target dependencies, I also had React in there.
I deleted 'React' target dependency, then re-added. cleaned build folders, re-built project. it worked.