首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RCTBridge委派中的'NSInternalInconsistencyException‘失败- React Native

RCTBridge委派中的'NSInternalInconsistencyException‘失败- React Native
EN

Stack Overflow用户
提问于 2017-06-06 09:32:50
回答 0查看 1.7K关注 0票数 2

描述

我已经成功地使用XCode 8构建了一个react-native项目,但应用程序在构建后崩溃,并显示以下错误消息。我已经尝试了所有的方法,但都没有效果,而且似乎没有类似的问题。我认为问题出在RCTBridge.m中:

代码语言:javascript
复制
- (Class)bridgeClass
{
  // In order to facilitate switching between bridges with only build
  // file changes, this uses reflection to check which bridges are
  // available.  This is a short-term hack until RCTBatchedBridge is
  // removed.

  Class batchedBridgeClass = objc_lookUpClass("RCTBatchedBridge");
  Class cxxBridgeClass = objc_lookUpClass("RCTCxxBridge");

  Class implClass = nil;

  if ([self.delegate respondsToSelector:@selector(shouldBridgeUseCxxBridge:)]) {
    if ([self.delegate shouldBridgeUseCxxBridge:self]) {
      implClass = cxxBridgeClass;
    } else {
      implClass = batchedBridgeClass;
    }
  } else if (batchedBridgeClass != nil) {
    implClass = batchedBridgeClass;
  } else if (cxxBridgeClass != nil) {
    implClass = cxxBridgeClass;
  }

  RCTAssert(implClass != nil, @"No bridge implementation is available, giving up.");
  return implClass;
}

其中,bridgeClass返回断言错误,原因是在RCTBatchedBridge类和RCTCxxBridge之间进行了选择,两者都不返回,如下面RCTBridgeDelegate.h中的注释所述

代码语言:javascript
复制
/**
 * Configure whether the legacy RCTBatchedBridge or new RCTCxxBridge
 * should be used.  If this method is implemented and the specified
 * bridge is not linked in, startup will fail.  If this method is not
 * implemented, the implementation will default to RCTBatchedBridge,
 * but if it is not linked in, will try RCTCxxBridge instead.  If
 * neither bridge is linked in, startup will fail.  This order will be
 * reversed in the near future, as the legacy bridge is closer to
 * being removed.
 *
 * @experimental
 */
- (BOOL)shouldBridgeUseCxxBridge:(RCTBridge *)bridge;

再现步骤和示例代码

所有涉及的RN模块都已安装,并与npm和CocoaPods链接等。没有以前的生成错误,并且生成处于调试模式。我也一直在使用Ignite样板,但从日志中看,它还没有转到应用程序特定的代码中。

构建成功后的错误:

代码语言:javascript
复制
2017-06-06 08:48:57.019 rn_irnext_demo[16376:122081] *** Assertion failure in -[RCTBridge bridgeClass](), myApp/node_modules/react-native/React/Base/RCTBridge.m:292
2017-06-06 08:48:57.031 rn_irnext_demo[16376:122081] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No bridge implementation is available, giving up.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000113344b0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000112da9141 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000113348cf2 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x000000011297869f -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 165
    4   rn_irnext_demo                      0x000000010e578e27 -[RCTBridge bridgeClass] + 535
    5   rn_irnext_demo                      0x000000010e578f7d -[RCTBridge setUp] + 285
    6   rn_irnext_demo                      0x000000010e578387 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] + 375
    7   rn_irnext_demo                      0x000000010e5781a2 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] + 146
    8   rn_irnext_demo                      0x000000010e54fee7 -[RCTRootView initWithBundleURL:moduleName:initialProperties:launchOptions:] + 183
    9   rn_irnext_demo                      0x000000010e540c58 -[AppDelegate application:didFinishLaunchingWithOptions:] + 280
    10  UIKit                               0x0000000111008957 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
    11  UIKit                               0x000000011100a23c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4119
    12  UIKit                               0x0000000111010584 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1709
    13  UIKit                               0x000000011100d793 -[UIApplication workspaceDidEndTransaction:] + 182
    14  FrontBoardServices                  0x000000011a3775f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    15  FrontBoardServices                  0x000000011a37746d -[FBSSerialQueue _performNext] + 186
    16  FrontBoardServices                  0x000000011a3777f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    17  CoreFoundation                      0x00000001132eac01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    18  CoreFoundation                      0x00000001132d00cf __CFRunLoopDoSources0 + 527
    19  CoreFoundation                      0x00000001132cf5ff __CFRunLoopRun + 911
    20  CoreFoundation                      0x00000001132cf016 CFRunLoopRunSpecific + 406
    21  UIKit                               0x000000011100c02f -[UIApplication _run] + 468
    22  UIKit                               0x00000001110120d4 UIApplicationMain + 159
    23  rn_irnext_demo                      0x000000010e54103f main + 111
    24  libdyld.dylib                       0x00000001139cb65d start + 1
    25  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

另外还会生成一个Thread 1:signal SIGABRT error in the main.m file.

其他信息:

1) XCode 8 2) react-native: 0.44 3) macOSx

在解决这个问题上需要帮助。提前感谢您的帮助!

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44380079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档