升级到React Native 0.60.5 iOS发行版后,版本会给出;“不存在捆绑URL”;错误
我刚刚用升级到React Native 0.60.5 iOS发行版后,版本会给出;“不存在捆绑URL”;错误,ios,react-native,upgrade,Ios,React Native,Upgrade,我刚刚用React-Native-upgrade和官方博客文章中提到的更新助手将我的项目从React-Native0.59.9更新为0.60.5。虽然我的项目已经有点“复杂”,因为它使用了一些库等。更新似乎是成功的 但不幸的是,我的应用程序不再适用于测试发布计划。在调试方案上,它可以毫无问题地工作。该版本也达到了“Build Successed”(构建成功)状态,但一旦应用程序启动,它就会因为“No bundle URL present”(不存在捆绑URL)错误而被卡住(另请参见我随附的Xcod
React-Native-upgrade
和官方博客文章中提到的更新助手将我的项目从React-Native0.59.9
更新为0.60.5
。虽然我的项目已经有点“复杂”,因为它使用了一些库等。更新似乎是成功的
但不幸的是,我的应用程序不再适用于测试发布计划。在调试方案上,它可以毫无问题地工作。该版本也达到了“Build Successed”(构建成功)状态,但一旦应用程序启动,它就会因为“No bundle URL present”(不存在捆绑URL)错误而被卡住(另请参见我随附的Xcode屏幕截图)
到目前为止,我已经尝试了在互联网上能找到的一切。重新安装NPM依赖项和POD;删除生成文件夹,更改Info.plist
中的NSAppTransportSecurity
,但是
这不能解决问题。。通过TestFlight部署的应用程序在启动时也会中断
反应本地信息
复制步骤
将react native从0.59.9更新为0.60.5
删除node\u模块
,ios/Pods
,ios/build
和Podfile.lock
重新安装node_模块
并运行pod安装
打开Project.xcworkspace
选择方案“项目-测试”转到“编辑方案>运行>构建配置”,并将方案更改为“测试-发布”
构建项目(在设备或模拟器上,无所谓)
“构建成功”并启动应用程序
应用程序卡在启动屏幕上,Xcode显示错误,如所附屏幕截图所示
文件/代码
目前这些是我的Info.plist
,Podfile
和package.json
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Jobner</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<true/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is required for searching jobs near you</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location is required for searching jobs near you</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
</dict>
</plist>
AppDelegate.m
应该链接到正确的捆绑文件,对吗?该代码在其中:
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
(我也在Github上的React Native issue tracker中发布了这个问题/bug。)
编辑:
我在这方面找到了解决办法。按照这些步骤,您可以创建main.jsbundle
和assets
文件夹,并将其添加到项目中
运行以下命令:react native bundle--dev false--platform ios--entry file index.js--bundle output ios/main.jsbundle--assets dest./ios
通过在项目中拖动main.jsbundle
和assets
目录,将它们添加到Xcode
虽然这感觉像是暂时的解决办法。。我现在有两个main.jsbundle
文件。我可以删除项目文件夹中的吗?assets
文件夹包含一些节点模块每次添加新模块并手动拖动项目根目录中的资源时,我是否都有此命令
另外,当我通过CI/CD(Bitrise)构建它时,根目录中没有创建main.jsbundle
,因为它在.gitignore
中默认被忽略。所以我的测试飞行构建仍然失败。如何处理
这里到底发生了什么
当您在发布模式下运行时,您必须拥有脱机main.js捆绑包。如果没有,这个问题只会出现。它不适用于0.60.5版本,即使在以前的版本中也会出现这种情况。因此,要创建脱机捆绑包,您需要在您提到的解决方案中执行步骤1。从0.60版本开始,当您执行此步骤时,将创建一个名为assets的文件夹。我不确定为什么需要拖动,因为如果您自动执行步骤1,它必须在xcode中索引。如果不发生这种情况,只需要在需要时拖动和复制项目
因此,这不是一个临时解决方案,而是您需要遵循的解决方案,以创建包含您所做的所有更改的捆绑包。这是reactnative中必须做的事情
注意:请删除js bundle和assets文件夹,并使用
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
当您在发布模式下运行时,您必须拥有脱机main.js捆绑包。如果没有,这个问题只会出现。它不适用于0.60.5版本,即使在以前的版本中也会出现这种情况。因此,要创建脱机捆绑包,您需要在您提到的解决方案中执行步骤1。从0.60版本开始,当您执行此步骤时,将创建一个名为assets的文件夹。我不确定为什么需要拖动,因为如果您自动执行步骤1,它必须在xcode中索引。如果不发生这种情况,只需要在需要时拖动和复制项目
因此,这不是一个临时解决方案,而是您需要遵循的解决方案,以创建包含您所做的所有更改的捆绑包。这是reactnative中必须做的事情
注意:请删除js bundle和assets文件夹,并使用
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
解决了这个问题。我的项目似乎缺少一个shell脚本,用于在“build Phases>bundle React Native code and images”下自动构建捆绑包和资产。当我打开这个部分时,Xcode也崩溃了
我打开文件/ios/Project.xcodeproj/Project.pbxproj
,搜索此部分:
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
};
并添加了shell脚本,因此我最终得到:
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
希望这能防止其他人花2天的时间在这上面;) 解决了这个问题。我的项目似乎缺少一个shell脚本,用于在“build Phases>bundle React Native code and images”下自动构建捆绑包和资产。当我打开这个部分时,Xcode也崩溃了
我打开文件/ios/Project.xcodeproj/Project.pbxproj
,搜索此部分:
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
};
并添加了shell脚本,因此我最终得到:
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
希望这能防止其他人花2天的时间在这上面;) 谢谢你的解释。但我必须说,这在早期版本中并没有发生。我以前从未运行过这个命令。我看到文件确实是自动添加的。但是我现在是否必须从.gitignore
中删除*.jsbundle
?否则,CI/CD生成将始终失败,因为此fi