'React/RCTUtils.h' file not found
Bug
I get the following error when trying to build the iOS app.
.../node_modules/react-native-device-info/ios/RNDeviceInfo/RNDeviceInfo.m:13:9: fatal error: 'React/RCTUtils.h' file not found
Environment info
I use pods in my project.
React native info output:
System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 54.81 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.7.0 - /usr/local/bin/node
Yarn: yarn install v0.27.5
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.73s. - /usr/local/bin/yarn
npm: 6.5.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 19, 22, 23, 24, 25, 26, 27, 28, 29
Build Tools: 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.3, 28.0.2, 28.0.3
System Images: android-19 | Intel x86 Atom, android-19 | Google APIs ARM EABI v7a, android-19 | Google APIs Intel x86 Atom, android-22 | Android TV Intel x86 Atom, android-22 | ARM EABI v7a, android-22 | G
oogle APIs Intel x86 Atom_64, android-23 | Android TV ARM EABI v7a, android-23 | ARM EABI v7a, android-23 | Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-24 | Intel x86 Atom, android-24 | Google
APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs ARM EABI v7a, android-26 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.1 => 16.6.1
react-native: 0.57.7 => 0.57.7
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Library version: 2.1.2
Steps To Reproduce
- Install and link:
1.1.
npm install1.2.react-native link react-native-device-info1.3.pod install - Run the project in Xcode.
Describe what you expected to happen:
The iOS project should successfully build and run.
Reproducible sample code
Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'FBSDKCoreKit', '4.40'
pod 'FBSDKLoginKit', '4.40'
pod 'FBSDKShareKit', '4.40'
pod 'GoogleSignIn', '~> 4.4.0'
# Required for new version of react-native-device-info, see https://github.com/react-native-community/react-native-device-info#manual
pod 'React', :path => '../node_modules/react-native'
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'MyApp-tvOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp-tvOS
target 'MyApp-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
# React-Native is not great about React double-including from the Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
# It removes React & Yoga from the Pods project, as it is already included in the main project.
targets_to_ignore = %w(React yoga)
if targets_to_ignore.include? target.name
target.remove_from_project
end
end
end
dupe #691 #688 #683
@mikehardy
#691 I tried the fix for issue #691 but i'm still getting this issue.
#688 I am using the latest version of Xcode (10.2.1)
#683 I've tried cleaning and reinstalling everything.
Am I missing something from the issue template?
Could it be the order in which I install node modules and pods?
Am I missing something from the issue template?
I don't think so - if you've checked the others and this is still happening I'll re-open it, but my Xcode-fu + Podfile-fu is not that strong, this will go on a stack of things to look at and I may not get it for a while - sorry
@mikehardy Thanks for the response. I'll keep looking into it and update if I find a solution.
I am seeing the same issue. Tried cleaning and reinstalling but to no avail. Here's my podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'WmtVolt' do
pod 'AppCenter/Crashes', '~> 2.0.1'
pod 'AppCenter/Analytics', '~> 2.0.1'
pod 'AppCenterReactNativeShared', '~> 2.0.0'
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for WmtVolt
pod 'React', :path => '../node_modules/react-native'
# Explicitly include Yoga for RN >= 0.42
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
platform :ios, '9.0'
pod 'react-native-camera', :path => '../node_modules/react-native-camera'
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
targets_to_ignore = %w(React yoga)
if targets_to_ignore.include? target.name
target.remove_from_project
end
end
end
end
Here's a reproducible repository: https://github.com/nartc/rndeviceinfo-reproduce
Steps:
npm installcd ./ios && pod installreact-native run-ios
Error: React/RCTUtils.h file not found
Environments:
- ReactNativeCLI: 2.0.1
- XCode: 10.2.1
- ReactNative: 0.59.9
I'll check that one, but I just tried with the example - which uses pods:
# Pods for exampleApp
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info/RNDeviceInfo.podspec'
and it works fine.
Can you examine for differences?
@mikehardy I'm missing RNDeviceInfo.podspec. Lemme double check
Update: Unfortunately, still the same error after adding RNDeviceInfo.podspec
Note that you want to do one or the other during react-native link, if you have linked before you used pods you have it linked in as a static .a in your .xcproject I think, but if you use this library as a Pod then it's in your Podfile and is in your .xcworkspace dynamically generated by pod install. Either way, the point of the example is to demonstrate that it can work, and that failures are most likely project-specific
I'm still looking though - this stuff is subtle and the existence of a reproduction repro is helpful
rather than comb through the repro - can you offer the exact steps you took to build it? like https://github.com/react-native-community/react-native-device-info/blob/master/refresh-example.sh
Here's the full context of how I ran into this problem. I added react-native-device-info (2.1.1) to my project about a week ago (I'm, by no means, a mobile developer so all of this linking stuff is new). And of course, I use react-native link at the time. Also, the moment I added react-native-device-info, I didn't have/use CocoaPods in my project. (no xcworkspace file).
Somewhere along last week, I added AppCenter and linking AppCenter using react-native link added CocoaPods to my project automatically. At this point, the project still works.
However, couple of days ago there was an update to Google Play Service and I noticed there's a hotfix for react-native-device-info (v 2.1.2). I unlinked, update and re-link. At this point, the project has had Pod and started having problem with RCTUtils.h
For the repro, here are the exact steps:
react-native init project_namenpm i react-native-device-infocd ./ios && pod init- Start filling out the
Podfileaccording to theREADME pod installcd ../ && react-native run-ios
I didn't run react-native link react-native-device-info because I wanted to test out Pod usage specifically.
That makes sense! But is also sort of terrible I think. Let me explain ;-). I am more a java person and the main thing I've learned about iOS is that moving from pre-Pods dependencies to Pods dependencies has the possibility to break your .xcproject file, which is a big mess that you can't really modify by hand (easily).
My best recommendation if you can is to go back in time to the git version prior to your unlink/re-link cycle, and just do the update. You don't have to unlink/re-link when packages update.
Conversion of a project from pre-Pods link to Pods link is something I'm even too scared to do on my work app as of yet. But I believe it involves opening the app in Xcode and deleting all the library references in your project, then closing Xcode, adding the now-deleted/pre-Pod dependencies to your Podfile and running Pod install
In your repro, you never actually run react-native link react-native-device-info ?
Correct.
And in regards to your above comment, I agree and learned it the hard way. I blame it on my lack of knowledge.
I'll try reverting to the point before I "re-linked" RNDeviceInfo.
@mikehardy However, you have any idea how it didn't work starting fresh using Pods?
Yeah still curious myself, so I'm leaving this open - but if you report success with a revert and standard update, it will be lower priority
@mikehardy just want to update reverting was successful. Thanks for the recommendations.
Glad to hear that worked! This comes up pretty frequently, as you could see from my first response to @fdwcomune - and now I think I finally understand how it can happen. Hopefully that helps fix the issue the original poster and others that have it in the future. Cheers