我已经将我的项目设置为使用运行脚本,该脚本会根据我在主分支中的提交量自动设置内部版本号:
整个脚本,如果有帮助的话:
#!/bin/bash
# update_build_number.sh
# Usage: `update_build_number.sh [branch]`
# Run this script after the 'Copy Bundle Resources' build phase
# Ref: http://tgoode.com/2014/06/05/sensible-way-increment-bundle-version-cfbundleversion-xcode/
branch=${1:-'master'}
buildNumber=$(expr $(git rev-list $branch --count) - $(git rev-list HEAD..$branch --count))
echo "Updating build number to $buildNumber using branch '$branch'."
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
if [ -f "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist"
fi
正如标题中提到的,我可以将其构建到设备上,并且构建号已正确设置。或者,我可以通过 Xcode 存档并上传到 AppStore,并且版本再次设置正确。根据这些观察,我假设配置正确。
但是,当我使用 faSTLane 管理部署时,它不会更新内部版本号,因此我收到此错误:
ERROR ITMS-90189: "Redundant Binary Upload. You've already uploaded a build with build number '#' for version number '#'. Make sure you increment the build string before you upload your app to App Store Connect. Learn more in Xcode Help (http://help.apple.com/xcode/mac/current/#/devba7f53ad4)."
tl;博士
"You already gave us that version, send us a new one"
对于 faSTLane,这是我用来部署 beta 版本的精简版本:
default_platform(:ios)
platform :ios do
lane :beta do
build_app(workspace: "MyApp.xcworkspace",
scheme: "MyApp")
upload_to_testflight
end
end
最后,如果我在 Xcode 中硬编码更新的内部版本号,那么 faSTLane 将正确传送文件,因此我假设我的设置是有效的,没有版本问题。
我还尝试了 increment_build_number
,但我找不到让它工作的设置(另外,Xcode 现在应该为我管理这个,所以 faSTLane 不应该担心)。
最佳答案
想通了这个,结果发现很简单。
当 Xcode 构建应用程序时,构建输出将转到:
/Users/theuser/Library/Developer/Xcode/DerivedData/MyAppName/Build/Products/Debug-iphoneos
当 faSTLane 构建它时,该文件将保存在本地目录中 this .
output_directory
The directory in which the ipa file should be stored in
Default value: .
通过更改 build_app
函数的 output_directory
,我可以将 faSTLane 指向 Xcode 使用的同一文件夹,从而允许脚本运行。
build_app(workspace: "MyApp.xcworkspace",
scheme: "MyApp",
output_directory: "/Users/theuser/Library/Developer/Xcode/DerivedData/MyApp/Build/Products/Debug-iphoneos")
但是,这里有一个不明显的问题。 DerivedData 中的文件夹可以更改,这会给将来的构建带来问题。然而,使用这个answer here ,您可以改为在 Xcode 中指定输出文件夹,然后将其与 faSTLane 同步。
关于ios - 内部版本号不是由 faSTLane 设置的,而是由 Xcode 设置的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56529448/