You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过CLI配置Xcode项目以支持Apple Generic Versioning?

用CLI配置Cordova iOS项目的Apple Generic版本控制

当然可以通过命令行完成这个配置!完全不用手动打开Xcode点点点,下面这些命令就能帮你把Versioning System设为Apple Generic,同时将Current Project Version设置为1,刚好适配你的fastlane自动化构建流程:

步骤1:切换到Cordova生成的iOS项目目录

首先进入到你的Ionic/Cordova项目的iOS平台目录,一般路径是:

cd platforms/ios

步骤2:设置Versioning System为Apple Generic

用xcodebuild命令直接修改项目配置,记得替换YourProject.xcodeproj和YourTarget为你实际的项目和Target名称(Cordova生成的项目里,Target名通常和项目名一致):

xcodebuild -project YourProject.xcodeproj -target YourTarget -setVersioningSystem "Apple Generic"

步骤3:设置Current Project Version为1

这里有两种方式可选:

方式一:使用Xcode自带的agvtool工具

agvtool是专门用于版本控制的命令行工具,-all参数会将所有Target的版本统一设为1:

agvtool new-version -all 1

方式二:继续用xcodebuild命令

如果更习惯用xcodebuild,也可以直接设置当前版本:

xcodebuild -project YourProject.xcodeproj -target YourTarget -setCurrentVersion 1

集成到fastlane中

如果要把这些操作整合到fastlane的构建流程里,直接在你的lane中加入sh执行这些命令即可,示例如下:

lane :build_ionic_ios do
  # 先切换到iOS项目目录
  Dir.chdir("platforms/ios") do
    sh "xcodebuild -project YourProject.xcodeproj -target YourTarget -setVersioningSystem 'Apple Generic'"
    sh "agvtool new-version -all 1"
  end
  # 后续执行构建、打包等步骤
  gym(
    scheme: "YourTarget",
    export_method: "app-store"
    # 其他gym参数...
  )
end

小提醒:执行这些命令前,确保你已经安装了Xcode Command Line Tools(一般安装Xcode后会自动配置好),如果遇到权限问题,可能需要加上sudo(不过一般不需要,只要你是项目目录的拥有者)。

内容的提问来源于stack exchange,提问作者Bram Vandewalle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:29:40