我最近换了电脑,所以我刚刚重新下载了我的 github 存储库。当我决定在我的设备上运行该应用程序时,我看到红色屏幕,告诉我不存在 bundle URL。
有一次(很久以前)我无法运行该项目,所以我首先在模拟器上运行它,然后在设备上运行它,它工作了。但现在这不起作用了。模拟器工作正常,但我无法在设备上运行任何东西。当我打开 xcode 时,我看到 main.jsbundle 是红色的。我不知道是不是这个问题。 此外,我的设备与我的计算机位于同一网络中。
我该如何解决这个问题?
最佳答案
尝试以下步骤:
第 1 步:打开命令提示符并从项目的根位置运行以下命令。
react-native bundle --platform ios --dev false --assets-dest ./ios --entry-file index.js --bundle-output ios/main.jsbundle
第 2 步:将下面一行添加到 AppDelegate.m
文件的 didlaunching
方法
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
//jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@”index” fallbackResource:nil];
关于ios - react native : I can run the application on iOS simulator but not on real device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54902079/