'react-native ios Podfile issue with "use_native_modules!"
In my react-native project ([email protected]) in the ios/ dir I run pod install and get this error:
[!] Invalid `Podfile` file: no implicit conversion of nil into String.
# from /Users/coryrobinson/projects/hhs2/ios/Podfile:37
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------
I haven't added or changed anything in this Podfile - it's all react-native generated. (I'm not experienced in iOS dev so this might be a simple fix, I just don't know what to look for :-|) Thanks for any help!
Here is my Podfile
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'hhs2' do
# Pods for hhs2
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
pod 'RNFS', :path => '../node_modules/react-native-fs'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
target 'hhs2Tests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
target 'hhs2-tvOS' do
# Pods for hhs2-tvOS
target 'hhs2-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Solution 1:[1]
Downgraded @react-native-community/cli-platform-ios from 3.1.0 to 3.0.0 and it worked.
Added
"@react-native-community/cli-platform-ios": "3.0.0"
to package.json.
Run npm install and then pod install to get it working again.
Solution 2:[2]
If you are using
pod install --project-directory=ios
you might need to tweak the Podfile by replacing
use_native_modules!
to
use_native_modules!(".")
Maybe this behavior will be improved in the future, I opened an issue about it https://github.com/react-native-community/cli/issues/657
Solution 3:[3]
i just dropped the whole node_modules and RN cache folder and did a clean reinstall, this fixed the "use_native_modules" problem so far....but after that i had to hassle a lot with other libs which where just not RN0.60 ready ;)
Solution 4:[4]
Verify if you have @react-native-community/cli-platform-ios in your package.json,
if you dont run:
npm install @react-native-community/cli-platform-ios
then
cd ios && pod install
Solution 5:[5]
this is because the outdate yarn version on your device, if you on macOS you can upgrade/install the yarn with follow this link: here it is
be aware to delete node-module and yarn.lock file, install all packages again, navigate to ios folder and run pod install.
Solution 6:[6]
For me, I deleted the node_modules and installed again by using npm install . After that, I navigated to /ios folder and ran pod install it worked.
Solution 7:[7]
Ok, my guess is for most people, the accepted answer will fix their issue. For me, the fix was so bizarre, I had to add it here.
For whatever reason, I ended up creating an invalid AndroidManifest.xml file in my android native setup.
I looked at the full error output, and the first lines of the error referenced a line number and column number. At that point in my xml file I broke the xml formatting.
2 days of searching to find a GitHub Issue with a description of where to look.
Solution 8:[8]
Don't use yarn install. Thats what worked for me...
- Go to main folder
- Delete nodes folder
- Run
sudo npm installor justnpm install cd iospod install
Solution 9:[9]
Having same issue while building app on AppCenter, locally works perfectly
Is there any possibility to track this error? Cause I've seen that there can be a lof of reasons why I see it.
Solution 10:[10]
After removing several react-native npm packages (ie: react-native-bluetooth-serial, react-native-sound, and more...) pod install works.
It appears the pod install error is related to older react-native packages that don't support cocoa pods? I'm not sure the details but removing those packages from node_modules & package.json solved my issue.
Solution 11:[11]
The issue is that:
use_native_modules!
is unsupported by earlier versions of CocoaPods. For example, our install was the app downloaded from the CocaoPods website. That version is 1.5.2.
Run:
pod --version
to check which version. If need be, uninstall and then re-install but in Terminal by running:
sudo gem install cocoapods
At least as of late October 2019, the current gem version available is 1.8.4. Once successfully installed, re-attempt the pod install and hopefully all is well.
Solution 12:[12]
I got this error after I tried to react-native run-ios an Expo app. The error I got indicated that something was wrong with the Pods, so I ran cd ios && pod install, which is how I got a similar error as the OP.
In that case, you obviously need to expo start instead of react-native run-ios.
Solution 13:[13]
This started happening out of the blue today, and the problem was a space in my directory structure. Ex:
/path/to/Directory\ Name/RNProject throws the !native_modules error /path/to/DirectoryName/RNProject works as it should
Pods was looking for "Directory. "
Solution 14:[14]
maybe its related to rights issues
adding "@react-native-community/cli-platform-ios": "3.0.0" in package.json
and
sudo chown -R user .
worked for me
Solution 15:[15]
Got it working based on a blog post from one of JavaScript Guru's.
Easily:
- Run
sudo xcode-select --switch /Applications/Xcode.appin therootof yourReact Nativeproject. - In the
iosfolder runpod install.
Edit:
No hacks with any of:
@react-native-community/cli-platform-iosrequire_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
were needed.
Solution 16:[16]
One of the reasons may be outdated version of Ruby. Use following command to upgrade it.
rvm install 2.6.1
rvm use 2.6.1 --default
Or you can follow below article, which has a detailed explanation of upgrading ruby and associated gems.
https://help.learn.co/en/articles/2789231-how-to-upgrade-from-ruby-2-3-to-2-6
Solution 17:[17]
Does anyone have a consistently recreatable solution for this issue that does not revolve around getting rid of use_native_modules? I have looked into:
- Changing Ruby Version
- Changing CocoaPods version
- Invalidating NPM and Cocoapods cache
And I am unable to fix the issue. It appears to be some npm dependency, but others on my team are not seeing it.
Solution 18:[18]
Getting rid of the line use_native_modules! works as well. Maybe this has been deprecated or syntax has changed? Curious to hear from others.
Update: Seems to be an issue with react-native 0.60.0. Until a release fixes this bug, 0.59.10 can be explicitly installed, and you only need to add CocoaPods as necessary.
react-native init APP_NAME --version [email protected]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
