update 2022/08/19
if using fastlane to bumping version
desc "Bump version and build nubmer"
lane :bump_version_and_build_number do |options|
version_number = options[:version]
puts version_number
sh("sed -i '' -e 's/MARKETING_VERSION \\= [^\\;]*\\;/MARKETING_VERSION = #{version_number};/' ../${YOUR_PROJECT_NAME}.xcodeproj/project.pbxproj")
increment_build_number
end
and just type in commend line
bundle exec fastlane bump_version_and_build_number version:1.0.1
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.
sed -i '' -e "s/MARKETING_VERSION = .*;/MARKETING_VERSION = $VERSION;/" $PROJECT_PATH/project.pbxproj
. – Lionellionello