如何使用脚本在 Xcode 11 中更改构建设置版本? [英] How to change build setting versioning in Xcode 11 using script?
问题描述
由于 Xcode 11 已将版本更改为 $(MARKETING_VERSION) &构建到 $(CURRENT_PROJECT_VERSION)
构建设置中有新字段
由于
,我如何使用脚本更改此值xcrun agvtool 新版本
xcrun agvtool new-marketing-version
在 Xcode 10 上运行不完美
我试过这个我用了sed -i '' -e 's/MARKETING_VERSION \= [^\;]*\;/MARKETING_VERSION = 3.4.5;/' ${YOUR_PROJECT_NAME}.xcodeproj/project.pbxproj
例如sed -i '' -e 's/MARKETING_VERSION \= [^\;]*\;/MARKETING_VERSION = 3.4.5;/' DemoProject.xcodeproj/project.pbxproj
注意这在scheme设置的pre-action中不起作用
至于 Build 版本我使用了 xcrun agvtool new-version xxx
例如xcrun agvtool 新版本 3.4.5b
您可以在构建阶段编写这些命令
我不使用 xcrun agvtool new-marketing-version 3.4.5b
的原因是它会将实数写入 plist.
我同意 Manuel 在
或者你当然可以通过在源代码中编辑 plist 来实现.
这是我迄今为止管理多目标版本控制的最接近的方法.
Since Xcode 11 had change Version to $(MARKETING_VERSION) & Build to $(CURRENT_PROJECT_VERSION)
there are new field in build setting
How can I change this value with script due to
xcrun agvtool new-version
xcrun agvtool new-marketing-version
not work perfectly as it on Xcode 10
I tried this one https://stackoverflow.com/a/58164679/7332815 but not working
I can only get correct value from
echo $versionNumber
echo $buildNumber
but how can I set new value to it?
okey I find a solution for myself, and thanks to an friend from meetup.
for Version number
I used
sed -i '' -e 's/MARKETING_VERSION \= [^\;]*\;/MARKETING_VERSION = 3.4.5;/' ${YOUR_PROJECT_NAME}.xcodeproj/project.pbxproj
e.g. sed -i '' -e 's/MARKETING_VERSION \= [^\;]*\;/MARKETING_VERSION = 3.4.5;/' DemoProject.xcodeproj/project.pbxproj
note that this can't work in pre-action of scheme setting
As for Build version
I used xcrun agvtool new-version xxx
e.g. xcrun agvtool new-version 3.4.5b
you can write these command in Build Phases
the reason I don't use xcrun agvtool new-marketing-version 3.4.5b
is because it will write solid number into plist.
And I agree with Manuel's answer in Post
With these I can manage multi-targets' versioning
p.s. If you want to do that to, for example, notificationService target, remember to change version and build number manual at first to make Xcode 11 change the corresponding value to an variable like this
or you can make that by edit plist in source code of course.
That's the closest method I achieve to manage multi-target versioning so far.
这篇关于如何使用脚本在 Xcode 11 中更改构建设置版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!