<?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>Light Year Software &#187; Xcode</title>
	<atom:link href="http://lightyearsoftware.com/tag/xcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://lightyearsoftware.com</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 22:19:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Unit Testing Cocoa with MacRuby</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2011%2F09%2Funit-testing-cocoa-with-macruby%2F&#038;seed_title=Unit+Testing+Cocoa+with+MacRuby</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2011%2F09%2Funit-testing-cocoa-with-macruby%2F&#038;seed_title=Unit+Testing+Cocoa+with+MacRuby#comments</comments>
		<pubDate>Thu, 29 Sep 2011 15:43:05 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/?p=727</guid>
		<description><![CDATA[I spend most of my development time split between Rails and iOS. Each offers a rich API that makes building projects much more productive and enjoyable. There is one place, however, that Ruby clobbers Objective-C: testing. It&#8217;s not that Objective-C doesn&#8217;t have test frameworks. There are several: OCUnit (bundled with Xcode), GHUnit, Cedar and Kiwi. [...]]]></description>
			<content:encoded><![CDATA[<p>I spend most of my development time split between Rails and iOS. Each offers a rich API that makes building projects much more productive and enjoyable. There is one place, however, that Ruby clobbers Objective-C: testing.<span id="more-727"></span></p>
<p>It&#8217;s not that Objective-C doesn&#8217;t have test frameworks. There are several: <a href="http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/ios_development_workflow/135-Unit_Testing_Applications/unit_testing_applications.html">OCUnit</a> (bundled with Xcode), <a href="https://github.com/gabriel/gh-unit">GHUnit</a>, <a href="https://github.com/pivotal/cedar">Cedar</a> and <a href="http://www.kiwi-lib.info/">Kiwi</a>. Cedar and Kiwi use blocks to get close to an RSpec-like syntax, but there&#8217;s only so far it can go. Objective-C can&#8217;t match Ruby when creating a DSL, even with preprocessor abuse.</p>
<p>Fortunately, there is a way to write tests in Ruby and run them against Objective-C code: <a href="http://www.macruby.org/">MacRuby</a>. MacRuby is an implementation of Ruby 1.9 that compiles Ruby to LLVM bytecode and has full access to Objective-C frameworks. You can write full Mac desktop applications with it, but for this post I&#8217;ll simply use it to write test specs with RSpec for testing Objective-C classes.</p>
<p>In this post, I&#8217;ll walk you through how to install MacRuby, RSpec and how to set up your Cocoa (Mac or iOS) project to unit test with RSpec. These tests are analogous to model specs in Rails. We&#8217;ll be testing classes in isolation, not trying to recreate the Cocoa environment in order to test window or view controllers, etc.</p>
<p>A big caveat for iOS developers: MacRuby loads Objective-C code from a framework, but iOS targets don&#8217;t support building frameworks. What this means is that you don&#8217;t have access to the <tt>UI*</tt> classes in the code under test. This limits what you can test. Pure model classes (those without any external dependencies) will be fine. Theoretically, it should be possible to find the simulator frameworks and link against those, but I&#8217;ve been unsuccessful thus far. <a href="http://chameleonproject.org/">Chameleon</a> might help if you want to dig into this further.</p>
<p>With that out of the way, let&#8217;s get started. If you haven&#8217;t already, download and install MacRuby. This places the <tt>macruby</tt> binary and other Ruby tools you&#8217;re familiar with (<tt>irb</tt>, <tt>gem</tt>, <tt>rake</tt>) in <tt>/usr/local/bin</tt>, with <tt>mac</tt> prefixes.</p>
<p>Then, install RSpec 2.5 (at present, there are <a href="https://github.com/rspec/rspec-core/issues/461">problems running specs with 2.6</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ sudo macgem install --bindir /usr/local/bin --format-executable rspec -v '~&gt;2.5.0'</pre></div></div>

<p><tt>--bindir</tt> ensures the <tt>rspec</tt> script doesn&#8217;t overwrite one that might already exist in <tt>/usr/bin</tt>, and <tt>--format-executable</tt> adds the <tt>mac</tt> prefix to it, so it matches the other MacRuby-provided scripts.</p>
<p>In Xcode, open your project and create a new target (File -> New Target). Use the Cocoa Framework template, found under Mac OS X, Framework &amp; Library. Call it whatever you like. I used &#8220;Specs&#8221;. Do not use Automatic Reference Counting. MacRuby, like MRI Ruby, is garbage collected and will use the Objective-C garbage collector. If your project uses ARC, that&#8217;s OK. <tt>retain</tt>, <tt>release</tt> and <tt>autorelease</tt> are no-ops under GC, and nothing changes if the calls to them are missing in the first place. Include Unit Tests should also be unchecked.</p>
<p>You must adjust some build settings for the new target. Under Apple LLVM Compiler &#8211; Language, find the settings for Objective-C Automatic Reference Counting and ensure it is set to NO. Just below that, set Objective-C Garbage Collection to Supported.</p>
<p><img class="size-full wp-image-729 aligncenter" title="compiler settings for ARC and GC" src="http://lightyearsoftware.com/wp-content/uploads/2011/09/Screen-Shot-2011-09-23-at-11.47.39-AM.png" alt="" width="438" height="53" /></p>
<p>Go to the target build phases, and add the <tt>.m</tt> files you wish to test to the compile sources phase. As you add files to your project later, be sure to check the boxes for both your main target and the Specs target if you want to test the new code.</p>
<p>Finally, you need to configure the schemes for the new target. In the build scheme, check the run box. In the run scheme, choose <tt>/usr/local/bin/macruby</tt> as the executable to test.</p>
<p><img class="size-full wp-image-730 aligncenter" title="run scheme info configuration" src="http://lightyearsoftware.com/wp-content/uploads/2011/09/Screen-Shot-2011-09-23-at-11.53.56-AM.png" alt="" width="424" height="209" /></p>
<p>Set up the arguments to pass to the executable when it runs as follows:</p>
<p><img class="size-full wp-image-731 aligncenter" title="run scheme arguments configuration" src="http://lightyearsoftware.com/wp-content/uploads/2011/09/Screen-Shot-2011-09-23-at-11.54.10-AM.png" alt="" width="526" height="312" /></p>
<p>Choose your framework as the base for expansions. You&#8217;ll pass two arguments to the program: the path to the RSpec wrapper and the directory containing the specs.</p>
<p>You might wonder why we&#8217;re using MacRuby as the executable to test instead of RSpec directly. If you try to use RSpec, Xcode won&#8217;t recognize it as a 64-bit executable and will refuse to run it under the debugger. It will work, but you must also choose &#8220;debugger: none&#8221; and give up your breakpoints, etc.</p>
<p>With this new target you get a new top-level group in your project. Xcode has also created Specs.h and Specs.m, which we don&#8217;t need. You should delete them.</p>
<p>Create a new file in this group called <tt>spec_helper.rb</tt> and paste this in:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">framework <span style="color:#996600;">'Specs'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Requires supporting ruby files with custom matchers and macros, etc,</span>
<span style="color:#008000; font-style:italic;"># in spec/support/ and its subdirectories.</span>
<span style="color:#CC00FF; font-weight:bold;">Dir</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{ENV['SRCROOT']}/Specs/support/**/*.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">require</span> f<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
RSpec.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>config<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#008000; font-style:italic;"># == Mock Framework</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># config.mock_with :mocha</span>
  <span style="color:#008000; font-style:italic;"># config.mock_with :flexmock</span>
  <span style="color:#008000; font-style:italic;"># config.mock_with :rr</span>
  config.<span style="color:#9900CC;">mock_with</span> <span style="color:#ff3333; font-weight:bold;">:spec</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>At this point, you should be able to choose your new target from the scheme picker in the toolbar and run. We haven&#8217;t created any specs yet, so you should see this:</p>
<pre>
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug  8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys004
[Switching to process 1636 thread 0x0]
No examples were matched. Perhaps {:if=>#&lt;Proc:0x4007553a0 (lambda)>, :unless=>#&lt;Proc:0x400795b60 (lambda)>} is excluding everything?

Finished in 0.0331 seconds
0 examples, 0 failures
Program ended with exit code: 0
</pre>
<p>You may not see any output. You can use ⌘7 and look at the most recent log or use this <a href="http://twitter.com/pilky/status/109737034633060352">tip from Martin Pilkington</a> to create a new window for output. I find this much less intrusive than allowing Xcode to constantly pop up the debugging panes in my editor windows.</p>
<p>Let&#8217;s create a simple spec file. Assuming you added a <tt>.m</tt> file that implements a class called <tt>Foo</tt>, create a new file in your Specs group called <tt>foo_spec.rb</tt>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;#{ENV['SRCROOT']}/Specs/spec_helper&quot;</span>
&nbsp;
describe Foo <span style="color:#9966CC; font-weight:bold;">do</span>
  it <span style="color:#006600; font-weight:bold;">&#123;</span> should be_an_instance_of<span style="color:#006600; font-weight:bold;">&#40;</span>Foo<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Run again and you should see this:</p>
<pre>
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug  8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys004
[Switching to process 1796 thread 0x0]
.

Finished in 0.40422 seconds
1 example, 0 failures
Program ended with exit code: 0
</pre>
<p>It works! Now try adding breakpoints, mocking and stubbing objects, etc. You have all the features of RSpec available to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2011%2F09%2Funit-testing-cocoa-with-macruby%2F&#038;seed_title=Unit+Testing+Cocoa+with+MacRuby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Your Own Private WWDC 2011</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2011%2F07%2Fyour-own-private-wwdc-2011%2F&#038;seed_title=Your+Own+Private+WWDC+2011</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2011%2F07%2Fyour-own-private-wwdc-2011%2F&#038;seed_title=Your+Own+Private+WWDC+2011#comments</comments>
		<pubDate>Fri, 01 Jul 2011 15:24:57 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/?p=702</guid>
		<description><![CDATA[Now that Apple has released the complete set of WWDC 2011 videos to registered developers, those of us who couldn&#8217;t make it to the conference have the opportunity to hear about all the new, shiny stuff coming in Mac OS X 10.7 and iOS 5. With 109 sessions to choose from, newcomers may not know [...]]]></description>
			<content:encoded><![CDATA[<p>Now that Apple has released the complete set of <a href="http://developer.apple.com/videos/wwdc/2011/">WWDC 2011 videos</a> to registered developers, those of us who couldn&#8217;t make it to the conference have the opportunity to hear about all the new, shiny stuff coming in Mac OS X 10.7 and iOS 5.<span id="more-702"></span></p>
<p>With 109 sessions to choose from, newcomers may not know where to start. This guide is intended to help you get started.</p>
<p><a href="http://www.apple.com/apple-events/wwdc-2011/"><strong>The Keynote</strong></a>: the only WWDC session not under NDA, this is where all the public news was announced. If for some reason you haven&#8217;t watched it yet, it&#8217;s worth watching, although it is a bit long and by now you&#8217;ve probably heard about everything.</p>
<p>Since everything else is under NDA, I can&#8217;t discuss specifics about the content of sessions.</p>
<p>Start with the <strong>Apple Platforms Kickoff</strong>. Where the keynote is truly for the press, this session is for developers.</p>
<p>Whether your focus is on Mac OS X or iOS, you&#8217;ll be using Xcode, so move on to <strong>Session 300: Developer Tools Kickoff</strong>. You&#8217;ll learn about the new tools and features coming in future versions of Xcode.</p>
<p>The final kickoff session is <strong>Session 400: Graphics, Media, and Games Kickoff</strong>. I found this session to be less focused on new stuff and more a general overview of the available frameworks and tools, though the demo at the end is impressive. There is a bit about Game Center and AV Foundation if you&#8217;re interested in these frameworks.</p>
<p>Trivia: in previous years, these sessions used the &#8220;State of the Union&#8221; moniker.</p>
<p>Where to next? That depends on what you want to do. Many sessions include pointers to others covering specific topics, so be sure to watch for those to find more information about areas that interest you.</p>
<h2>If you&#8217;re a Mac OS X developer&#8230;</h2>
<p>If you have an app in the Mac App Store or plan to ship one in the future, start with <strong>Session 203: Introducing App Sandbox</strong> and <strong>Session 204: App Sandbox and the Mac App Store</strong>. There are new submission requirements coming with 10.7 that are more important than anything else.</p>
<p>Follow that up with <strong>Session 101: What&#8217;s New in Cocoa</strong>. This is the high-level session to learn about the new stuff for developers in 10.7. Don&#8217;t miss <strong>Session 323: Introducing Automatic Reference Counting</strong> so you can (mostly) stop thinking about manual memory management.</p>
<p><strong>Session 127: Design Patterns to Simplify Mac Accessibility</strong> is James Dempsey&#8217;s annual talk that includes a song. Even if you don&#8217;t think you care about accessibility (hint: you should), his talk is great and the song is a funny distillation of the topic.</p>
<h2>If you&#8217;re an iOS developer&#8230;</h2>
<p>Start with <strong>Session 100: What&#8217;s New in Cocoa Touch</strong>, then <strong>Session 323: Introducing Automatic Reference Counting</strong>, followed by <strong>Session 309: Introducing Interface Builder Storyboarding</strong> and <strong>Session 102: Implementing UIViewController Containment</strong>. Follow the suggestions for related sessions depending on your interests and needs.</p>
<h2>App Design</h2>
<p>Excellent design will set your app apart from the crowd. There are two sessions covering UI and UX topics: <strong>Session 110: Designing User Interfaces for iOS and Mac OS X Apps</strong> and <strong>Session 105: Polishing Your App</strong>, the latter of which includes non-visual polish such as responsiveness and performance, a user experience issue.</p>
<h2>Security and Performance</h2>
<p>You should care about the security of your app and how well it performs. <strong>Session 202: Security Overview</strong> discusses attack vectors and options for addressing them. <strong>Session 310: What&#8217;s New in Instruments</strong> will point you in the right direction for performance analysis and tuning, while <strong>Session 312: iOS Performance and Power Optimization with Instruments</strong> and <strong>Session 318: iOS Performance in Depth</strong> teaches practical techniques for diagnosing and fixing problems for iOS apps.</p>
<p>Releasing these videos for free is a great service to the Apple developer community. There is value in almost every session, and the huge advantage we have in watching them now is we can check out topics we might not have made time for if attending the conference in person. Skip ahead or stop a video if it isn&#8217;t holding your attention.</p>
<p>My recommendations here are a starting point. Apple&#8217;s platforms are growing and getting better every year. Explore new things; you never know when you might learn something relevant to an existing project. Watch a session about a topic you think you know well. With such a rich set of frameworks, there are often little tricks to learn that mean you can rewrite some old code to be clearer or perform better.</p>
<p>Is there a particularly good session I haven&#8217;t mentioned? Mention it in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2011%2F07%2Fyour-own-private-wwdc-2011%2F&#038;seed_title=Your+Own+Private+WWDC+2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic Git Revision Stamping for App Store Projects</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F11%2Fautomatic-git-revision-stamping-for-app-store-projects%2F&#038;seed_title=Automatic+Git+Revision+Stamping+for+App+Store+Projects</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F11%2Fautomatic-git-revision-stamping-for-app-store-projects%2F&#038;seed_title=Automatic+Git+Revision+Stamping+for+App+Store+Projects#comments</comments>
		<pubDate>Tue, 02 Nov 2010 15:57:42 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=310</guid>
		<description><![CDATA[Following up on my post about automatic Subversion revision stamping, here is a modified script for use with Git-based projects. I&#8217;ve been moving toward Git for more of my work, for mostly two reasons. The first is that Subversion uses &#8220;@&#8221; to denote a specific revision of a file, which makes adding images for the [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on my post about <a href="http://lightyearsoftware.com/blog/2010/05/automatic-subversion-revision-stamping-for-iphone-projects/">automatic Subversion revision stamping</a>, here is a modified script for use with Git-based projects.<span id="more-310"></span></p>
<p>I&#8217;ve been moving toward Git for more of my work, for mostly two reasons. The first is that Subversion uses &#8220;@&#8221; to denote a specific revision of a file, which makes adding images for the Retina Display annoying because they use &#8220;@2x&#8221; in the file name. The second is that integrating third-party source into a project is more work than it should be because Subversion litters the tree with <tt>.svn</tt> directories. I can&#8217;t simply delete the old third-party source and drop in the new files, because Subversion loses its state. Yes, I could <tt>svn rm</tt>, then <tt>svn add</tt>, but that grows the repository unnecessarily and I lose the ability to diff the source and see what actually changed.</p>
<p>Git does not use a numeric repository version, however, and a simple SHA1 hash is unsuitable for use as the third component of a bundle version because it can include the letters a-f. I took the simplest way out and use a file (<tt>build-counter</tt>) with a number in it, incremented for every Ad Hoc and App Store build, but not for Debug or Release. This file is created if it does not exist and automatically committed.</p>
<p>As with my Subversion script, if any local modifications are detected during an Ad Hoc or App Store build, it will fail.</p>
<p>Since it&#8217;s likely that Apple will enforce the same format restrictions on Mac App Store apps, this script can also be used in those projects.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Xcode auto-versioning script for Git by Steve Madsen.</span>
<span style="color:#008000; font-style:italic;"># Adapted from Subversion script by Axel Andersson.</span>
&nbsp;
build_counter_file = <span style="color:#996600;">'build-counter'</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;#{$0}: Must be run from Xcode&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'BUILT_PRODUCTS_DIR'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> development?
  ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'BUILD_STYLE'</span><span style="color:#006600; font-weight:bold;">&#93;</span> !~ <span style="color:#006600; font-weight:bold;">/</span>Ad Hoc<span style="color:#006600; font-weight:bold;">|</span>App Store<span style="color:#006600; font-weight:bold;">/</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> local_modifications?
  <span style="color:#996600;">`git ls-files -m`</span> != <span style="color:#996600;">&quot;&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
build_counter = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span>build_counter_file<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#006666;">0</span>
<span style="color:#9966CC; font-weight:bold;">unless</span> development?
  <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;#{$0}: local modifications present for a production build!&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> local_modifications?
&nbsp;
  build_counter <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
  <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>build_counter_file, <span style="color:#996600;">'w'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f.<span style="color:#CC0066; font-weight:bold;">printf</span> <span style="color:#996600;">&quot;%d&quot;</span>, build_counter <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;git commit -m 'increment build counter' #{build_counter_file}&quot;</span>
    <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;#{$0}: Git commit of #{build_counter_file} failed: #{$?.exitstatus}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
info = <span style="color:#996600;">&quot;#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['WRAPPER_NAME']}/Info.plist&quot;</span>
info_xml = <span style="color:#996600;">`plutil -convert xml1 '#{info}' -o -`</span>
<span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;#{$0}: reading Info.plist failed: #{$?.exitstatus}&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> $?.<span style="color:#9900CC;">success</span>?
&nbsp;
info_xml.<span style="color:#CC0066; font-weight:bold;">gsub!</span> <span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\t <span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span>CFBundleVersion\n<span style="color:#006600; font-weight:bold;">&#91;</span>\t <span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span>\d<span style="color:#006600; font-weight:bold;">+</span>\.\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">*</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#996600;">&quot;<span style="color:#000099;">\\</span>1.#{build_counter}<span style="color:#000099;">\\</span>2&quot;</span>
&nbsp;
<span style="color:#CC00FF; font-weight:bold;">IO</span>.<span style="color:#9900CC;">popen</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;plutil -convert binary1 - -o '#{info}'&quot;</span>, <span style="color:#996600;">'w'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>plutil<span style="color:#006600; font-weight:bold;">|</span> plutil <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; info_xml <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;#{$0}: writing Info.plist failed: #{$?.exitstatus}&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> $?.<span style="color:#9900CC;">success</span>?</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F11%2Fautomatic-git-revision-stamping-for-app-store-projects%2F&#038;seed_title=Automatic+Git+Revision+Stamping+for+App+Store+Projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic Subversion Revision Stamping for iPhone Projects</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F05%2Fautomatic-subversion-revision-stamping-for-iphone-projects%2F&#038;seed_title=Automatic+Subversion+Revision+Stamping+for+iPhone+Projects</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F05%2Fautomatic-subversion-revision-stamping-for-iphone-projects%2F&#038;seed_title=Automatic+Subversion+Revision+Stamping+for+iPhone+Projects#comments</comments>
		<pubDate>Wed, 26 May 2010 14:56:59 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=260</guid>
		<description><![CDATA[Early during development of a new iPhone OS application, I discovered that App Store submissions must use a strict format for the CFBundleVersion key in the Info.plist file. It can only be numbers and dots. This left me a little frustrated with how to version pre-1.0 releases to testers. I didn&#8217;t want to use an [...]]]></description>
			<content:encoded><![CDATA[<p>Early during development of a new iPhone OS application, I discovered that App Store submissions must use a strict format for the <tt>CFBundleVersion</tt> key in the <tt>Info.plist</tt> file. It can only be numbers and dots. This left me a little frustrated with how to version pre-1.0 releases to testers. I didn&#8217;t want to use an open-source style &#8220;0.9&#8243; and yet it wasn&#8217;t 1.0. What I really wanted was &#8220;1.0 b1&#8243; or similar.</p>
<p>I stumbled on Daniel Jalkut&#8217;s post about <a href="http://www.red-sweater.com/blog/23/automatic-build-sub-versioning-in-xcode">automatically stamping the Subversion revision into <tt>Info.plist</tt></a> and thought that might be a good way to go. I also created a new key in <tt>Info.plist</tt>, <tt>LYSApplicationDisplayVersion</tt>, that I use as a human-friendly version string, which is where I get my preferred &#8220;1.0 b1&#8243; form. <tt>CFBundleVersion</tt> now takes the form of <em>major.minor.revision</em>, where <em>major</em> and <em>minor</em> are the important parts of the human-friendly version (&#8220;1.0&#8243;) and <em>revision</em> is the Subversion revision number that produced the binary.</p>
<p>I like this method because it solves one problem raised by commenters on Daniel&#8217;s post. Because the Subversion revision is the third component, it doesn&#8217;t matter that r3999 is a mature 1.2 point release and r4000 is a risky pre-2.0 alpha for testers. Those versions end up 1.2.3999 and 2.0.4000 and it&#8217;s clear that they are from two different branches of development. For iPhone Ad Hoc distribution, iTunes also parses the version properly and knows that 1.0.100 is newer than 1.0.95.</p>
<p>Here is the script to paste into your custom script build phase:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Xcode auto-versioning script for Subversion</span>
<span style="color: #666666; font-style: italic;"># by Axel Andersson, modified by Daniel Jalkut to add</span>
<span style="color: #666666; font-style: italic;"># &quot;--revision HEAD&quot; to the svn info line, which allows</span>
<span style="color: #666666; font-style: italic;"># the latest revision to always be used.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;$0: Must be run from Xcode&quot;</span> <span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;BUILT_PRODUCTS_DIR&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Get the current subversion revision number and use it to set the CFBundleVersion value</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$REV</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`/usr/bin/svnversion -n ./`</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$INFO</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Info.plist&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$REV</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># (Match the last group of digits and optional letter M/S/P):</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># ugly yet functional (barely) regex by Daniel Jalkut:</span>
<span style="color: #666666; font-style: italic;">#$version =~ s/([\d]*:)(\d+[M|S]*).*/$2/;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># better yet still functional regex via Kevin &quot;Regex Nerd&quot; Ballard</span>
<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$version</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/(\d+)([MSP]*)$/</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;$0: No Subversion revision found&quot;</span> <span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$version</span><span style="color: #339933;">;</span>
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;$0: Modified, switched or partial working copy, you sure about that?&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$2</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;BUILD_STYLE&quot;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">eq</span> <span style="color: #ff0000;">&quot;Ad Hoc&quot;</span> <span style="color: #339933;">||</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;BUILD_STYLE&quot;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">eq</span> <span style="color: #ff0000;">&quot;App Store&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>FH<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;plutil -convert xml1 <span style="color: #000099; font-weight: bold;">\&quot;</span>$INFO<span style="color: #000099; font-weight: bold;">\&quot;</span> -o - |&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;$0: $INFO: $!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$info</span> <span style="color: #339933;">=</span> <span style="color: #000066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #009999;">&lt;FH&gt;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>FH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$info</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/([\t ]+&lt;key&gt;CFBundleVersion&lt;\/key&gt;\n[\t ]+&lt;string&gt;\d+\.\d+).*?(&lt;\/string&gt;)/$1.$version$2/</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>FH<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;| plutil -convert binary1 - -o <span style="color: #000099; font-weight: bold;">\&quot;</span>$INFO<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;$0: $INFO: $!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> FH <span style="color: #0000ff;">$info</span><span style="color: #339933;">;</span>
<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>FH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>There are a couple of other changes to this script for Subversion 1.5 and later, and for iPhone OS targets.</p>
<p>The first is that the regular expression allows for a trailing P in the Subversion revision. This signals a working copy from a sparse checkout, which I never use and therefore may be a problem. I have the script fail if any letter is appended to the revision when the <tt>BUILD_STYLE</tt> is &#8220;Ad Hoc&#8221; or &#8220;App Store&#8221;, which are two new configurations, cloned from Release, that I use for Ad Hoc and App Store distribution, respectively. Especially for modified working copies: I <em>never</em> want to accidentally hand out a build made from a modified working copy. Should the day come that I really do, I can comment this line out, make the build, and uncomment it again.</p>
<p>The second is that iPhone projects convert <tt>Info.plist</tt> to the binary plist format in the application bundle. In order to extract the existing <tt>CFBundleVersion</tt> key, it must be converted back to XML. When writing the plist back out, it is again converted to binary. Both of these steps use <tt>plutil</tt>, which is part of the Developer Tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F05%2Fautomatic-subversion-revision-stamping-for-iphone-projects%2F&#038;seed_title=Automatic+Subversion+Revision+Stamping+for+iPhone+Projects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Xcode User Defaults</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F04%2Fxcode-user-defaults%2F&#038;seed_title=Xcode+User+Defaults</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F04%2Fxcode-user-defaults%2F&#038;seed_title=Xcode+User+Defaults#comments</comments>
		<pubDate>Thu, 29 Apr 2010 20:27:22 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=237</guid>
		<description><![CDATA[Xcode as a development environment matches my working style fairly well, but there are two things about it that have bothered me. The first is a warning when I try to undo edits across a file save event. Since I have Xcode set up to save all files before a build, this happens often when [...]]]></description>
			<content:encoded><![CDATA[<p>Xcode as a development environment matches my working style fairly well, but there are two things about it that have bothered me. The first is a warning when I try to undo edits across a file save event. Since I have Xcode set up to save all files before a build, this happens often when I try an experiment and don&#8217;t like it.</p>
<p>The second is code completion for language constructs such as <tt>if</tt> statements. Xcode wants to do this:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>condition<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>While I used this style a long time ago, today I want the opening brace on its own line:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>condition<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>No amount of digging in the preferences will provide a way to change these behaviors, however there is a lot of customizability hidden in the <a href="http://developer.apple.com/mac/library/documentation/DeveloperTools/Reference/XcodeUserDefaultRef/100-Xcode%5FUser%5FDefaults/UserDefaultRef.html">Xcode User Defaults</a>. My two issues are solved quite easily:</p>
<pre>
$ defaults write com.apple.Xcode XCShowUndoPastSaveWarning NO
$ defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "\n"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F04%2Fxcode-user-defaults%2F&#038;seed_title=Xcode+User+Defaults/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>malloc Debugging</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F01%2Fmalloc-debugging%2F&#038;seed_title=malloc+Debugging</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F01%2Fmalloc-debugging%2F&#038;seed_title=malloc+Debugging#comments</comments>
		<pubDate>Tue, 12 Jan 2010 21:39:04 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=218</guid>
		<description><![CDATA[Bill Bumgarner posted a nice tutorial on using malloc to debug memory misuse in Cocoa. I&#8217;ve run across these before when reading the malloc(1) man page, but it&#8217;s nice to have a tutorial that shows how to use them in practice.]]></description>
			<content:encoded><![CDATA[<p>Bill Bumgarner posted a nice tutorial on <a href="http://www.friday.com/bbum/2010/01/10/using-malloc-to-debug-memory-misuse-in-cocoa/">using malloc to debug memory misuse in Cocoa</a>. I&#8217;ve run across these before when reading the <tt>malloc(1)</tt> man page, but it&#8217;s nice to have a tutorial that shows how to use them in practice.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2010%2F01%2Fmalloc-debugging%2F&#038;seed_title=malloc+Debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode: iPhone Project Dependency on Mac OS X Project</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2009%2F10%2Fxcode-iphone-project-dependency-on-mac-os-x-project%2F&#038;seed_title=Xcode%3A+iPhone+Project+Dependency+on+Mac+OS+X+Project</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2009%2F10%2Fxcode-iphone-project-dependency-on-mac-os-x-project%2F&#038;seed_title=Xcode%3A+iPhone+Project+Dependency+on+Mac+OS+X+Project#comments</comments>
		<pubDate>Fri, 02 Oct 2009 02:32:53 +0000</pubDate>
		<dc:creator>Steve Madsen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=190</guid>
		<description><![CDATA[This week, while building an iPhone application for a client, I wanted to run a custom Mac OS X command-line utility during the build phase of the iPhone project. I set up the command-line utility as a dependent project of the iPhone project, but it won&#8217;t build, telling me: target specifies product type &#8216;com.apple.product-type.tool&#8217;, but [...]]]></description>
			<content:encoded><![CDATA[<p>This week, while building an iPhone application for a client, I wanted to run a custom Mac OS X command-line utility during the build phase of the iPhone project. I set up the command-line utility as a dependent project of the iPhone project, but it won&#8217;t build, telling me:</p>
<blockquote><p>
target specifies product type &#8216;com.apple.product-type.tool&#8217;, but there&#8217;s no such product type for the &#8216;iphonesimulator&#8217; platform
</p></blockquote>
<p>There is no perfect solution to this problem, but here&#8217;s my workaround: rather than let Xcode build the dependent project for me, I simply added a call to <tt>xcodebuild</tt> as part of my custom script phase. As long as the input and output files for this phase are set up properly, the entire phase is skipped when the output file is up-to-date, and <tt>xcodebuild</tt> is pretty fast when the target binary is already built, too.</p>
<p>My final script phase looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">cd</span> SubProject; xcodebuild <span style="color: #660033;">-configuration</span> Release<span style="color: #7a0874; font-weight: bold;">&#41;</span>
SubProject<span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span>Release<span style="color: #000000; font-weight: bold;">/</span>SubProjectCommand</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Flightyearsoftware.com%2F2009%2F10%2Fxcode-iphone-project-dependency-on-mac-os-x-project%2F&#038;seed_title=Xcode%3A+iPhone+Project+Dependency+on+Mac+OS+X+Project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.531 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-04 08:55:52 -->

