gpt4 book ai didi

ios - 升级到 React Native 0.60.5 iOS 发布版本后出现 "No bundle URL present"错误

转载 作者:行者123 更新时间:2023-11-28 20:51:41 27 4
gpt4 key购买 nike

我刚刚使用 react-native upgrade 和更新助手将我的项目从 React Native 0.59.9 更新到 0.60.5官方博文中提到。虽然我的项目已经有点“复杂”,因为它使用了一些库等,但似乎更新成功了。

但不幸的是,我的应用程序不再适用于 Test - Release 方案。在调试方案上,它可以正常工作。该版本也达到了“构建成功”状态,但是一旦应用程序启动,它就会因为“不存在捆绑 URL”错误而卡住(另请参见我随附的 Xcode 屏幕截图)。

到目前为止,我已经尝试了所有可以在 Internet 上找到的内容。重新安装 NPM 依赖项和 Pod;删除构建文件夹,更改 Info.plist 中的 NSAppTransportSecurity,但是它不会解决问题。通过 TestFlight 部署的应用程序在启动时也会中断。

React Native 信息

System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 430.30 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 23, 26, 28, 29
Build Tools: 28.0.3, 29.0.0
System Images: android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1

重现步骤

  1. 将 react-native 从 0.59.9 更新到 0.60.5
  2. 删除 node_modulesios/Podsios/buildPodfile.lock
  3. 重新安装 node_modules 并运行 pod install
  4. 打开Project.xcworkspace
  5. 选择方案“项目 - 测试”转到“编辑方案 > 运行 > 构建配置”并将方案更改为“测试 - 发布”
  6. 构建项目(在设备或模拟器上,无所谓)
  7. “构建成功”并启动应用
  8. 应用卡在启动画面上,Xcode 显示错误,如所附屏幕截图所示

文件/代码

目前这些是我的 Info.plistPodfilepackage.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>
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

project 'Project',
'Prod - Debug' => :debug,
'Acc - Debug' => :debug,
'Test - Debug' => :debug,
'Prod - Release' => :release,
'Acc - Release' => :release,
'Test - Release' => :release

target 'Project' do
# Pods for Project
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

target 'ProjectTests' do
inherit! :search_paths
# Pods for testing
end

use_native_modules!
end
{
"name": "project",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"lint": "eslint --ext .jsx --ext .js src/",
"ios": "react-native run-ios --scheme \"Project - Test\" --configuration \"Test - Debug\"",
"android": "ENVFILE=.env.dev react-native run-android --variant=devDebug --appIdSuffix=dev",
"postinstall": "npx jetify"
},
"dependencies": {
"@aws-amplify/auth": "1.2.31",
"@aws-amplify/core": "1.1.0",
"@babel/polyfill": "7.4.4",
"@react-native-community/async-storage": "1.6.1",
"accounting": "0.4.1",
"amazon-cognito-identity-js": "3.0.15",
"cross-fetch": "3.0.4",
"dayjs": "1.8.15",
"iban": "0.0.12",
"prop-types": "15.7.2",
"qs": "6.7.0",
"react": "16.9.0",
"react-geocode": "0.1.2",
"react-native": "0.60.5",
"react-native-android-keyboard-adjust": "^1.2.0",
"react-native-bootsplash": "1.0.1",
"react-native-config": "luggit/react-native-config#master",
"react-native-datepicker": "1.7.2",
"react-native-device-info": "2.3.2",
"react-native-gesture-handler": "1.3.0",
"react-native-keyboard-aware-scroll-view": "0.9.1",
"react-native-keyboard-spacer": "^0.4.1",
"react-native-linear-gradient": "2.5.6",
"react-native-pdf": "5.1.4",
"react-native-svg": "9.8.4",
"react-navigation": "3.11.0",
"react-redux": "7.1.1",
"redux": "4.0.4",
"redux-devtools-extension": "2.13.8",
"redux-thunk": "2.3.0",
"reselect": "^4.0.0",
"rn-fetch-blob": "0.10.16",
"styled-components": "4.3.2"
},
"devDependencies": {
"@babel/core": "7.5.5",
"@babel/plugin-proposal-export-default-from": "7.5.2",
"@babel/plugin-proposal-export-namespace-from": "7.5.2",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/runtime": "7.5.5",
"babel-eslint": "10.0.2",
"babel-plugin-module-resolver": "3.2.0",
"babel-plugin-styled-components": "1.10.6",
"eslint": "^5.16.0",
"eslint-config-react-app": "^4.0.1",
"eslint-import-resolver-babel-module": "5.1.0",
"eslint-plugin-flowtype": "3.13.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "1.6.1",
"eslint-plugin-react-native": "3.7.0",
"jetifier": "^1.6.4",
"metro-react-native-babel-preset": "0.56.0"
},
"xcodeSchemes": {
"Debug": [
"Test - Debug",
"Acc - Debug",
"Prod - Debug"
],
"Release": [
"Test - Release",
"Acc - Release",
"Prod - Release"
],
"projectDirectory": "ios",
"settings": {}
},
"rnpm": {
"assets": [
"./src/app/static/fonts/"
]
}
}

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 问题跟踪器中发布了这个问题/错误。)

enter image description here

编辑:

我在 this Stack Overflow post 中找到了解决方案.按照这些步骤,您可以创建一个 main.jsbundleassets 文件夹并将其添加到您的项目中。

  1. 运行以下命令:react-native bundle --dev false --platform ios --entry-file index.js --bundle-output ios/main.jsbundle --assets-dest ./ios
  2. 通过将 main.jsbundleassets 目录拖到您的项目中,将它们添加到 Xcode。

虽然这感觉像是一个临时解决方案..我现在有两个 main.jsbundle 文件。我可以删除项目文件夹中的那个吗? assets 文件夹包含一些节点模块,我每次添加新模块并手动将 Assets 拖到我的项目根目录时是否都有此命令?

此外,当我通过 CI/CD (Bitrise) 构建它时,根目录中没有创建 main.jsbundle,因为它在 .gitignore 中默认被忽略。所以我的 TestFlight 构建仍然失败。如何处理?

这里究竟发生了什么?

enter image description here

最佳答案

当你在 Release模式下运行时,你必须拥有离线的 main.js 包。如果它不存在,这个问题只会出现。它不是 0.60.5 版本,它甚至在您以前的版本中也会发生。所以要创建离线包,您需要在您提到的解决方案中执行第 1 步。从 0.60 版本开始,执行此步骤时会创建一个名为 assets 的文件夹。我不确定你为什么需要拖动,因为如果你自动执行第 1 步,它必须在 xcode 中建立索引。如果没有发生这种情况,您只需要在需要时拖动和复制项目。

因此,这不是一个临时解决方案,而是您需要遵循的解决方案来创建包含您所做的所有更改的 bundle 。它是 reactnative 中的强制性内容。

注意:请删除 js bundle 和 assets 文件夹,然后使用

重新创建它
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

关于ios - 升级到 React Native 0.60.5 iOS 发布版本后出现 "No bundle URL present"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57800341/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com