- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSURL * jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"HelloWorldApp"
initialProperties:nil
launchOptions:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
CGRect rect=CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width , [UIScreen mainScreen].bounds.size.height);
self.window = [[UIWindow alloc] initWithFrame:rect];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController=rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
由于沒有開啟服務(wù) 運行報錯Could not connect to development server
解決方法?
(1)終端cd到當(dāng)前項目 然后npm start 然后重新運行xcode項目,還是報錯的話就退出xcode 重新來一次就ok了