React Native真机运行

根据之前iOS真机测试的经验, 我把开发好的RN应用直接安装到自己的手机里, 兴冲冲的打开后, 居然红屏
WTF?

解决方案

下面给出的是最简单的解决方案, 只适用于个人测试, 如果要发布到App Store, 还要做额外的设置

找到AppDelegate.m

把下面的代码注释掉:

1
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

把下面的代码注释打开

1
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

重新安装即可

Fork me on GitHub