Re: Automatic versioning
Re: Automatic versioning
- Subject: Re: Automatic versioning
- From: "B.J. Buchalter" <email@hidden>
- Date: Sun, 04 Feb 2007 12:57:59 -0500
- Thread-topic: Automatic versioning
Hi Jim,
> Hence, like so many before me, I appeal to the world. Anybody have a
> way to do this easily, automatically, and all from within xcode?
This is the way we do it for our KEXT project. We have a Run Script build
phase as the last build phase for the target. Its contents is:
#Update embedded version info
script="buildDataScript";
if [ -x "$script" ]; then
./"$script"
fi
####
The buildDataScript is as follows (sorry about the line breaks):
#!/bin/tcsh
source buildData
set activebuild=`expr $build - 1`
sed "s/1.4.7d1/${maj}.${min}$rel$activebuild/" "$PRODUCT_SETTINGS_PATH" >
"$TARGET_BUILD_DIR/$TARGET_NAME.$WRAPPER_EXTENSION/Contents/Info.plist"
sed "s/1.4.7d1/${maj}.${min}$rel$activebuild/"
"$TARGET_BUILD_DIR/$TARGET_NAME.$WRAPPER_EXTENSION/Contents/Resources/Englis
h.lproj/InfoPlist.strings" > /tmp/sed.strings
cp /tmp/sed.strings
"$TARGET_BUILD_DIR/$TARGET_NAME.$WRAPPER_EXTENSION/Contents/Resources/Englis
h.lproj/InfoPlist.strings"
set SVNRev=`svn info buildData | awk '/Revision:/ {print $2}'`
touch Sources/BuildString.cpp
echo "#define buildVers_buildvers ${PROJECT}_buildvers" >
Headers/BuildData.h
echo "#define buildVers_buildvers ${PROJECT}_buildvers" >
Sources/BuildString.cpp
echo 'char*' buildVers_buildvers='"'${maj}.${min}$rel$build"
[$SVNRev]"'";' >> Sources/BuildString.cpp
set build=`expr $build + 1`
echo "set maj=$maj" > buildData
echo "set min=$min" >> buildData
echo "set rev=$rev" >> buildData
echo "set rel=$rel" >> buildData
echo "set build=$build" >> buildData
#####
and the buildData file is:
set maj=2
set min=2
set rev=00
set rel=d
set build=154
#####
This script will automatically update the build number. Our code is under
SVN, so it also grabs the SVN rev number from the repository and adds it the
version string for us.
All the sed lines are to stuff the version number into the plist and such so
that the getinfo string for the product has the updated build number. Please
note that the sed code assumes that the version number in the plist will not
change -- it changes it for you. So, you will either need to adjust your
plist to be what the script expects, or adjust the script to match what is
currently in your plist. This script also support the marketing version of
the product by manually setting the maj, min, rev, and rel variables in the
buildData file.
This is, perhaps, a bit crufty, but it does work pretty well for us. BTW, if
you add "BuildString" to your sources, it will also define a static variable
that your code can access that has the version string.
The other effect of this code is that there will always be something to
build after each build (the BuildString.cpp file), so if you click build, it
will always rebuild that one file with an updated build number).
Good luck.
Best regards,
B.J. Buchalter
Metric Halo
5 Donovan Drive
Hopewell Junction, NY 12533 USA
tel +1 845 223-6112
fax +1 603 250-2451
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden