简体   繁体   English

React Native:我可以在iOS模拟器上运行应用程序,但不能在真实设备上运行

[英]React native: I can run the application on iOS simulator but not on real device

I changed my computer recently, so I just downloaded my github repo again. 我最近更换了计算机,所以我再次下载了我的github存储库。 When I decided to run the app on my device I got the red screen telling me No bundle URL present. 当我决定在设备上运行该应用程序时,出现红色屏幕,告诉我不存在捆绑软件URL。

Once (a long time ago) I could not run the project, so I first run it on the simulator and then on the device and it worked. 有一次(很久以前)我无法运行该项目,因此我先在模拟器上运行它,然后在设备上运行它,然后它就可以运行了。 But now this is not working. 但是现在这行不通了。 The simulator works fine, but I can't run anything on the device. 模拟器运行正常,但是我无法在设备上运行任何东西。 When I open xcode I see the main.jsbundle in red. 当我打开xcode时,我看到的main.jsbundle为红色。 I don't know if this is the problem. 我不知道这是否是问题。 Also my device is in the same network of my computer. 另外,我的设备与计算机在同一网络中。

How can I fix this? 我怎样才能解决这个问题?

Try below steps: 请尝试以下步骤:

Step 1: Open command prompt and run below command from project's root location. 步骤1:打开命令提示符,然后从项目的根目录运行以下命令。

react-native bundle --platform ios --dev false --assets-dest ./ios --entry-file index.js --bundle-output ios/main.jsbundle

Step 2: Add below line into AppDelegate.m file's didlaunching method 步骤2: didlaunching添加到AppDelegate.m文件的didlaunching方法中

 jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
//jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@”index” fallbackResource:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM