gpt4 book ai didi

ios - RCTBridge 委托(delegate)中的“NSInternalInconsistencyException”失败 - React Native

转载 作者:行者123 更新时间:2023-12-01 15:58:16 27 4
gpt4 key购买 nike

描述

我已经使用 XCode 8 成功构建了一个 react-native 项目,但应用程序在构建后崩溃并显示以下错误消息。我一直在尝试一切但无济于事,而且似乎没有类似的问题。我认为尝试调试的问题在于 RCTBridge.m:

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

由于在 RCTBatchedBridge 类和 RCTCxxBridge 之间进行选择,bridgeClass 返回断言错误
/**
* 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。没有先前的构建错误,并且构建处于 Debug模式。我也一直在使用 Ignite 样板,但从日志中它还没有转到特定于应用程序的代码。

构建成功后的错误:
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)X代码8
2) react 原生:0.44
3) macOSx

需要帮助来解决这个问题。预先感谢您的帮助!

最佳答案

我终于设法解决了这个问题,并将这个答案发布给那些可能遇到这个问题的人。

该错误是由于单独的修复,事后看来,这是一个临时的:

Duplicate symbols for architecture x86_64 under Xcode

删除 -ObjC from Other Linker Flags将导致上述问题,因为使用 native 类完成的任何链接都将不起作用并导致应用程序崩溃。所以我做的是以下内容:

1) 查找包含重复符号的文件并删除对重复文件的任何引用,同时保留项目的 Libraries 文件夹中的文件。

2) 重新插入-ObjC in the Other Linker Flags对于主要项目目标,应用程序将停止崩溃。

希望这可以帮助。

关于ios - RCTBridge 委托(delegate)中的“NSInternalInconsistencyException”失败 - React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44380079/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com