Set version number to build date in Xcode

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
emendelson
Forum All-Star
Posts: 1677
Joined: Tue Oct 14, 2008 12:12 am

Set version number to build date in Xcode

Post by emendelson »

I don't even pretend to know what I'm doing, but this seems to work in BasiliskII and will presumably work (with different strings) in SheepShaver.

To set the version number to the current date, open the BasiliskII project in Xcode. In the left had column of the central pane, under TARGETS, select BasiliskII.

In the central pane, select Build Phases, and expand the item that says Run Script.

You will see a script already present, with one line that begins "cc". Beneath that line, insert the following:

Code: Select all

buildNumber=$(date -u "+%Y-%m-%d")
fullNumber="2.5 "$(date -u "+%Y-%m-%d")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $fullNumber" "${BUILT_PRODUCTS_DIR}/BasiliskII.app/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildNumber" "${BUILT_PRODUCTS_DIR}/BasiliskII.app/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleGetInfoString $buildNumber" "${BUILT_PRODUCTS_DIR}/BasiliskII.app/Contents/Info.plist"
You should now have a script with 6 numbered lines and a blank line 7.

Below the window with the script, remove the check mark (if any) in the two boxes next to Run Script.

It should look something like this:

Image

Now build BasiliskII and look at the version numbers in the Get Info panel. It should look something like this:

Image

I had been doing this by hand in my build, but this is obviously a lot easier.
Post Reply