ios - iOS 上 React Native 中的 BatchedBridge 错误

标签 ios react-native

我有一个简单的原生 iOS 应用程序,我想将 React Native 集成到其中。当我打开 View Controller 时,出现错误:

> Error calling RCTLog.logIfNoNativeHook
> 
> Unhandled JS Exception: Could not get BatchedBridge, make sure your
> bundle is packaged correctly
> 
> RCTFatal
> -[RCTCxxBridge handleError:]
> __34-[RCTCxxBridge _initializeBridge:]_block_invoke facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()>
> const&)
> facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void
> ()>&&)::$_1::operator()() const void
> std::__1::__invoke_void_return_wrapper<void>::__call<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void
> ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void
> ()>&&)::$_1&&&)
> std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void
> ()>&&)::$_1,
> std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void
> ()>&&)::$_1>, void ()>::operator()() std::__1::function<void
> ()>::operator()() const invocation function for block in
> facebook::react::RCTMessageThread::runAsync(std::__1::function<void
> ()>)
> __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
> __CFRunLoopDoBlocks
> __CFRunLoopRun CFRunLoopRunSpecific
> +[RCTCxxBridge runRunLoop]
> __NSThread__start__
> _pthread_body
> _pthread_body thread_start

这是我的 Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'NativeRNTest' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    'BatchedBridge',
    # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"

  # Third party deps podspec link
  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'

  # Pods for NativeRNTest

  target 'NativeRNTestTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'NativeRNTestUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

我的环境:
>react-native info
Scanning folders for symlinks in /Users/[redacted]/Projects/native_rn_demo/node_modules (5ms)

Environment:

  OS: macOS Sierra 10.12.6
  Node: 8.9.0
  Yarn: 1.1.0
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
  react: ^16.0.0 => 16.0.0
  react-native: ^0.51.0 => 0.51.0

我已经搜索过这个问题,所有的解决方案都是针对Android的,在这里似乎不起作用。有任何想法吗?

最佳答案

好的,我通过重命名 index.js 修复了错误至index.ios.js .

关于ios - iOS 上 React Native 中的 BatchedBridge 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48014303/

相关文章:

Swift 中的 iOS 9 斯坦福类(class) - 第 1 讲

ios - react-native 支持 NSDataDetector 吗?

ios - React Native 如何使用 expo 和 firebase 设置推送通知

iphone - 没有平滑的图像查看器

android - 我可以在 Android 或基于 Web 的应用程序上使用 CloudKit 吗?

ios - 在 iOS 应用程序中添加应用程序事件会产生未声明的标识符 'AppEvent'

javascript - 返回特定屏幕而不是第一个屏幕 react-native-navigation

iphone - 适用于 iOS 设备的 Sprite

react-native - 类型错误 : null is not an object (evaluating '_ReanimatedModule.default.createNode' )

react-native - 在 React Native 中访问静态/本地镜像