适用于Xcode项目的Apple通用版本控制工具。man agvtool, April 11, 2012
命令概要:
agvtool what-version | vers [-terse]
agvtool [-noscm | -usecvs | -usesvn] next-version | bump [-all]
agvtool [-noscm | -usecvs | -usesvn] new-version [-all] versionNumber
agvtool what-marketing-version | mvers [-terse | -terse1]
agvtool [-noscm | -usecvs | -usesvn] new-marketing-version | vers version
agvtool
提供了使用Apple Generic Versioning
系统的Xcode项目的常规行为。
您可以通过在项目中设置一些构建设置来启用版本控制,
VERSIONING_SYSTEM | 启用Apple-generic versioning,必须设置为 apple-generic
|
CURRENT_PROJECT_VERSION | This setting defines the current version of the project. The value must be a integer or floating point number like 57 or 365.8. |
DYLIB_CURRENT_VERSION | This setting defines the current version of any framework built by the project. Like CURRENT_PROJECT_VERSION the value must be an integer or floating point number like 57 or 365.8. By default it is set to ``$(CURRENT_PROJECT_VERSION)''. |
VERSION_INFO_PREFIX | Used as a prefix for the name of the version info symbol in the generated versioning source file. If you prefix your exported symbols you will probably want to set this to the same prefix. |
VERSION_INFO_SUFFIX | Used as a suffix for the name of the version info symbol in the generated versioning source file. This is rarely used. |
VERSION_INFO_BUILDER | This defines a reference to the user performing a build to be included in the generated stub, and defaults to the value of the USER environment vari-able. |
VERSION_INFO_EXPORT_DECL | This defines a prefix string for the version info symbol declaration in the generated stub. This can be used, for example, to add an optional `export' keyword to the version symbol declaration. This should rarely be changed. |
VERSION_INFO_FILE | Used to specify a name for the source file that will be generated and compiled into your product. By default this is set to ``$(PRODUCT_NAME)_vers.c''. |
要启用Apple通用版本控制,必须为需要版本控制的每个项目至少设置VERSIONING_SYSTEM
和CURRENT_PROJECT_VERSION
项目构建设置。 版本化项目的target将生成两个全局变量并将其链接到您的产品中。 一个是double类型的,只是CURRENT_PROJECT_VERSION
。 另一个是版本字符串,其格式设置为与what(1)兼容。 这些变量可在您的代码中使用。
具有多个target
的project
要求每个目标具有相同的CURRENT_PROJECT_VERSION
。 实现此目的最简单的方法是在project
的 Build Setting
设置CURRENT_PROJECT_VERSION
。
* what-version | vers [-terse]
返回当前项目的build版本号
-terse 仅输出build版本号
* next-version | bump [-all]
增加所有的target的build到下一个最高的整数值,例如54->55,234.6->235
* new-version [-all version]
设置所有target 的 build version number 为给定的值
* what-marketing-version | mvers [-terse | -terse1]
列出所有target的marketing version,即正常的版本号
-terse1 仅输出版本号
* new-marketing-version version
设置marketing version,即正常的版本号, 到给定的版本号
Note: 从Xcode11开始,marketing version
写在了project.pbxproj
中,而在info.plist中改为了$(MARKETING_VERSION)
, 导致what-marketing-version
拿到的职位$(MARKETING_VERSION)
。在Stackoverflow上,提供了一个临时的解决方法。