2016-12-05 85 views
0

我遵循“入门”构建我的第一个React本机应用程序。反应本机iOS应用程序崩溃

这是我做的:

npm install -g yarn react-native-cli 

react-native init AwesomeProject 
cd AwesomeProject 
react-native run-ios 

然而,应用程序成功地建成后坠毁。

然后我打开Xcode运行应用程序,但应用程序再次崩溃。

这里是信息:

2016-12-05 13:26:26.633 [info][tid:main][RCTBatchedBridge.m:73] Initializing <RCTBatchedBridge: 0x60800019f210> (parent: <RCTBridge: 0x6080000b1460>, executor: RCTJSCExecutor) 
2016-12-05 13:26:26.634 AwesomeProject[89471:10945233] *** Assertion failure in -[RCTBatchedBridge loadSource:onProgress:](), /Users/Leaf/Desktop/AwesomeProject/node_modules/react-native/React/Base/RCTBatchedBridge.m:197 
2016-12-05 13:26:26.663 AwesomeProject[89471:10945233] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleURL must be non-nil when not implementing loadSourceForBridge' 
*** First throw call stack: 
(
    0 CoreFoundation      0x000000010adcc34b __exceptionPreprocess + 171 
    1 libobjc.A.dylib      0x0000000109cda21e objc_exception_throw + 48 
    2 CoreFoundation      0x000000010add0442 +[NSException raise:format:arguments:] + 98 
    3 Foundation       0x00000001098a6d79 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166 
    4 AwesomeProject      0x00000001093ef035 -[RCTBatchedBridge loadSource:onProgress:] + 997 
    5 AwesomeProject      0x00000001093ed1a3 -[RCTBatchedBridge start] + 883 
    6 AwesomeProject      0x000000010942d20c -[RCTBridge setUp] + 684 
    7 AwesomeProject      0x000000010942c263 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] + 387 
    8 AwesomeProject      0x000000010942c072 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] + 146 
    9 AwesomeProject      0x000000010938d077 -[RCTRootView initWithBundleURL:moduleName:initialProperties:launchOptions:] + 183 
    10 AwesomeProject      0x0000000109376585 -[AppDelegate application:didFinishLaunchingWithOptions:] + 245 
    11 UIKit        0x000000010d33e0be -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 290 
    12 UIKit        0x000000010d33fa43 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4236 
    13 UIKit        0x000000010d345de9 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731 
    14 UIKit        0x000000010d342f69 -[UIApplication workspaceDidEndTransaction:] + 188 
    15 FrontBoardServices     0x0000000110867723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 
    16 FrontBoardServices     0x000000011086759c -[FBSSerialQueue _performNext] + 189 
    17 FrontBoardServices     0x0000000110867925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45 
    18 CoreFoundation      0x000000010ad71311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 
    19 CoreFoundation      0x000000010ad5659c __CFRunLoopDoSources0 + 556 
    20 CoreFoundation      0x000000010ad55a86 __CFRunLoopRun + 918 
    21 CoreFoundation      0x000000010ad55494 CFRunLoopRunSpecific + 420 
    22 UIKit        0x000000010d3417e6 -[UIApplication _run] + 434 
    23 UIKit        0x000000010d347964 UIApplicationMain + 159 
    24 AwesomeProject      0x000000010937695f main + 111 
    25 libdyld.dylib      0x000000010ed1e68d start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

AppDelegate.m

/** 
* Copyright (c) 2015-present, Facebook, Inc. 
* All rights reserved. 
* 
* This source code is licensed under the BSD-style license found in the 
* LICENSE file in the root directory of this source tree. An additional grant 
* of patent rights can be found in the PATENTS file in the same directory. 
*/ 

#import "AppDelegate.h" 

#import "RCTBundleURLProvider.h" 
#import "RCTRootView.h" 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    NSURL *jsCodeLocation; 

    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 

    RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 
                 moduleName:@"AwesomeProject" 
               initialProperties:nil 
                launchOptions:launchOptions]; 
    rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 
    UIViewController *rootViewController = [UIViewController new]; 
    rootViewController.view = rootView; 
    self.window.rootViewController = rootViewController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

@end 
+2

显示'AppDelegate.m'文件的代码。 –

+0

@NiravD我已经添加了'AppDelegate.m' – zhuscat

回答

0

原因的内容是2.6.8在全局模式下运行。 问题解决后,我把它关掉。