在构建时更新 dSYM 中的 CFBundleShortVersionString? [英] Update CFBundleShortVersionString in dSYM at build?

查看:35
本文介绍了在构建时更新 dSYM 中的 CFBundleShortVersionString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用它作为构建阶段:

I'm using this as a build phase in my project:

export PLISTBUDDY="/usr/libexec/PlistBuddy"

export INFO="${CODESIGNING_FOLDER_PATH}/Info.plist"
export RXREVISION=`git describe --tags | perl -pi -E "s/[^-]+\-([^-]+).*/\1/"`
export RXVERSION=`git describe --tags | perl -pi -E "s/([^-]+)\-[^-]+.*/\1/"`
$PLISTBUDDY $INFO -c "add CFBundleVersion string $RXREVISION"
$PLISTBUDDY $INFO -c "set :CFBundleVersion $RXREVISION"
$PLISTBUDDY $INFO -c "add CFBundleShortVersionString string $RXVERSION"
$PLISTBUDDY $INFO -c "set :CFBundleShortVersionString $RXVERSION"

这非常适用于更新构建应用程序的 Info.plist 中的构建版本,并且不会改变我的源代码树.

This works perfectly for updating the build revision in the built application's Info.plist, and it doesn't mutate my source tree.

我尝试将更新版本脚本放在链接阶段的末尾和之前.无论哪种方式,它都能影响对构建的应用程序的更改,但 dSYM 是从原始源代码树构建的.

I have tried putting my Update Version script both at the end and also before the link phase. Either way, it's able to affect changes to the built application, but the dSYM is built from the original source tree.

构建的应用程序和构建的 dSYM 之间的版本号不匹配是一个问题.(HockeyApp 在这里抛出错误.)

This mismatch of version numbers between the built app and the built dSYM is a problem. (HockeyApp throws an error here.)

如果我更新源代码树中的 Info.plist,我需要处理它的变化.这给我留下了两个我可以看到的选项:

If I update the Info.plist in my source tree, I need to deal with it changing. Which leaves me two options that I can see:

  1. 将 Info.plist 置于源代码控制之下,并让脚本直接对其进行编辑.但这意味着我需要在每次构建后检查更改.
  2. 忽略Info.plist,让脚本直接编辑它.但是 Info.plist 中还有很多其他东西我确实希望在源代码控制下进行.
  1. Put Info.plist under source control, and have the script edit it directly. But this means I'll need to check in the changes after each build.
  2. Ignore Info.plist, and have the script edit it directly. But there's plenty of other things in Info.plist that I do want under source control.

如何让 dSYM 中的版本也自动更新,而不必处理我的源树中的 Info.plist 更改每个构建?

How can I get the version in the dSYM updating automatically, too, without having to deal with the Info.plist in my source tree changing every build?

另外,切线:我如何在 dSYM 中看到版本?

Also, tangentially: How do I see the version in the dSYM?

推荐答案

dSYM 包在根文件夹中也有一个 info.plist 具有相似的值.你也可以用类似的方式修改它.

The dSYM package also has an info.plist in the root folder with similar values. You could probably modify that too in a similar way.

另一种选择是在额外的 .xcconfig 文件中定义版本号,并将 info.plist 中的版本号包含在其中,请参阅 此处.

Another option is to define the version number in an extra .xcconfig file and include the version number from the info.plist into it, see here.

然后,您还可以通过使用多个独立的 info.plist 文件并在构建设置,不包括源代码控制下的测试构建设置.

You could then also decide which kind of versioning you want or release or test builds, by using multiple independent info.plist files and referencing to different .xcconfig files in the build settings and don't include the one for test builds under source control.

一般来说,我建议对每次版本更改都进行提交,因为这使得代码真正具有可重现性,并且还在源代码控制系统中唯一标识它.

In general I would suggest to do commits for every version change, since this makes the code really reproducible and also uniquely identify it in the source control system.

除此之外,Apple 指定将 CFBundleVersion 设置为单调递增的字符串,由一个或多个句点分隔的整数组成",请参阅 此处.CFBundleShortVersionString 是您的营销版本,例如您的目标是在 3.0 版本上工作.

Apart from that, Apple specifies to set CFBundleVersion to a "monotonically increased string, comprised of one or more period-separated integers", see here. CFBundleShortVersionString is your marketing version, e.g. your goal is to work on version 3.0.

那么如何为发布版本执行以下操作:使用新版本号更新 CFBundleVersion,使用新的营销版本(如 3.0 Beta 1<)更新 CFBundleShortVersion/code> 并提交它们,然后标记该提交以供发布.与任何其他元数据一样,版本号是源的一部分,特别是如果版本号还用于触发特定代码以实现兼容性、数据库升级或其他事情(通常会这样做).

So how about doing the following for a release build: Update CFBundleVersion with the new build number and CFBundleShortVersion with the new marketing version like 3.0 Beta 1 and commit both of them and then tag that commit for release. Version numbers are part of your source like any other meta data, especially if the version number are also used to trigger specific code for compatibility, database upgrades or other things (which is often done).

这篇关于在构建时更新 dSYM 中的 CFBundleShortVersionString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆