react-native-device-info: '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 install
1.2.react-native link react-native-device-info
1.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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24 (1 by maintainers)
hey @alexstoyanov I had this same error. My mistake was using both pod install and react-native link <pakcageName> so I ran react-native unlink packageName. Then I went into the ios directory of my react native project and ran pod deintegrate && pod install then cd back to the root of the project and run react-native run-ios. everything is working great.
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.
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
I’ll check that one, but I just tried with the example - which uses pods:
and it works fine.
Can you examine for differences?