【发布时间】:2016-12-04 06:23:00
【问题描述】:
我正在尝试运行使用 react native (v0.3) 创建的应用程序,而无需连接到我的计算机。我已经将应用程序与react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios 捆绑在一起,并在我连接的iPhone 上运行(在Xcode 上也更改为Release)。
即使(在启动后)我禁用 WiFi 并断开手机与我的 Mac 的连接,这也能正常工作。但是,如果我完全关闭应用程序并尝试再次启动它(没有连接 WiFi 或 USB)它会崩溃(它会显示应用程序屏幕并在几秒钟后崩溃)...
在启动时,我可以看到一个标有“连接到 192.*”的绿色条(这可能是我的 mac 的 IP 地址)。如何完全禁用连接?该连接对调试非常有用,但无法将应用展示给他人。
按照official documentation 中的建议取消注释AppDelegate.m 中的jsCodeLocation 部分并没有多大帮助,因为不可能生成此代码:
#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:@"weather"
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;
}
或者我只是在这里遗漏了什么?
版本:
- OSX 10.11.5
- Xcode 7.3.1
- React Native 0.3
- npm 3.10.3
【问题讨论】:
标签: ios iphone xcode npm react-native