<?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>[iPhone developer:tips]; &#187; Xcode</title>
	<atom:link href="http://iPhoneDeveloperTips.com/category/xcode/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Thu, 11 Mar 2010 14:32:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tell Xcode Not to Compile a File</title>
		<link>http://iPhoneDeveloperTips.com/xcode/tell-xcode-not-to-compile-a-file.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/tell-xcode-not-to-compile-a-file.html#comments</comments>
		<pubDate>Wed, 16 Dec 2009 03:15:36 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=4410</guid>
		<description><![CDATA[By default, when you create a new file or import a file into Xcode, if the file type is recognized as a source file (.c, .m .js, etc), the file is added to the Compile Sources folder in the application target. 
You may not always prefer this default action &#8211; for example, if a JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>By default, when you create a new file or import a file into Xcode, if the file type is recognized as a source file (.c, .m .js, etc), the file is added to the <strong>Compile Sources</strong> folder in the application target. </p>
<p>You may not always prefer this default action &#8211; for example, if a JavaScript file is imported, Xcode does not know what to do with this file type so a compile warning is generated, see the example below:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/12/script.png" /></p>
<p>I ran into this recently when I added a JavaScript file that is associated with an <a  target="_blank"  href="http://www.openx.org/">Openx</a> ad that I wanted to displayed inside my application, using a UIWebView. </p>
<p>There is a simple fix, drag/drop the offending file(s) from the <strong>Compile Sources</strong> folder to the <strong>Copy Bundle Resources</strong> folder within the applications Target, which will simply include the file in the application bundle with no processing of the file (this is where you will typically see image files, sound files, etc).</p>
<p>In the image below, the file foo.js has been moved into the <strong>Copy Bundle Resources</strong> folder:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/12/script2.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/tell-xcode-not-to-compile-a-file.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Killer Xcode Tips and Tricks &#8211; Tips 1 to 10</title>
		<link>http://iPhoneDeveloperTips.com/xcode/xcode-tips-and-tricks-tips-1-to-10.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/xcode-tips-and-tricks-tips-1-to-10.html#comments</comments>
		<pubDate>Fri, 16 Oct 2009 13:33:12 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=4221</guid>
		<description><![CDATA[My world is surrounded by sticky notes, both electronic and paper, doing my best to keep track of Xcode shortcuts, tips and tricks. I strive to use the mouse as little as possible when coding, and without these tips I&#8217;d be lost. What better place to keep track of this stuff than to write about [...]]]></description>
			<content:encoded><![CDATA[<p>My world is surrounded by sticky notes, both electronic and paper, doing my best to keep track of Xcode shortcuts, tips and tricks. I strive to use the mouse as little as possible when coding, and without these tips I&#8217;d be lost. What better place to keep track of this stuff than to write about them here.</p>
<p>This is the first post of what I hope is many where we can share tips and tricks on working with Xcode.<br />
<span id="more-4221"></span></p>
<h5>Tip #1 &#8211; Split Editor View Vertically</h5>
<p>If you like to have multiple code windows open at once, the Split Editor option is your friend (see the little square grid icon shown below).</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/split1.png" /></p>
<p>By default, the windows are split horizontally. If you prefer to view your code side-by-side (nice for comparing), here&#8217;s how to tell the split to be vertical</p>
<blockquote>
<ol>
<li>Hold down <strong>Option</strong> key when clicking the Split Window icon</li>
</ol>
</blockquote>
<h5>Tip #2 &#8211; Comment Out a Block of Code </h5>
<p>You can quickly comment out a block of code as follows:</p>
<blockquote>
<ol>
<li>Select one or more lines of code to comment</li>
<li><strong>Command-/</strong></li>
</ol>
</blockquote>
<p>To uncomment a block of code, repeat the steps above.</p>
<h5>Tip #3 &#8211; Toggle Between .h and .m Files (aka Switch to Counterpart)</h5>
<p>Within your current code window, you can swap between the .h and .m file as follows:</p>
<blockquote>
<ol>
<li><strong>Command-Option Up-Arrow</strong></li>
</ol>
</blockquote>
<h5>Tip #4 &#8211; Map Keys to Actions (Key Bindings)</h5>
<p>The Switch to Counterpart tip above is a real time saver. However, I often find that if I map logical key-strokes to actions I&#8217;m much more likely to get into the habit of using them. For example, I mapped the Switch to Counterpart to <strong>Option-S</strong>, as in Swap or Switch. </p>
<p>Here&#8217;s how to set key bindings in Xcode</p>
<blockquote>
<ol>
<li>From the Xcode menu choose <strong>Prefereces</strong></li>
<li>Select <strong>Key Bindings</strong></li>
<li>Click on one of the <strong>Actions</strong> in the list</li>
<li>Tap on the <strong>Keys</strong> column on the right</li>
<li>Enter the keystroke you want to map to the action</li>
<li>Click <strong>Ok</strong> to save your changes</li>
</ol>
</blockquote>
<h5>Tip #5 &#8211; Jump to API Documentation</h5>
<p>Showing relevant API documentation for anything within the SDK(s) is as simple as:</p>
<blockquote>
<ol>
<li><strong>Option Double-Click</strong> on relevant code </li>
</ol>
</blockquote>
<p>For example, in the screenshot below, after Option double-clicking on <strong>UIToolbar</strong>, a popup window shows a summary of the class information.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/toolbar.png" /></p>
<h5>Tip #6 &#8211; Traverse File History</h5>
<p>As you open and edit various files, Xcode keeps a history list of your actions, not unlike when using a web-browser. You can move through the list using the directional arrows as shown below:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/history.png" /></p>
<p>The keystoke equivalent for the above is:</p>
<blockquote>
<ol>
<li><strong>Option-Command Left-Arrow</strong> goto to previous file</li>
<li><strong>Option-Command Right-Arrow</strong> goto to next file</li>
</ol>
</blockquote>
<h5>Tip #7 &#8211; Set a Bookmark</h5>
<p>I can&#8217;t imagine coding without having the option to set a bookmark as a placeholder for what I&#8217;m working on. I do this regularly when I need to segue to another file to find a snippet or otherwise poke around outside the current file I&#8217;m working on.</p>
<p>Setting a bookmark is as simple as:</p>
<blockquote>
<ol>
<li><strong>Control-D</strong></li>
<li>Enter a name for the bookmark</li>
</ol>
</blockquote>
<h5>Tip #8 &#8211; Jump to Bookmark</h5>
<p>There are two options to jump to a bookmark. First, you can select the bookmark icon in the upper right corner of the Editor window.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/bookmarks.png" /></p>
<p>You can bring up the same menu as shown in the above figure using this keystoke:</p>
<blockquote>
<ol>
<li><strong>Control-4</strong></li>
</ol>
</blockquote>
<h5>Tip #9 &#8211; Indent / Un-indent Code</h5>
<p>You can indent a line of code or a selected block of code as follows:</p>
<blockquote>
<ol>
<li><strong>Command-[</strong> move code left</li>
<li><strong>Command-]</strong> move code right</li>
</ol>
</blockquote>
<p>The above works regardless of where you are in a line of code, in other words, you don&#8217;t have to be at the beginning of the line.</p>
<h5>Tip #10 &#8211; Zoom Editor</h5>
<p>You can toggle between Detail view and Editor view by clicking the Editor button as shown here:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/zoomeditor.png" /></p>
<p>The keystroke equivalent of the above is:</p>
<blockquote>
<ol>
<li><strong>Shift-Command-E</strong></li>
</ol>
</blockquote>
<h5>Have an Xcode Tip to Share?</h5>
<p>If you have a favorite tip or trick, please post a comment or <a href="http://iphonedevelopertips.com/contact">send tips to me here</a>. <strong>Killer Xcode Tips and Tricks – Tips 11 to 20</strong> will be posted next week, and suggestions are welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/xcode-tips-and-tricks-tips-1-to-10.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Where Does Xcode Simulator Write Files?</title>
		<link>http://iPhoneDeveloperTips.com/xcode/where-does-xcode-simulator-write-files.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/where-does-xcode-simulator-write-files.html#comments</comments>
		<pubDate>Mon, 12 Oct 2009 09:33:43 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=4166</guid>
		<description><![CDATA[When working with Xcode and running apps in the Simulator, looking at files written to your system is often a necessity to verify all is well. For example, I&#8217;m working on a project at the moment that requires updating a plist (XML file) when the application exits. Once the content is written to the plist, [...]]]></description>
			<content:encoded><![CDATA[<p>When working with Xcode and running apps in the Simulator, looking at files written to your system is often a necessity to verify all is well. For example, I&#8217;m working on a project at the moment that requires updating a plist (XML file) when the application exits. Once the content is written to the plist, as part of the test cycle I need to open the file and make sure the content is written and updated as I expect.<br />
<span id="more-4166"></span></p>
<h5>Path to Xcode Simulator Files</h5>
<p>The path to the simulator files is here:</p>
<p><strong><span style="color: #5615d5;">/Users/<em>USER_NAME</em>/Library/Application Support/iPhone Simulator/User/Applications</span><br />
</strong></p>
<p><strong>USER_NAME</strong> is the current user logged in on the machine. There is a unique identifier created by the simulator, one value for each application. The figure below shows how this looks on my machine, notice there are two entries in the <strong>Applications</strong> folder, one for each of the current applications I am working on.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/xcode1.png" alt="" /></p>
<p>In the application <strong>App-Vol1</strong> you can see that I am creating a custom plist file <strong>Favorites.plist</strong> and storing the file in the <strong>Documents</strong> directory. This is the file I referred to earlier that I update whenever the user quits the application.</p>
<h5>Easy Access to Simulator Files</h5>
<p>To make access to the simulator files quick and easy, I keep an entry on the left side of Finder titled <strong>iPhone Simulator</strong>. Simply navigate your way to the simulator files and drag/drop the folder on the left sidebar. You can rename this folder by right-clicking and choosing <strong>Rename</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/where-does-xcode-simulator-write-files.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Static Code Analysis (Clang) and Xcode 3.2</title>
		<link>http://iPhoneDeveloperTips.com/xcode/static-code-analysis-clang-and-xcode-3-2.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/static-code-analysis-clang-and-xcode-3-2.html#comments</comments>
		<pubDate>Thu, 03 Sep 2009 04:03:37 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3698</guid>
		<description><![CDATA[With the release of Xcode 3.2 (available with Mac OX 10.6 &#8211; Snow Leopard) you can easily run a static analysis check on your code, thanks to integration of Clang. If you&#8217;ve worked with Clang prior to its integration of Xcode, you already know just how cool this is for . If you are new [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of Xcode 3.2 (available with Mac OX 10.6 &#8211; Snow Leopard) you can easily run a static analysis check on your code, thanks to integration of <a  target="_blank"  href="http://clang.llvm.org/">Clang</a>. If you&#8217;ve worked with Clang prior to its integration of Xcode, you already know just how cool this is for . If you are new to Clang, you owe it to yourself to check it out.</p>
<p>Static analysis does a deeper parsing of your code than a traditional compilation. It looks through each potential code path and can find potential problems that are not obvious to the compiler (and may be missed by you as well).<br />
<span id="more-3698"></span></p>
<h5>How it Works</h5>
<p>The code below compiles just fine, no warnings. However, Xcode 3.2 will flag a few potential problems when running an analysis of the code. To run the analyzer, from the <strong>Build</strong> menu, choose <strong>Build and Analyze</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>getSomeValue<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>x
<span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">BOOL</span> positiveFlag;
&nbsp;
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>x &lt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>   
  <span style="color: #002200;">&#123;</span>    
   positiveFlag <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;   
  <span style="color: #002200;">&#125;</span>   
  <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>x &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
  <span style="color: #002200;">&#123;</span>
    positiveFlag <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
  <span style="color: #002200;">&#125;</span>  
&nbsp;
  <span style="color: #a61390;">return</span> positiveFlag;
&nbsp;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>If you look in the <strong>Build Results</strong> window, you&#8217;ll see more information:</p>
<blockquote>
<ul>
<li>Variable &#8216;positiveflag&#8217; declared without an initial value</li>
<li>Uninitialized or undefined value returned to caller</li>
</ul>
</blockquote>
<p>The problem occurs in this code if the value of <strong>x == 0</strong>, given the variable <strong>positiveflag</strong> has no default value set, it may not return what you expect.</p>
<h5>Showing Control Flow</h5>
<p>Here&#8217;s an interesting option you have within the integration of static analysis in Xcode &#8211; click on one of the entries in the <strong>Build Results</strong> window (as shown below):</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/09/clang6.png" alt="" /></p>
<p>and Xcode will highlight the flow of the code, and help you pinpoint the potential problem:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/09/clang5.png" alt="" /></p>
<h5>Run Static Analysis with Each Build</h5>
<p>By default, you request a static analysis of your code by selecting <strong>Build and Analyze</strong> in the <strong>Build</strong> menu. If you would like a static analysis run whenever you build a project with the debug configuration, you can check the <strong>Run Static Analyzer</strong> in the <strong>Build Options</strong> as shown in the image below:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/09/clang3.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/static-code-analysis-clang-and-xcode-3-2.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Build iPhone Apps for 2.2 and Earlier, Using Xcode 3.2 and Snow Leopard</title>
		<link>http://iPhoneDeveloperTips.com/xcode/build-iphone-apps-for-2-2-and-earlier-using-xcode-3-2-and-snow-leopard.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/build-iphone-apps-for-2-2-and-earlier-using-xcode-3-2-and-snow-leopard.html#comments</comments>
		<pubDate>Mon, 31 Aug 2009 19:03:54 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3657</guid>
		<description><![CDATA[Once you upgrade to Snow Leopard, you&#8217;ll notice a few things have changed as far as how to create builds for versions of the iPhone/iPod prior to 3.0. The changes are minor, however, I think you&#8217;ll agree that things have been simplified.
Let&#8217;s start with how to get your system working with Snow Leopard:
Install Xcode/SDK for [...]]]></description>
			<content:encoded><![CDATA[<p>Once you upgrade to Snow Leopard, you&#8217;ll notice a few things have changed as far as how to create builds for versions of the iPhone/iPod prior to 3.0. The changes are minor, however, I think you&#8217;ll agree that things have been simplified.</p>
<p>Let&#8217;s start with how to get your system working with Snow Leopard:</p>
<p><strong>Install Xcode/SDK for Snow Leopard</strong></p>
<blockquote>
<ol>
<li>Install Snow Leopard from DVD</li>
<li>Install Xcode 3.2 from Snow Leopard DVD</li>
<li>Download and install iPhone SDK 3.0 for Snow Leopard from Apple Developer Connection</li>
</ol>
</blockquote>
<p><span id="more-3657"></span></p>
<p>Once installed, upon opening a project you may see something similar to the following (which I received when opening a recent project):</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/08/xcode0.png" /></p>
<p>Notice the reference to &#8220;iPhone Device 2.2.1 (missing)&#8221;. This project was built for 2.2.1 before I upgrade Xcode. On a similar note, if you open the dialog to set the device and distribution settings, here is how things will look:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/08/xcode1.png" /></p>
<p>Again, the references to earlier SDK&#8217;s are no longer available.</p>
<p><strong>Targetging 2.2 or Earlier Version of iPhone SDK</strong></p>
<p>The trick to targeting earlier versions of the SDK is now done through the Deployment section in the Build preferences. In the image below you&#8217;ll see a reference to <strong>iPhone OS Deployment Target</strong> along with a list of available OS target options.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/08/xcode2.png" /></p>
<p>Choose the target you need, clean, rebuild, and with that, you should be good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/build-iphone-apps-for-2-2-and-earlier-using-xcode-3-2-and-snow-leopard.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>iTunes Icon for Ad-hoc Distributions</title>
		<link>http://iPhoneDeveloperTips.com/xcode/itunes-icon-for-ad-hoc-distributions.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/itunes-icon-for-ad-hoc-distributions.html#comments</comments>
		<pubDate>Thu, 30 Jul 2009 09:06:05 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=2877</guid>
		<description><![CDATA[Creating an icon for iTunes adhoc / ad-hoc distributions.]]></description>
			<content:encoded><![CDATA[<p>A common question that comes up from users who are testing ad-hoc / beta releases of iPhone apps, is why there is no icon for the applications in iTunes?</p>
<p>For ad-hoc builds of your application, by default, iTunes will display a generic icon for your application. The default artwork for an ad-hoc build looks as follows:<br />
<span id="more-2877"></span></p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/07/scr1.png" /></p>
<p>To add artwork so beta testers will see an icon within iTunes, you add a file with the name <strong>iTunesArtwork</strong> to your application bundle. </p>
<p><strong>Add iTunes icon to Xcode Project:</strong></p>
<p>  * Create a png or jpg file that is 512&#215;512 pixels<br />
  * In the <strong>Groups &#038; Files</strong> list, right click on <strong>Resources</strong> group<br />
  * Choose <strong>Add</strong>, followed by <strong>Existing Files&#8230;</strong><br />
  * Select the file you created, <strong>iTunesArtwork</strong><br />
  * In the popup dialog, check <strong>Copy items into destination group&#8217;s folder</strong><br />
  * Click <strong>Add</strong></p>
<p>Clean and rebuild your project. When you add the application to iTunes, you should now see the artwork now tied to the application.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/07/scr22.png" /></p>
<p><strong>Caveats:</strong><br />
So the above sounds simple enough, which it is, however, there are a few gotcha&#8217;s that made this simple process go from what should of been 10 minutes of tinkering to an hour of hair pulling.</p>
<p>Let me point out the steps that may trip you up:</p>
<p><strong>#1</strong> &#8211; The file must be named <strong>iTunesArtwork</strong> with no extension, and don&#8217;t forget to capitalize the T and A (hmmm, there&#8217;s a joke in there somewhere).</p>
<p><strong>#2</strong> &#8211; I now know that you can&#8217;t start with a filename that has an extension of jpg or png and simply rename the file. For example, I had a 512&#215;512 image that I created for the App Store. Seemed a reasonable assumption that if I renamed the file, everything would be copacetic. I went into Finder, right clicked on the file and removed the extension. No go. I could add to the project as shown above, however, the icon would not show up in iTunes. </p>
<p>After trying various file types (png, jpg), adding the file in different locations (root of the project, resources folder, etc), I decided to create a new image altogether thinking maybe the image was wonky. When saving the image in the image editor, I specified not to add a file extension. Shazam, that was the problem!</p>
<p>You&#8217;ll know if you&#8217;ve done this correctly as the file within the Resources folder will show up without an extension:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/07/scr5.png" /></p>
<p>as compared to this:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/07/scr41.png" /></p>
<p>#3 &#8211; There was a known bug within Xcode in an earlier version that generated the error <strong>0xE8000058</strong>. This would happen when you switched from creating an ad-hoc build to a debug version and attempted to install on a device. </p>
<p>If you run into this error, remove the file iTunesArtwork from your application bundle (you can leave the file, just delete the reference to it) and rebuild. </p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/itunes-icon-for-ad-hoc-distributions.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Xcode, Folders and the File System &#8211; Part 2</title>
		<link>http://iPhoneDeveloperTips.com/xcode/xcode-folders-and-the-file-system-part-2.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/xcode-folders-and-the-file-system-part-2.html#comments</comments>
		<pubDate>Tue, 09 Jun 2009 13:54:21 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=2393</guid>
		<description><![CDATA[In Part 1 of Xcode, Folders and the File System I walked through a short example on how to import folders into Xcode such that resources within a project have a folder structure that matches the file system.
In this post I will show you two ways to access the imported resources, one by specifying a [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://iphonedevelopertips.com/xcode/xcode-folders-and-the-file-system-part-1.html">Part 1 of Xcode, Folders and the File System</a> I walked through a short example on how to import folders into Xcode such that resources within a project have a folder structure that matches the file system.</p>
<p>In this post I will show you two ways to access the imported resources, one by specifying a path, one using an application bundle, both examples will focus on working with images. The code below is an example of building a path to a resource, avoiding a hardcoded path by using index values maintained within the application.<br />
<span id="more-2393"></span></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">int</span> modelIndex <span style="color: #002200;">=</span> <span style="color: #2400d9;">2</span>, imageIndex <span style="color: #002200;">=</span> <span style="color: #2400d9;">5</span>;
...
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>imageName <span style="color: #002200;">=</span> 
  <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;/Model-%02d/coverflow/CoverFlow-%02d.jpg&quot;</span>, 
   modelIndex, imageIndex<span style="color: #002200;">&#93;</span>;
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;image: %@&quot;</span>, imageName<span style="color: #002200;">&#41;</span>;</pre></div></div>

<p>The output in the debug console looks as follows, notice the full path to the image:</p>
<p>2009-06-09 08:20:30.732 AppName[25154:20b] image: /Model-02/coverflow/CoverFlow-05.jpg</p>
<p>You can create a <strong>UIImageView</strong> referencing the file using the code shown below. The method <strong>imageNamed:</strong> looks for the image in the application’s main bundle if this is the first request for the image. If the image has been loaded previously, the image is retrieved from the system maintained internal cache.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIImageView <span style="color: #002200;">*</span>wallpaper <span style="color: #002200;">=</span> 
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span>imageName<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>There are times when you will need to reference resources by working with the main application bundle. Following on the same theme of working with images, caching of images is not always a good idea (see the post <a href="http://iphonedevelopertips.com/memory-management/images-and-caching.html">Images and Caching</a> for more information). In this case, using the method <strong>imageWithContentsOfFile:</strong> is a better option. However, there is one difference we need to account for when using this method, namely, <strong>imageWithContentsOfFile:</strong> loads image data from a specified path, however, it will not look in the application bundle by default.</p>
<p>Creating the proper path can be as simple as:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> 
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Splash&quot;</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;jpg&quot;</span> inDirectory<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span><span style="color: #002200;">&#93;</span>; 
UIImageView <span style="color: #002200;">*</span>background <span style="color: #002200;">=</span> 
<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageWithContentsOfFile<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>In order for <strong>imageWithContentsOfFile:</strong> to work with images imported from the file system as I demonstrated in Part 1, we need to specify the full path to the resource, here&#8217;s how that code might look:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>dir <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Model-%02d/coverflow&quot;</span>, modelIndex<span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>file <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CoverFlow-%02d&quot;</span>, imageIndex<span style="color: #002200;">&#93;</span>; 
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span>file
   ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;jpg&quot;</span> inDirectory<span style="color: #002200;">:</span>dir<span style="color: #002200;">&#93;</span>;
UIImageView <span style="color: #002200;">*</span>wallpaper <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> 
  initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageWithContentsOfFile<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Working with files directly imported from the file system can be quite useful, even more so when there are many files to manage within an application. However, you will need to keep in mind how to access the resources, either through a full path or by working with an application bundle.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/xcode-folders-and-the-file-system-part-2.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Xcode, Folders and the File System &#8211; Part 1</title>
		<link>http://iPhoneDeveloperTips.com/xcode/xcode-folders-and-the-file-system-part-1.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/xcode-folders-and-the-file-system-part-1.html#comments</comments>
		<pubDate>Mon, 08 Jun 2009 16:15:01 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=2362</guid>
		<description><![CDATA[Xcode provides a built in mechanism for organzing content within a project (control-click or right click -&#62; Add -&#62; New Group). For example, in the image below, I&#8217;ve created a number of groups for separating the primary functionality of an application into model classes and views. 

Although this is nice, for the most part the [...]]]></description>
			<content:encoded><![CDATA[<p>Xcode provides a built in mechanism for organzing content within a project (control-click or right click -&gt; Add -&gt; New Group). For example, in the image below, I&#8217;ve created a number of groups for separating the primary functionality of an application into model classes and views. </p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/06/xcode-groups.png" /></p>
<p>Although this is nice, for the most part the file structure as stored on the system is still flat. In other words, Xcode manages this information internally, it does not create corresponding folders on the file system.<br />
<span id="more-2362"></span></p>
<p>In a recent application I was working with large sets of images. The question was, how to best manage all the images within Xcode such that I could leverage the inherent nature of folders and sub-folders on the file system. Let me explain a little further.</p>
<p><img style="max-width: 800px;" src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/06/filesys.png" /></p>
<p>From the figure above you can get an idea of how I chose to break down the content. There was a total of 12 models, for each model there were  up to 40 images in the folder <strong>/coverflow</strong> (see the image on the right), a separate folder for wallpaper images, with an image that corresponds to each coverflow image, as well as a handful of other images such a headshot, MenuButton, etc.</p>
<p>On the file system this is a logical breakdown of content, and if I were to use this same structure within the application I could build a path to the appropriate folder in the resource bundle using an index value to specify which folder I am after (/Model-01, /Model-02, etc). This would allow for code that can access the same files, regardless of which model the user selected, no hard-coding of file names and paths.</p>
<p>There were two tricks to get this to work within Xcode. The first trick is to properly import the file contents into Xcode. Here&#8217;s how you do that:</p>
<p><strong>Step #1: </strong>In the project, right click (control-click) and choose Add -&gt; Existing Files:</p>
<p><img style="max-width: 800px;" src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/06/add1.png" /></p>
<p><strong>Step #2: </strong>Choose the folders on the file system to import:</p>
<p><img style="max-width: 800px;" src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/06/add2.png" /></p>
<p><strong>Step #3: </strong>After clicking on Add, you will be prompted with the dialog box below. Chose to copy the files into the project as well as create the folder references in the project:</p>
<p>&nbsp;<img style="max-width: 800px;" src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/06/add3.png" /></p>
<p>You&#8217;ll know that all is well if the folder references appear as blue folders (shown below).</p>
<p><img style="max-width: 800px;" src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/06/add4.png" /></p>
<p>The second trick was to properly reference resources within the application. This was straightforward for images that I wanted the system to cache, however it required a few extra steps for those images I didn&#8217;t want cached. More on this, and the code to make it all work, in Part II.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/xcode-folders-and-the-file-system-part-1.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Finding the Xcode Project File in a Folder</title>
		<link>http://iPhoneDeveloperTips.com/xcode/finding-the-xcode-project-file-in-a-folder.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/finding-the-xcode-project-file-in-a-folder.html#comments</comments>
		<pubDate>Mon, 01 Jun 2009 22:54:46 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=2338</guid>
		<description><![CDATA[This barely qualifies as a tip worthy of publishing, however, it&#8217;s something I use regularly so I figured it&#8217;s worthwhile passing on.
I&#8217;ve been working with some monster projects as it relates to content. What that translates to is really long lists of files inside of Finder. Since I bounce between a handful of projects over [...]]]></description>
			<content:encoded><![CDATA[<p>This barely qualifies as a tip worthy of publishing, however, it&#8217;s something I use regularly so I figured it&#8217;s worthwhile passing on.</p>
<p>I&#8217;ve been working with some monster projects as it relates to content. What that translates to is really long lists of files inside of Finder. Since I bounce between a handful of projects over the course of the week, more often than not I opt to open a project from by browsing the files within Finder and opening the file with the extension .xcodeproj. With folders having many files, I quickly tired of scrolling down the file list looking for the xcode project file. </p>
<p>To bubble the project file to the top, I simply rename the project file and place an underscore at the front of the project name. For example, <strong>SomeProject.xcodeproj</strong> becomes <strong>_SomeProject.xcodeproj</strong>. This has no effect on the project (from Xcode&#8217;s perspective), however you may need to update your source code control system with the new (renamed) file.</p>
<p>Trivial as it is, a hand tip none-the-less.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/finding-the-xcode-project-file-in-a-folder.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iPhone Distribution Build Cheatsheet</title>
		<link>http://iPhoneDeveloperTips.com/xcode/iphone-distribution-build-cheatsheet.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/iphone-distribution-build-cheatsheet.html#comments</comments>
		<pubDate>Thu, 02 Apr 2009 02:27:03 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=2011</guid>
		<description><![CDATA[For anyone who&#8217;s been through creating a distribution build, Ad Hoc or for the App Store, you know all to well it&#8217;s no walk in the park. After going through this a few times, I began writing notes to myself, which eventually become a rather lengthy checklist.
I thought this same information might be helpful for [...]]]></description>
			<content:encoded><![CDATA[<p>For anyone who&#8217;s been through creating a distribution build, Ad Hoc or for the App Store, you know all to well it&#8217;s no walk in the park. After going through this a few times, I began writing notes to myself, which eventually become a rather lengthy checklist.</p>
<p>I thought this same information might be helpful for others, so I consolidated all the notes into one document.<br />
<span id="more-2011"></span></p>
<p>There are a few caveats:</p>
<ul>
<li>The list is not necessarily the shortest path to create a distribution.</li>
<li>A few redundant steps are listed, mostly done as a sanity check to ensure nothing was missed.</li>
<li>This list will be helpful primarily to those who are about to adventure upon their first deployment.</li>
</ul>
<p>Download: <strong><a href="http://iphonedevelopertips.com/wp-content/uploads/2009/iPhoneDistributionBuildCheatsheet.pdf">iPhone Distribution Build Cheatsheet</a> </strong></p>
<p>This list was written with Pages on a Mac and printed to a PDF file. If anyone has a suggestion on how to embed the document into this post, <a href="http://iphonedevelopertips.com/contact">please let me know</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/iphone-distribution-build-cheatsheet.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
