<?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>[iPhoneiOS dev: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>Wed, 25 Aug 2010 11:38:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Download and Install Older Versions of Xcode (Xcode Previous Releases)</title>
		<link>http://iPhoneDeveloperTips.com/xcode/download-and-install-older-versions-of-xcode-xcode-previous-releases.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/download-and-install-older-versions-of-xcode-xcode-previous-releases.html#comments</comments>
		<pubDate>Fri, 23 Jul 2010 01:02:07 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6710</guid>
		<description><![CDATA[As a general rule of thumb, it&#8217;s best to stick with the latest release of Xcode. That said, there are times when running an older release can be a good thing. You can download older versions of Xcode by logging into Apple Developer Connection &#8211; Downloads and ADC Program Assests (http://connect.apple.com) &#8211; You will need [...]]]></description>
			<content:encoded><![CDATA[<p>As a general rule of thumb, it&#8217;s best to stick with the latest release of Xcode. That said, there are times when running an older release can be a good thing. </p>
<p>You can download older versions of Xcode by logging into <a href="http://connect.apple.com">Apple Developer Connection &#8211; Downloads and ADC Program Assests</a> (<a href="http://connect.apple.com">http://connect.apple.com</a>) &#8211; You will need to be a member of the developer program to login.<br />
<span id="more-6710"></span></p>
<p>Once on the site, from the <strong>Downloads</strong> section, choose <strong>Developer Tools</strong> &#8211; you will be shown with a list of all Xcode versions, back to 1.0 released in October of 2004.</p>
<h5>Install Multiple Versions of Xcode</h5>
<p>To keep from overwriting an existing installation, you can specify the path for Xcode during the install process. For example, the default location is /Developer, to install an older version you could instruct Xcode to install into a simliar name such as /Developer-3.1</p>
<p>To change the install path, click on the Location header in the install dialog:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/08/xcodeInstall-1.png" /></p>
<p>Choose a new path for the Essentials Package:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/08/xcodeInstall-2.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/download-and-install-older-versions-of-xcode-xcode-previous-releases.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing iPhone Apps with iOS4 SDK, Deploying to 3.x Devices : Base SDK and iPhone OS Deployment Target</title>
		<link>http://iPhoneDeveloperTips.com/xcode/base-sdk-and-iphone-os-deployment-target-developing-apps-with-the-4-x-sdk-deploying-to-3-x-devices.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/base-sdk-and-iphone-os-deployment-target-developing-apps-with-the-4-x-sdk-deploying-to-3-x-devices.html#comments</comments>
		<pubDate>Tue, 06 Jul 2010 07:08:23 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6506</guid>
		<description><![CDATA[Editor&#8217;s Note:You can download and install any previous release of Xcode if you would like to roll back to an earlier version. You can get the specifics here: Download and Install Older Versions of Xcode. If you&#8217;ve installed Xcode 3.2.3 you quickly became aware that the only SDK&#8217;s packaged with this version are 4.0 and [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Editor&#8217;s Note:</strong>You can download and install any previous release of Xcode if you would like to roll back to an earlier version. You can get the specifics here: <a  target="_blank"  href="http://iphonedevelopertips.com/xcode/download-and-install-older-versions-of-xcode-xcode-previous-releases.html">Download and Install Older Versions of Xcode</a>.<br />
</em><br />
If you&#8217;ve installed Xcode 3.2.3 you quickly became aware that the only SDK&#8217;s packaged with this version are 4.0 and 3.2. Until 4.x has widespread adoption, chances are you&#8217;ll want your applications to run on earlier versions of the iPhone OS (iOS) SDK. You can accomplish this feat through two configuration options within Xcode, the Base SDK and the iPhone OS Deployment Target.<br />
<span id="more-6506"></span></p>
<h5>Base SDK</h5>
<p>The Base SDK is the version of SDK that will be used when compiling your application &#8211; the compiler will use the headers and libraries of this specific SDK. For example, in the image below notice that there are only two choices for the Base SDK for both the device and simulator, versions 3.2 and 4.0.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/07/basesdk.png" /></p>
<p>However, we have an issue here, if you build an application with the latest SDK and deploy on a device with an earlier OS, chances are your application will crash if you reference any code in a 4.x API while running the application on a 3.x device. Also, the 3.2 SDK is for the iPad only, so this isn&#8217;t an option when deploying to an iPhone or iPod touch.</p>
<h5>iPhone OS Deployment Target</h5>
<p>To specify which OS version is the minimum that your application will support, you set the deployment target. Your application will then run on this minimum OS as well as all later versions.</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/07/targetsdk.png" /></p>
<p>This is all well and good, however, the obvious question is how to deploy on an earlier OS version yet take advantage of features for those devices that are running a later OS?</p>
<h5>Check for Feature Availability Not OS Version</h5>
<p>When targeting an earlier OS as mentioned above, yet you want to take advantage of features of a later OS for devices that support it, you can use the method <strong>respondsToSelector</strong> to check if the receiver  implements or inherits a method that can respond to a specified message. This approach follows Apple&#8217;s recommendation to check for availability of features versus a specific OS version.</p>
<p>In the example below the code will check if the object returned by <strong>[UIDevice currentDevice]</strong> will respond to the selector shown, if so, you can write relevant multi-tasking code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIDevice currentDevice<span style="color: #002200;">&#93;</span> respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>isMultitaskingSupported<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Multi-tasking code for supported devices</span>
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">else</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Devices without multi-tasking support</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Another time when that you may choose to use <strong>respondsToSelector</strong> is for cases when the implementation of the same API has changed with a later OS version. I ran into this particular case when writing code for displaying movies using the <strong>MPMoviePlayerController</strong>. In the 4.x SDK the notifications have changed slightly &#8211; in 2.0 to 3.1 <strong>MPMoviePlayerContentPreloadDidFinishNotification</strong> was the notification you would use to receive notice that a movie was ready to play. With 3.2 (iPad) and later, <strong>MPMoviePlayerContentPreloadDidFinishNotification</strong> has been deprecated and  <strong>MPMoviePlayerLoadStateDidChangeNotification</strong> has taken its place. </p>
<p>The code example below shows how you may go about using <strong>respondsToSelector</strong> to figure out which notification you should request based on the whether or not the movie player can return information about its load state:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">MPMoviePlayerController <span style="color: #002200;">*</span>mp <span style="color: #002200;">=</span> 
   <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MPMoviePlayerController alloc<span style="color: #002200;">&#93;</span> initWithContentURL<span style="color: #002200;">:</span>movieURL<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// This method is available on 3.2 and greater...</span>
 <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>mp respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>loadState<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> 
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Register to receive notification when load state changed</span>
  <span style="color: #11740a; font-style: italic;">// (check for playable, stalled...)</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">&#93;</span> addObserver<span style="color: #002200;">:</span>self 
                       selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>moviePlayerLoadStateChanged<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> 
                       name<span style="color: #002200;">:</span>MPMoviePlayerLoadStateDidChangeNotification 
                       object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">else</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Register to receive a notification when the movie is ready to play.</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">&#93;</span> addObserver<span style="color: #002200;">:</span>self 
                         selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>moviePreloadDidFinish<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> 
                         name<span style="color: #002200;">:</span>MPMoviePlayerContentPreloadDidFinishNotification 
                         object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Check for Function Availability</h5>
<p>Beyond working with objects, if you need to check for the availability of a specific function, you do so by comparing the function to NULL. In the example below I check for a function related to creating a PDF-based graphics context (available in 3.2 and later).</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>UIGraphicsBeginPDFContextToFile <span style="color: #002200;">!=</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// The function is available</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Testing Across OS Versions</h5>
<p>Unfortunately, with the upgrade to the latest Xcode (3.2.3) there are no simulators for 3.1.x and earlier OS versions. Although it has always been recommended to test your apps on device, at this point it becomes a necessity. </p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/base-sdk-and-iphone-os-deployment-target-developing-apps-with-the-4-x-sdk-deploying-to-3-x-devices.html/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Rename an Xcode Project</title>
		<link>http://iPhoneDeveloperTips.com/xcode/rename-xcode-project.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/rename-xcode-project.html#comments</comments>
		<pubDate>Fri, 02 Apr 2010 01:51:32 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6075</guid>
		<description><![CDATA[If you&#8217;ve ever attempted to rename an Xcode project you can speak first hand to the pain of getting all the details just right. Good news, it was recently pointed out by a reader in this post: Change Company Name from Within Xcode on a Per Project Basis that there is now a rename feature [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever attempted to rename an Xcode project you can speak first hand to the pain of getting all the details just right. Good news, it was recently pointed out by a reader in this post: <a href="http://iphonedevelopertips.com/xcode/change-company-name-from-within-xcode-on-a-per-project-basis.html">Change Company Name from Within Xcode on a Per Project Basis</a> that there is now a rename feature built into Xcode.</p>
<h5>Renaming an Xcode Project</h5>
<p>First, click on the Project menu and select Rename:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/04/rename1.png" /></p>
<p>From there, fill in the new name, I&#8217;d also recommend creating a snapshot as a precaution:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/04/rename2.png" /></p>
<p>Renaming an Xcode project is no longer a mysterious, troublesome endeavor.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/rename-xcode-project.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Change Company Name from Within Xcode on a Per Project Basis</title>
		<link>http://iPhoneDeveloperTips.com/xcode/change-company-name-from-within-xcode-on-a-per-project-basis.html</link>
		<comments>http://iPhoneDeveloperTips.com/xcode/change-company-name-from-within-xcode-on-a-per-project-basis.html#comments</comments>
		<pubDate>Thu, 25 Mar 2010 11:39:49 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5973</guid>
		<description><![CDATA[A common question for most anyone new to Xcode is how to change the Company Name that is added to each new source file. The default information looks similar to the following: Copyright (c) 2010 MyCompanyName. All rights reserved. Up until Xcode 3.2 to change this value you had to resort to running a command [...]]]></description>
			<content:encoded><![CDATA[<p>A common question for most anyone new to Xcode is how to change the Company Name that is added to each new source file. The default information looks similar to the following:</p>
<blockquote><p>Copyright (c) 2010 MyCompanyName. All rights reserved.</p></blockquote>
<p>Up until Xcode 3.2 to change this value you had to resort to running a command from a terminal, you can see how this was previously done in this tip: <a href="http://iphonedevelopertips.com/xcode/change-company-name-in-xcode.html">Change Company Name in Xcode</a>. </p>
<p>A welcome change with 3.2+ is that this value can now be managed from within Xcode. Even better, the name can be configured on a project by project basis, which is really nice if you need to maintain multiple copyright statements across projects.</p>
<h5>Change Company Name within Xcode</h5>
<p>In the Groups and Files window, right click on the project name and select <strong>Get Info</strong>:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/03/comp1.png" /></p>
<p>In the <strong>General Settings</strong> tab, near the bottom you&#8217;ll see a field for the Organization Name:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/03/comp2.png" /></p>
<p>Update this field and the new value will be reflected in each source code file you create in the active project.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/xcode/change-company-name-from-within-xcode-on-a-per-project-basis.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>3</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>6</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>2</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>19</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 [...]]]></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>14</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>6</slash:comments>
		</item>
	</channel>
</rss>
