ios - xcodebuild 从 Info.plist 中去除 CFBundleVersion 和 CFBundleShortVersionString
问题描述
我正在 Azure DevOps 中构建一个 iOS 应用程序。*.ipa 的构建和导出工作正常,但上传到 App Store 失败并显示以下消息:
2020-10-05T14:02:27.9260830Z [14:02:27]: [Transporter Error Output]: ERROR ITMS-90057: "The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring"
2020-10-05T14:02:27.9268950Z [14:02:27]: [Transporter Error Output]: ERROR ITMS-90056: "This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"
2020-10-05T14:02:28.1474570Z [14:02:28]: Transporter transfer failed.
2020-10-05T14:02:28.1475590Z [14:02:28]:
2020-10-05T14:02:28.1477810Z [14:02:28]: ERROR ITMS-90057: "The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring"
2020-10-05T14:02:28.1480380Z ERROR ITMS-90056: "This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"
2020-10-05T14:02:28.2737090Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] <main> DBG-X: parameter ShouldUseRESTAPIs = false
2020-10-05T14:02:28.2741670Z
2020-10-05T14:02:28.2743710Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] <main> ERROR: ERROR ITMS-90057: "The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring"
2020-10-05T14:02:28.2745220Z
2020-10-05T14:02:28.2746740Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] <main> ERROR: ERROR ITMS-90056: "This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"
2020-10-05T14:02:28.2747600Z
2020-10-05T14:02:28.2748330Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] <main> DBG-X: The error code is: 1102
2020-10-05T14:02:28.2748700Z
2020-10-05T14:02:28.2749420Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] <main> INFO: Done performing authentication.
2020-10-05T14:02:28.2749760Z
2020-10-05T14:02:28.2749950Z [14:02:28]: [iTMSTransporter]
2020-10-05T14:02:28.2750120Z
2020-10-05T14:02:28.2750310Z [14:02:28]: [iTMSTransporter]
2020-10-05T14:02:28.2750480Z
2020-10-05T14:02:28.2750660Z [14:02:28]: [iTMSTransporter]
2020-10-05T14:02:28.2750830Z
2020-10-05T14:02:28.2751070Z [14:02:28]: [iTMSTransporter] Package Summary:
2020-10-05T14:02:28.2751270Z
2020-10-05T14:02:28.2751460Z [14:02:28]: [iTMSTransporter]
2020-10-05T14:02:28.2751630Z
2020-10-05T14:02:28.2751950Z [14:02:28]: [iTMSTransporter] 1 package(s) were not uploaded because they had problems:
2020-10-05T14:02:28.2752240Z
2020-10-05T14:02:28.2753070Z [14:02:28]: [iTMSTransporter] /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/d20201005-1299-rww8bj/1454404673.itmsp - Error Messages:
2020-10-05T14:02:28.2753450Z
2020-10-05T14:02:28.2754860Z [14:02:28]: [iTMSTransporter] ERROR ITMS-90057: "The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring"
2020-10-05T14:02:28.2755720Z
2020-10-05T14:02:28.2757000Z [14:02:28]: [iTMSTransporter] ERROR ITMS-90056: "This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"
2020-10-05T14:02:28.2757770Z
2020-10-05T14:02:28.2758440Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:28 UTC] <main> DBG-X: Returning 1
果然,当我提取 ipa 文件并查看“Payload/MyApp.app/Info.plist”时,CFBundleVersion
却CFBundleShortVersionString
不见了。
但是,这些值包含在原始的预编译 Info.plist 中,并且也在构建阶段使用 GitVersion 和 PlistBuddy 设置。我检查了变量是否正确设置,并且还尝试仅使用硬编码版本,这并没有改变结果。
> echo 'iOsBundleVersion: $(iOsBundleVersion)'
iOsBundleVersion: 1.2.21
> echo 'iOsMarketingVersion: $(iOsMarketingVersion)'
iOsMarketingVersion: 1.2
azure-pipelines.yml(摘录):
- task: InstallAppleCertificate@2
displayName: 'Install certificates'
inputs:
certSecureFile: $(certSecureFile)
certPwd: '$(certPwd)'
keychain: 'temp'
- task: InstallAppleProvisioningProfile@1
displayName: 'Install provisioning profile'
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: $(provProfileSecureFile)
- task: CocoaPods@0
displayName: 'Install CocoaPods'
inputs:
workingDirectory: '$(appRoot)'
forceRepoUpdate: true
projectDirectory: 'ios'
- task: Bash@3
displayName: 'Set bundle version'
inputs:
targetType: 'inline'
script: |
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $(iOsBundleVersion)" ./Info.plist
/usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $(iOsMarketingVersion)" ./Info.plist
workingDirectory: '$(appRoot)'
- task: Xcode@5
displayName: 'Build project'
inputs:
actions: 'archive'
configuration: 'Release'
sdk: 'iphoneos'
xcWorkspacePath: '$(appRoot)/MyApp.xcworkspace'
scheme: '$(appName)'
packageApp: true
exportPath: '$(appRoot)/ios/build'
xcodeVersion: 'default'
signingOption: 'manual'
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
args: '-UseModernBuildSystem=0'
workingDirectory: '$(appRoot)'
useXcpretty: true
这导致以下命令:
xcodebuild -workspace /Users/runner/work/1/s/MyApp.xcworkspace -scheme MyApp archive -sdk iphoneos -configuration Release -archivePath /Users/runner/work/1/s/MyApp CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=Apple Distribution: xxxxxxxx (xxxxxxxxx) PROVISIONING_PROFILE=xxxxxxxx PROVISIONING_PROFILE_SPECIFIER= -UseModernBuildSystem=0 | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty --no-color
和
xcodebuild -exportArchive -archivePath /Users/runner/work/1/s/MyApp.xcarchive -exportPath /Users/runner/work/1/s/ios/build -exportOptionsPlist _XcodeTaskExportOptions.plist | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty --no-color
Info.plist(摘录):
<?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>$(PRODUCT_NAME)</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.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.20</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
解决方案
您可能需要检查项目中使用的所有 Info.plist。某些 info.plist 可能缺少键并导致上述错误。
您可以检查以下脚本以搜索丢失的 info.plistCFBundleShortVersionString
和CFBundleVersion
. 有关信息,请参阅此线程。
find . -name 'Info.plist' -not -path "*.storyboard*" | while read file; do
echo $file;
{ plutil -p $file | grep CFBundleShortVersionString; } || echo Failed $file;
done;
您还可以查看此线程以查看您的项目 Target 中是否添加了构建版本。如果没有,您可以尝试通过 XCode 设置构建和版本号。
推荐阅读
- python-3.x - tkfiledialog 在新计算机上提供了一个荒谬的小窗口
- sql - 如何制作一个范围内特定日期时间数据的临时表?
- acumatica - 如何让 SelectFirstNode 在 Acumatica PXTreeView 中始终如一地工作?
- android - 在 Google Play 管理中心,我可以更新内部版本吗?还是我必须完全创建一个新的?
- javascript - 如何修复 JSXgraph 的不等式故障?
- r - 从字符串创建列表/向量
- python - 如何检查 VS 代码中的变量命名拼写错误
- json - 使用 Swift Decodable 进行动态(但称为另一个键值)JSON 解码
- c# - 通过自定义方案在 CefSharp 中使用 WebAssembly(wasm)
- r - cox 回归的列线图