react-native: Can't run react native app from existing ios app
I tried to run my react native app using RCTRootView but keep throwing this error
2019-09-27 16:28:42.163 [info][tid:com.facebook.react.JavaScript] 'Failed to print error: ', 'Requiring module "node_modules/react-native/Libraries/Utilities/Platform.ios.js", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): \'PlatformConstants\' could not be found. Verify that a module by this name is registered in the native binary.'
2019-09-27 16:28:42.171 [fatal][tid:main] Unhandled JS Exception: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary.
React Native version:
React 16.9.0 React-Native 0.61.1
pod config
pod 'React', :path => 'react/node_modules/react-native/'
pod 'React-Core', :path => 'react/node_modules/react-native/'
# pod 'React-DevSupport', :path => 'react/node_modules/react-native/React'
# pod 'React-fishhook', :path => 'react/node_modules/react-native/Libraries/fishhook'
pod 'React-RCTActionSheet', :path => 'react/node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => 'react/node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => 'react/node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => 'react/node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => 'react/node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => 'react/node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => 'react/node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => 'react/node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => 'react/node_modules/react-native/Libraries/Vibration'
# pod 'React-RCTWebSocket', :path => 'react/node_modules/react-native/Libraries/WebSocket'
pod 'React-cxxreact', :path => 'react/node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => 'react/node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => 'react/node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => 'react/node_modules/react-native/ReactCommon/jsinspector'
pod 'Yoga', :path => 'react/node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => 'react/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => 'react/node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => 'react/node_modules/react-native/third-party-podspecs/Folly.podspec'
Steps To Reproduce
- create react app
- configure xcode follow pod file
- http://$host:$port/index.bundle?platform=ios
Describe what you expected to happen:
run seemlessly
Snack, code example, screenshot, or link to a repository:
Running Code in XCode
NSURL *jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.67:19000/index.bundle?platform=ios"];
_rctBridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation moduleProvider:nil launchOptions:nil];
_rootView = [[RCTRootView alloc] initWithBridge:_rctBridge moduleName:@"AppHome" initialProperties:@{@"appId":self.marketApp.appId}];
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 32
I was able to fix this problem by adding the following podspecs:
I used this commit for guidance.
Getting same error and tried all above solution, but can’t success…
I’m using RN 0.61.2 with an existing iOS project.
Getting the same error as OP on v0.61.2, when adding RN to an existing iOS project following the guide:
https://facebook.github.io/react-native/docs/integration-with-existing-apps
The Podfile required quite a few changes compared to the Podfile in the tutorial, I think the tutorial might be outdated. After getting around that problem, getting the same error OP mentioned:
[fatal][tid:main] Unhandled JS Exception: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary.
I was on 0.60.5 then went to 0.61.1. Then I ran into this issue and downgraded back to 0.60.6 and now it is working for me.
I solved all of my problems by doing the following (dirty way but only one who worked after hours of trying):
Hope this helps anyone.
Use Upgrade helper to solue this issue https://react-native-community.github.io/upgrade-helper/?from=0.60.4&to=0.61.2
Following @BrianBatchelder comment, however I’m getting an issue with FBLazyVector and RCTRequired stating that
AccessibilityPrimitives.h file not found
This is how my
Podfile
looks like:I’m using RN 0.61.2 with an existing iOS project.
@AustP downgraded too and working too here 👍
@qyhongfan I followed https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.61.2, I’m currently at my 5th try. So this is definitely not gonna help anyone here as this issue could come from react-native itself as much as a dependency. The thing is, compilation errors do not give enough informations for us to precisely know which dependancy could be causing the error, and we can’t afford spending a week testing them out one by one.
@BrianBatchelder I already added those podspecs in my
Podfile
but still ran into this issue. Did I miss something? I used upgrade-helper(https://react-native-community.github.io/upgrade-helper/?from=0.60.5&to=0.61.1) for guidance.Finally after hours of struggle I was able to get it working, I manually run
react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
and add the/assets
folder in XCode. If you don’t have a/Resources
folder create one, the main.jsbundle will appear there after you run the script. If it doesn’t appear, manually doadd files...
with XCode and add it. Then do Archive from XCode for generic device. Note: if you aren’t usingindex.js
as your main js file rename it in the script above.This way I was able to get it working for release. @ahartzog
I solved my problems by updating from 0.59.10 to 0.60.4 and then to 0.61.2. Now my issue is that just like in 0.60, fetch returns a blob everytime…
@BrianBatchelder currently working on this same issue. I’ve included all of those podspecs. Did you end up fixing it for RN 0.61, 0.61.1 or another version?