Getting an unique build tag for each Xcode build

Long had i pondered on getting a unique stamp in every build xcode makes, so i could more easily distinguish between builds when failures occur. Today i made a nice discovery.

In your project right click on the name of your project under “Targets” and select: Add New Build Phase->Run Script Build Phase

Now create a script that will generate a header file with the build tag information inside.

Here’s the code for copy paste:

#
# create a build tag
#
NEW_DATE=`date -u +%Y%m%d%H%M`; 
NEW_TAG=`echo "ibase=10;obase=16;$NEW_DATE" | bc`
echo Build: $NEW_TAG Date: $NEW_DATE

echo "#define APPBUILD_DATE_STRING $NEW_DATE" > Classes/AppBuild.h
echo "#define APPBUILD_TAG $NEW_TAG" >> Classes/AppBuild.h

Running it should give you something like this:

Advertisements
Tagged with: ,
Posted in Apple, Code
One comment on “Getting an unique build tag for each Xcode build
  1. vaderr12 says:

    Thank you LOOKASSEN. That was exactly what I needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories
%d bloggers like this: