Can't run react native app from existing ios app

See original GitHub issue

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}];

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:32

github_iconTop GitHub Comments

33reactions
BrianBatcheldercommented, Oct 1, 2019

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.

14reactions
samirmagnatescommented, Oct 11, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Integration with Existing Apps - React Native
Integration with Existing Apps. React Native is great when you are starting a new mobile app from scratch. However, it also works well...
Read more >
How to add React Native to an existing iOS app in 2022
I have been starting to use React Native in existing iOS and Android apps that I am maintaining. One of the problems I...
Read more >
How to integrate react native code with an existing iOS app?
1. Create a directory structure and set up the dependencies. ... Create a root folder where the react native module and the existing...
Read more >
Implement react-native-web on existing app, web can run but ...
So I want to implement react-native-web to an existing apps (Android and iOS) and I following this tutorial. And I run the web...
Read more >
How to create React Native App for Android, iOS and Web ...
Step 1: Init a React Native Application: · Step 2: Run this new app in Android (optional) · Step 3: Web Setup.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found