<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Diego's Rants &#187; xCode</title>
	<atom:link href="http://blog.massanti.com/tag/xcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.massanti.com</link>
	<description>Confessions from a Geek</description>
	<lastBuildDate>Wed, 27 Oct 2010 11:22:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Automatic build numbering increase with xCode</title>
		<link>http://blog.massanti.com/2009/09/20/automatic-build-numbering-increase-with-xcode/</link>
		<comments>http://blog.massanti.com/2009/09/20/automatic-build-numbering-increase-with-xcode/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 04:01:34 +0000</pubDate>
		<dc:creator>Diego Massanti</dc:creator>
				<category><![CDATA[Apple / Macintosh]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[xCode]]></category>

		<guid isPermaLink="false">http://blog.massanti.com/?p=997</guid>
		<description><![CDATA[I had this problem some days ago where i wanted to automatically increase the build number of my Application in xCode, every time that i actually made a new build. xCode comes with a tool called agvtool which is supposed to fill this gap, but the main problem with this is that it needs the [...]]]></description>
			<content:encoded><![CDATA[<p>I had this problem some days ago where i wanted to automatically increase the build number of my Application in xCode, every time that i actually made a new build. xCode comes with a tool called agvtool which is supposed to fill this gap, but the main problem with this is that it needs the project to be actually closed, for some reason that i certainly ignore.</p>
<p>After some searches, i finished at <a href="http://chanson.livejournal.com/125568.html">this interesting post by Chris Hanson</a>, but this was not exactly what i wanted to do, again, i wanted a simple approach to increase the build number with every build.</p>
<p>So this is what i did.</p>
<p>First I created a new configuration settings file in xCode, as shown below.</p>
<div id="attachment_998" class="wp-caption aligncenter" style="width: 310px"><a rel="lightbox" href="http://blog.massanti.com/wp-content/uploads/2009/09/Screen-shot-2009-09-20-at-12.20.54-AM.png"><img class="size-medium wp-image-998 " title="Creating a new Configuration Settings File in xCode" src="http://blog.massanti.com/wp-content/uploads/2009/09/Screen-shot-2009-09-20-at-12.20.54-AM-300x247.png" alt="Creating a new Configuration Settings File in xCode" width="300" height="247" /></a><p class="wp-caption-text">Creating a new Configuration Settings File in xCode</p></div>
<p>After this, i ended up with an empty configuration file, so i added the following inside it:</p>
<pre>CURRENT_PROJECT_VERSION = 1</pre>
<p>xCode uses this variable to store your application&#8217;s build number, so we are going to tell it to use this file in order to get the value for the CURRENT_PROJECT_VERSION variable.</p>
<p>Go to your target&#8217;s properties, be sure to select All configurations and All Settings, then base your target&#8217;s config in your newly created version.xcconfig file, and set the version variable to our new version variable as shown below:</p>
<div id="attachment_999" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.massanti.com/wp-content/uploads/2009/09/Screen-shot-2009-09-20-at-12.26.49-AM.png" rel="shadowbox[post-997];player=img;"><img class="size-medium wp-image-999" title="Configuring the Target to use the new variable in the version.xcconfig file." src="http://blog.massanti.com/wp-content/uploads/2009/09/Screen-shot-2009-09-20-at-12.26.49-AM-300x272.png" alt="Configuring the Target to use the new variable in the version.xcconfig file." width="300" height="272" /></a><p class="wp-caption-text">Configuring the Target to use the new variable in the version.xcconfig file.</p></div>
<p>After all this is done, all you have to do is create a new &#8220;Run Script&#8221; build phase, and place the following inside it:</p>
<pre class="brush: plain; title: ;">
NEW_VERSION=`cat &quot;$SRCROOT/version.xcconfig&quot; | awk '/CURRENT_PROJECT_VERSION/ { print $3 + 1 }'`
sed -i '' &quot;s/CURRENT_PROJECT_VERSION = .*/CURRENT_PROJECT_VERSION = $NEW_VERSION/&quot; &quot;$SRCROOT/version.xcconfig&quot;
CURRENT_PROJECT_VERSION=$NEW_VERSION
touch &quot;$SRCROOT/version.xcconfig&quot;
</pre>
<p>Obviously, if you changed the file or variable names, you will have to adapt the script as needed.<br />
Now, every time you build the app, the build number is automatically increased by one, and included in your application&#8217;s plist file as shown below:</p>
<div id="attachment_1002" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.massanti.com/wp-content/uploads/2009/09/Screen-shot-2009-09-20-at-12.42.27-AM.png" rel="shadowbox[post-997];player=img;"><img class="size-medium wp-image-1002" title="Build number being shown in the built app." src="http://blog.massanti.com/wp-content/uploads/2009/09/Screen-shot-2009-09-20-at-12.42.27-AM-300x219.png" alt="Build number being shown in the built app." width="300" height="219" /></a><p class="wp-caption-text">Build number being shown in the built app.</p></div>
<p>A whole thanks goes to the guys at #macdev on freenode Diabolik and KonaBlend who helped with the bash scripting!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.massanti.com/2009/09/20/automatic-build-numbering-increase-with-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

