ios - react native : I can run the application on iOS simulator but not on real device

标签 ios xcode react-native

我最近换了电脑,所以我刚刚重新下载了我的 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/

相关文章:

iPhone 电池耗尽问题

iphone - 在 UITableView 中加载 plist

android - 无法构建 React Native 0.59.8 android.support.v4.net.ConnectivityManagerCompat

react-native - react native : Victory chart formatting for x-axis time column

ios - 如果我想为 UIButton 创建更大的点击区域,我应该覆盖 hitTest : or pointInside:?

ios - 从 CloudKit 中获取多个记录类型

ios - 无法在名称为 'itemCell' 的包中加载 NIB '

objective-c - NSFetchedResultsController 缺少一些对象

objective-c - 如何在 Cocoa 编程中访问不同类的对象

javascript - 在expo react-native中打开键盘时如何隐藏TabBar