我有反应本机项目,它的工作在模拟器和设备上都很好。
但我注意到,当我的电脑关闭时,当我试图在设备上运行我的项目时,我无法运行这个项目。
当我的电脑开机时,我工作得很好。
知道为什么会发生这种事吗?如何解决?
发布于 2019-03-18 16:12:28
您的应用程序无法工作,因为包处于脱机状态(节点服务器关闭)。
安卓构建(Apk)
现在使用以下命令创建脱机js。
react-native bundle --platform android
--dev false --entry-file index.js --bundle-output
android/app/src/main/assets/index.android.bundle
--assets-dest android/app/src/main/res/现在运行此命令以创建脱机资源文件和其他
cd android && ./gradlew assembleRelease使用Android打开~/android文件夹,您就有了独立的android应用程序。
IOS Build(IPA)
在创建包之前,请检查AppDelegate.m文件中的IPA构建,我们需要静态绑定,它在脱机模式下工作
#if DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif创建脱机绑定
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios现在我们打开Xcode并执行以下操作
1产品->清洁
2产品->档案
然后,您必须在Xcode中使用Product -> Archive,并根据所需的发行版执行以下步骤
https://stackoverflow.com/questions/55216283
复制相似问题