React-native: Can't run react native app from existing ios app

Created on 27 Sep 2019  路  32Comments  路  Source: facebook/react-native

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

  1. create react app
  2. configure xcode follow pod file
  3. 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}];
Bug iOS Stale

Most helpful comment

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

All 32 comments

I have the same error upgrading to 61.1 from an existing react-native (recent) application. Android running fine.

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.

@AustP downgraded too and working too here 馃憤

I am also seeing this problem, but need 0.61 for CocoaPods support. Is there any more information?

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

@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?

@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.

I tried again without running react-native upgrade, just follow the upgrade-helper diff to update my project and the error is gone.

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

This worked for me.
Thanks

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:

...
# React Native pods
pod 'React-Core', :path => '../../node_modules/react-native'
pod 'React-CoreModules', :path => '../../node_modules/react-native/React/CoreModules'
#pod 'React-Core/DevSupport', :path => '../../node_modules/react-native/'
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-Core/RCTWebSocket', :path => '../../node_modules/react-native/'

#pod 'ReactCommon/jscallinvoker', :path => "../../node_modules/react-native/ReactCommon"
#pod 'ReactCommon/turbomodule/core', :path => "../../node_modules/react-native/ReactCommon"
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 'React-CoreModules', :podspec => '../../node_modules/react-native/React/CoreModules/React-CoreModules.podspec'
pod 'ReactCommon', :path => '../../node_modules/react-native/ReactCommon'
pod 'FBLazyVector', :podspec => '../../node_modules/react-native/Libraries/FBLazyVector/FBLazyVector.podspec'
pod 'FBReactNativeSpec', :podspec => '../../node_modules/react-native/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec'
pod 'RCTRequired', :podspec => '../../node_modules/react-native/Libraries/RCTRequired/RCTRequired.podspec'
pod 'RCTTypeSafety', :podspec => '../../node_modules/react-native/Libraries/TypeSafety/RCTTypeSafety.podspec'
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'
...

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.

Getting same error and tried all above solution, but can't success...

Simulator Screen Shot - iPhone X - 2019-10-11 at 17 56 25

I'm using RN 0.61.2 with an existing iOS project.

Help?

@Frakcool I ran into the same issue, did you find any solution ?

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

This worked like a charm for me

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:

...
# React Native pods
pod 'React-Core', :path => '../../node_modules/react-native'
pod 'React-CoreModules', :path => '../../node_modules/react-native/React/CoreModules'
#pod 'React-Core/DevSupport', :path => '../../node_modules/react-native/'
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-Core/RCTWebSocket', :path => '../../node_modules/react-native/'

#pod 'ReactCommon/jscallinvoker', :path => "../../node_modules/react-native/ReactCommon"
#pod 'ReactCommon/turbomodule/core', :path => "../../node_modules/react-native/ReactCommon"
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 'React-CoreModules', :podspec => '../../node_modules/react-native/React/CoreModules/React-CoreModules.podspec'
pod 'ReactCommon', :path => '../../node_modules/react-native/ReactCommon'
pod 'FBLazyVector', :podspec => '../../node_modules/react-native/Libraries/FBLazyVector/FBLazyVector.podspec'
pod 'FBReactNativeSpec', :podspec => '../../node_modules/react-native/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec'
pod 'RCTRequired', :podspec => '../../node_modules/react-native/Libraries/RCTRequired/RCTRequired.podspec'
pod 'RCTTypeSafety', :podspec => '../../node_modules/react-native/Libraries/TypeSafety/RCTTypeSafety.podspec'
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'
...

I'm using RN 0.61.2 with an existing iOS project.

i have the same issue. do you have any solution?

@bockc @zhonglaoban I searched on Finder for: RCTRequired and looked at the path for the podspec, then included it into the podfile. But I don't think that's the solution, as it shows up other errors, so I'm currently working on a new project (from scratch) and see if I can manage to get the result I want. If so, I'll let you know what I did.

@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.

I solved all of my problems by doing the following (dirty way but only one who worked after hours of trying):

$ react-native init tmpapp
$ cp tmpapp/ios/Podfile myapp/ios/
$ rm myapp/ios/Podfile.lock
$ cd myapp/ios/ ; pod install ; cd .. # EDIT: not sure if this is needed
$ react-native run-ios

Hope this helps anyone.

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...

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

This works for me! Thank you!

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

This did not fix it for me...

I was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

It doesn't work for me. RN 0.61.4. Any updates here?

still having this issue, tried everything said here but nothing. getting

Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: 
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found.
Verify that a module by this name is registered in the native binary.'

on release scheme

@netgfx same error, I have an issue in the CodePush repo --> https://github.com/microsoft/react-native-code-push/issues/1704

At this point I've given up on CP in iOS and I'm just hoping this do their new re-write release sometime in the not too distant future.

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 do add files... with XCode and add it.
Then do Archive from XCode for generic device.
Note: if you aren't using index.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 was able to fix this problem by adding the following podspecs:

  • React-CoreModules
  • ReactCommon/turbomodule/core
  • FBLazyVector
  • FBReactNativeSpec
  • RCTRequired
  • RCTTypeSafety

I used this commit for guidance.

This worked like a charm for me

i got Unable to find a specification for `ReactCommon/turbomodule/core ..where you find turbomodule???

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

I have same issue:
Invariant Violation: TurboModuleRegistry.getEnforcing(...): \'PlatformConstants\' could not be found
Have anyone solved?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anchetaWern picture anchetaWern  路  3Comments

josev55 picture josev55  路  3Comments

DreySkee picture DreySkee  路  3Comments

jlongster picture jlongster  路  3Comments

WG-Com picture WG-Com  路  3Comments