Here’s the info from my StackOverflow answer.

https://stackoverflow.com/a/55525399/1058199

Over the years, Apple has come up with several manners of changing version and 
build numbers. Many of them are now outdated and poor practice. Changing 
CURRENT_PROJECT_VERSION modifies values within your project's project.pbxproj 
file and if you are running a distributed team, this will cause merge conflicts 
if the other half of the team tries to update and while they were asleep, you 
updated this internal value. If you are using pods, you'll get several more 
merge conflicts per pod that you add to the project. 

So, CURRENT_PROJECT_VERSION?

Don't use it.

Within the info.plist file are these keys. 

CFBundleVersion
CFBundleShortVersionString
Use CFBundleVersion for your app's build number. Use CFBundleShortVersionString 
for your app's version number. 

Use Plistbuddy to do it. 

    <key>CFBundleShortVersionString</key>
    <string>3.0.7</string>
    <key>CFBundleVersion</key>
    <string>934</string>
</dict>
</plist>
Try the script below.

#!/bin/sh

# To make executable, use: chmod u+x 
Build-Versioning-Scripts/Increment_Build_Number.sh
# to locate your target's info.plist use
# ${PRODUCT_SETTINGS_PATH}

echo "----"
echo "Info.plist for target: ${PRODUCT_SETTINGS_PATH}"

buildNum=$(/usr/libexec/Plistbuddy -c "Print CFBundleVersion" 
"${PRODUCT_SETTINGS_PATH}")
echo "Current build #: $buildNum"

if [ -z "$buildNum" ]; then
echo "No build number found in $PRODUCT_SETTINGS_PATH"
exit 2
fi

buildNum=$(expr $buildNum + 1)
echo "Build # incremented to: $buildNum"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNum" 
"$PRODUCT_SETTINGS_PATH"
echo "----"
exit 0
By adding this script to your build or archive process on your build machine, 
this will automatically update the app's build number. If you wish to increment 
your app's versionnumber, change CFBundleShortVersionString (Bundle versions 
string, short) in the info.plist manually. 


> On Aug 19, 2020, at 3:07 PM, Alex Zavatone via Cocoa-dev 
> <cocoa-dev@lists.apple.com> wrote:
> 
> I have build scripts that do that based on the # of the git checkins.
> 
> I’ll send you the projects.
> 
> 
>> On Aug 19, 2020, at 11:07 AM, Gabriel Zachmann via Cocoa-dev 
>> <cocoa-dev@lists.apple.com> wrote:
>> 
>> Question:
>> 
>> Is there a way to use a key/value that was defined earlier in the plist file
>> to define a value for a later key?
>> 
>> Explanation:
>> I have a macOS project with an automatically created "About" window.
>> The plist file has, additionally to all the default stuff, the key 
>> CFBuildNumber (with a value that I increment automatically).
>> 
>> In Xcode, I tried to change "Bundle version" to a value like
>> 
>>  $(CURRENT_PROJECT_VERSION)_$(CFBuildNumber)
>> 
>> However, in the final Info.plist in the app's bundle, this then looks like
>> 
>>   <key>CFBundleVersion</key>
>>   <string>3.1_</string>
>> 
>> Notice the underscore, but the value of CFBuildNumber is gone.
>> "3.1", BTW, is the value I have set under
>> 
>>   Project / Targets / General / Identity / Build
>> 
>> I have tried to change parentheses into curly braces, to no avail.
>> 
>> So, question again: is there a way to use a key/value that was defined 
>> earlier in the plist file
>> to define a value for a later key?
>> I'd like to do that so that the "About" window contains the build number, 
>> too.
>> 
>> Thanks a lot in advance.
>> 
>> 
>> _______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to