ios - 内部版本号不是由 faSTLane 设置的,而是由 Xcode 设置的

标签 ios xcode fastlane fastlane-gym

我已经将我的项目设置为使用运行脚本,该脚本会根据我在主分支中的提交量自动设置内部版本号:

enter image description here

整个脚本,如果有帮助的话:

#!/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/

相关文章:

ios - 将 SKNode 链接到 GKAgent2D?

iphone - 搜索核心数据

objective-c - 切换到 Xcode 8.2.1 导致 BRCloudDocsErrorDomain

ios - 将 StoryBoard 添加到现有的 UINavigation with Tab bar 项目

ios - 如何清除 FaSTLane gym 输出目录?

ios - 使用 FaSTLane 在 iTunes 连接中创建新的 iOS 应用程序版本

ios - 什么 _ :_: and similar combinations of the colon and underscore mean in Swift?

ios - 自动调整 UICollectionView 高度以调整其内容大小

ios - lproj 文件尚未加载

ios - 使用 FaSTLane 快照读取 UserDefaults 时遇到困难