<?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>The Rare AiR &#187; Tutorials</title>
	<atom:link href="http://www.therareair.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.therareair.com</link>
	<description>An Eric Orion Anderson Website.</description>
	<lastBuildDate>Thu, 01 Jul 2010 20:31:02 +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>Tutorial: How to Setup Icefaces for JBoss 5.0 in Eclipse</title>
		<link>http://www.therareair.com/2009/03/28/tutorial-how-to-setup-icefaces-for-jboss-50-in-eclipse/</link>
		<comments>http://www.therareair.com/2009/03/28/tutorial-how-to-setup-icefaces-for-jboss-50-in-eclipse/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 18:46:44 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.therareair.com/?p=260</guid>
		<description><![CDATA[This tutorial will show how to setup an Icefaces development environment in Eclipse for Jboss 5.0.  I will be using the newest GM versions of Icefaces (1.7.2-SP1), Eclipse (3.4.2), and Jboss (5.0.1).
Download the Stuff
First, lets get Icefaces here.  Notice we will not be downloading the libraries, as they are included in the Eclipse [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will show how to setup an Icefaces development environment in Eclipse for Jboss 5.0.  I will be using the newest GM versions of Icefaces (1.7.2-SP1), Eclipse (3.4.2), and Jboss (5.0.1).</p>
<h1 class="body">Download the Stuff</h1>
<p>First, lets get Icefaces <a href="http://www.icefaces.org/main/downloads/os-downloads.iface" target="_blank">here</a>.  Notice we will not be downloading the libraries, as they are included in the Eclipse Plugin.</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/download_icefaces_for_eclipse.png" title="" class="thickbox" rel="singlepic335" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/335__460x320_download_icefaces_for_eclipse.png" alt="download_icefaces_for_eclipse.png" title="download_icefaces_for_eclipse.png" />
</a>
</div>
<p>Next lets download Eclipse <a href="http://www.eclipse.org/downloads/" target="_blank">here</a>.  Note you will need to have a Java JDK installed.  You can get that <a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank">here</a>.</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/download_eclipse.png" title="" class="thickbox" rel="singlepic334" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/334__460x320_download_eclipse.png" alt="download_eclipse.png" title="download_eclipse.png" />
</a>
</div>
<p>Lastly, lets get the Jboss Application Server <a href="http://www.jboss.org/jbossas/downloads/" target="_blank">here</a>.</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/download_jboss.png" title="" class="thickbox" rel="singlepic336" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/336__460x320_download_jboss.png" alt="download_jboss.png" title="download_jboss.png" />
</a>
</div>
<h1 class="body">Install Applications</h1>
<p>Extract all three of these somewhere.  I extracted them into C: as seen here:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/extracted_apps.png" title="" class="thickbox" rel="singlepic338" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/338__460x320_extracted_apps.png" alt="extracted_apps.png" title="extracted_apps.png" />
</a>
</div>
<p>Open eclipse and goto the help menu->Software Updates&#8230;  From here hit the Available Software tab.  Click the add site button and then the Local&#8230; button.  Direct it to where you extracted the Icefaces Eclipse Plugin.  Should end up looking like this:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/eclipse_install_icefaces.png" title="" class="thickbox" rel="singlepic337" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/337__460x320_eclipse_install_icefaces.png" alt="eclipse_install_icefaces.png" title="eclipse_install_icefaces.png" />
</a>
</div>
<p>Click install and agree to the terms.  It will install and restart Eclipse.  Last thing before we get started is to add our server.  In Eclipse goto the Window menu->Preferences.  Expand Server->Runtime Environment.  Click Add&#8230;  Expand Jboss and select Jboss v5.0.  Click next and browse to where you extracted Jboss.</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/add_server.png" title="" class="thickbox" rel="singlepic333" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/333__460x320_add_server.png" alt="add_server.png" title="add_server.png" />
</a>
</div>
<h1 class="body">Create Icefaces Project</h1>
<p>We are now ready to start creating a new Icefaces project.  Goto the file menu->New->Dynamic Web Project.  Give it a project name.  Set the Target Runtime to the server we created in the last step.  You can leave Dynmaic Web Module version at 2.5  Changed the configuration to an Icefaces Project.  </p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/new_icefaces_project.png" title="" class="thickbox" rel="singlepic339" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/339__460x320_new_icefaces_project.png" alt="new_icefaces_project.png" title="new_icefaces_project.png" />
</a>
</div>
<p>Click Next.  Change Content Directory to &#8216;web&#8217; since this is more popular. </p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/new_icefaces_project2.png" title="" class="thickbox" rel="singlepic340" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/340__460x320_new_icefaces_project2.png" alt="new_icefaces_project2.png" title="new_icefaces_project2.png" />
</a>
</div>
<p>
Click Next.  Select Server Supplied JSF radio button.  Deploy only the Icefaces Libraries as Jboss AS has the rest already included.  Including the others will throw errors when you deploy your web application.  You can leave the rest.  Click Next and Finish.  </p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/new_icefaces_project3.png" title="" class="thickbox" rel="singlepic341" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/341__460x320_new_icefaces_project3.png" alt="new_icefaces_project3.png" title="new_icefaces_project3.png" />
</a>
</div>
<p>You now have have your project created.  Before we can start developing, one more thing to configure.  We need to add a line to the faces-config.xml in the WEB-INF folder.  Without it you will receive errors when deploying.  Your face-config.xml should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE faces-config PUBLIC</span>
<span style="color: #00bbdd;">    &quot;-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN&quot;</span>
<span style="color: #00bbdd;">    &quot;http://java.sun.com/dtd/web-facesconfig_1_1.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;faces-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;view-handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
		com.icesoft.faces.facelets.D2DFaceletViewHandler 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/view-handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/faces-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>
After making the changes save the file.</p>
<h1 class="body">Test if it Works</h1>
<p>We are now ready to add a new test page.  Right click on the web folder and New->JSP.  Lets name the new file &#8216;test.jspx&#8217;.  Click Next.  Select New IceFaces JSPX File (.jspx).</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/new_page.png" title="" class="thickbox" rel="singlepic342" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/342__460x320_new_page.png" alt="new_page.png" title="new_page.png" />
</a>
</div>
<p>Click finish.  We can now deploy and test if it works.  Right click the project and select Run As->Run on Server.  It should already be set to the server we created earlier:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/run_app.png" title="" class="thickbox" rel="singlepic343" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/343__460x320_run_app.png" alt="run_app.png" title="run_app.png" />
</a>
</div>
<p>
You can click next and make any configuration changes if you wish.  Click finish when you are ready.  Notice it will open to the default root.  Open a browser and enter this url if you used the same configurations as I did (default).</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost:8080/IcefacesTutorial/test.iface</span></pre></div></div>

<p>
If everything worked as expected you should have received this page:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/icefaces-tutorial/test_result.png" title="" class="thickbox" rel="singlepic344" >
	<img class="ngg-singlepic ngg-center" src="http://www.therareair.com/wp-content/gallery/cache/344__460x320_test_result.png" alt="test_result.png" title="test_result.png" />
</a>
</div>
<p>Hope this helped.  If you got lost or just want to check out the files, <a href='http://www.therareair.com/wp-content/uploads/2009/03/icefacestutorial.zip'>here</a> is the Eclipse project used in the tutorial.  Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.therareair.com/2009/03/28/tutorial-how-to-setup-icefaces-for-jboss-50-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tutorial: How to Compile Google Chrome on Leopard</title>
		<link>http://www.therareair.com/2009/01/12/tutorial-how-to-compile-google-chrome-on-leopard/</link>
		<comments>http://www.therareair.com/2009/01/12/tutorial-how-to-compile-google-chrome-on-leopard/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 19:31:05 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.therareair.com/?p=212</guid>
		<description><![CDATA[This is a tutorial to show how to compile Google Chrome on Leopard.  
Download and Install Google Depot Tools
First thing you need to do is get gClient, a tool in Google&#8217;s Depot Tools.  This will help download/sync the latest source code for Chrome.  Open a terminal:

cd Desktop/
svn co http://src.chromium.org/svn/trunk/tools/depot_tools/ depot_tools


This will create [...]]]></description>
			<content:encoded><![CDATA[<p>This is a tutorial to show how to compile Google Chrome on Leopard.  </p>
<h1 class="body">Download and Install Google Depot Tools</h1>
<p>First thing you need to do is get gClient, a tool in Google&#8217;s Depot Tools.  This will help download/sync the latest source code for Chrome.  Open a terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> Desktop<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>src.chromium.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>tools<span style="color: #000000; font-weight: bold;">/</span>depot_tools<span style="color: #000000; font-weight: bold;">/</span> depot_tools</pre></div></div>

<p>
This will create a folder &#8216;depot_tools&#8217; on the desktop.  Move this somewhere you like.  I move this folder into /usr/bin by hitting &#8216;command-shift-g&#8217;, navigating to /usr/bin and dragging this new folder in there.  You will probably need to authenticate as well.  You will need to add this to the $PATH as well.  You do this by going to the terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bashrc</pre></div></div>

<p>
Add: export PATH=$PATH:/usr/bin/depot_tools and exit and save.  Quit the terminal.</p>
<h1 class="body">Download and Compile Google Chrome</h1>
<p>After you have installed Depot Tools the gClient command should now work.  Open up a terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> chrome
<span style="color: #7a0874; font-weight: bold;">cd</span> chrome
gclient config http:<span style="color: #000000; font-weight: bold;">//</span>src.chromium.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>src
gclient <span style="color: #c20cb9; font-weight: bold;">sync</span></pre></div></div>

<p>
If it is your first time downloading the source  it could take a while so grab a drink&#8230;  Later updates you can just run the sync (last command) and it is fairly quick.  After it has completed downloading go to the the terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> src
<span style="color: #7a0874; font-weight: bold;">cd</span> build
xcodebuild <span style="color: #660033;">-project</span> all.xcodeproj <span style="color: #660033;">-target</span> All</pre></div></div>

<p>
You can also open the all.xcodeproj in Xcode if you wish.  After it is complete you will notice a &#8216;Chromium.app&#8217; in the xcodebuild directory in the chrome folder.  That&#8217;s it.  Happy Coding! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.therareair.com/2009/01/12/tutorial-how-to-compile-google-chrome-on-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: How To Compile OpenSSL for the iPhone</title>
		<link>http://www.therareair.com/2009/01/01/tutorial-how-to-compile-openssl-for-the-iphone/</link>
		<comments>http://www.therareair.com/2009/01/01/tutorial-how-to-compile-openssl-for-the-iphone/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 05:29:37 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.therareair.com/?p=181</guid>
		<description><![CDATA[This is a quick tutorial to show you how to minimally compile a version of the openssl and crypto libraries for the iPhone.
Download and Configure OpenSSL
First thing to do is grab the openssl source.  You can get that here.  I&#8217;ll be using openssl-0.9.8i for this demo.  Unzip this file (mines on the desktop).  Open up a [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick tutorial to show you how to minimally compile a version of the openssl and crypto libraries for the iPhone.</p>
<h1 class="body">Download and Configure OpenSSL</h1>
<p>First thing to do is grab the openssl source.  You can get that <a title="here" href="http://www.openssl.org/source/" target="_blank">here</a>.  I&#8217;ll be using openssl-0.9.8i for this demo.  Unzip this file (mines on the desktop).  Open up a terminal and go to the unzipped folder and run the default configuration.  <strong>The argument passed is where your &#8216;make install&#8217; will place the compiled libraries. You should replace this with your path</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> Desktop<span style="color: #000000; font-weight: bold;">/</span>openssl-0.9.8i
.<span style="color: #000000; font-weight: bold;">/</span>config <span style="color: #660033;">--openssldir</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>airpard<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>openssl_arm<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<h1 class="body">Edit the Makefile</h1>
<p>Next thing to do is open up the make file.  This is named &#8220;Makefile&#8221; in the current directory you should already be in with the terminal.  Here are the list of changes to make:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Find <span style="color: #007800;">CC</span>= <span style="color: #c20cb9; font-weight: bold;">cc</span> and change it to:
<span style="color: #007800;">CC</span>= <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gcc-<span style="color: #000000;">4.0</span>
&nbsp;
Find <span style="color: #660033;">-arch</span> i386 <span style="color: #000000; font-weight: bold;">in</span> CFLAG and change it to:
<span style="color: #660033;">-arch</span> armv6
&nbsp;
Find CFLAG and add to the BEGINNING<span style="color: #000000; font-weight: bold;">!!</span>:
<span style="color: #660033;">-isysroot</span> <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS2.2.sdk
&nbsp;
Find <span style="color: #007800;">SHARED_LDFLAGS</span>=-arch i386 <span style="color: #660033;">-dynamiclib</span> and change it to:
<span style="color: #007800;">SHARED_LDFLAGS</span>=-arch armv6 <span style="color: #660033;">-dynamiclib</span></pre></div></div>

<h1 class="body">Fix Build Error</h1>
<p>If you build it at this point you may have noticed a build error. To fix this open up ui_openssl.c. This is located in openssl-0.9.8i/crypto/ui/ folder. If you have a text editor with line numbers, head down to line 403. Otherwise do a text search to make this change:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">static volatile sig_atomic_t intr_signal;
to
static volatile int intr_signal;</pre></div></div>

<p>Save your changes and you should now be able to build with no errors.</p>
<h1 class="body">Build Libraries</h1>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>That&#8217;s it. You&#8217;ll notice that everything was moved to the path provided in step 1 when configuring openssl. Remember to add the include folder to your Xcode project. Also, remember these libraries are only built for the iPhone and will not work in the simulator. You can change all the armv6 references to i386 and build it again if you choose to. Happy Coding!</p>
<h1 class="body">Examples</h1>
<p>Some people had some questions about how to use the libraries in an Xcode project. Here is a simple xcode project including just the linking of the libraries and adding of the header files: <a href="http://www.therareair.com/wp-content/uploads/2009/01/openssl_tutorial.zip">openssl_tutorial</a> (v2.2) <a href="http://www.therareair.com/wp-content/uploads/2009/01/openssl_tutorial3.1.zip">openssl_tutorial</a> (v3.1)</p>
<p>For the lazy people.  Compiled libraries: <a href="http://www.therareair.com/wp-content/uploads/2009/01/compiled_libraries.zip">compiled_libraries</a> (v2.2)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.therareair.com/2009/01/01/tutorial-how-to-compile-openssl-for-the-iphone/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Tutorial: How To Static Analyze Your Objective-C Code Using the Clang Static Analyzer Tool</title>
		<link>http://www.therareair.com/2008/09/26/tutorial-how-to-static-analyze-your-objective-c-code-using-the-clang-static-analyzer-tool/</link>
		<comments>http://www.therareair.com/2008/09/26/tutorial-how-to-static-analyze-your-objective-c-code-using-the-clang-static-analyzer-tool/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 08:01:50 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.therareair.com/?p=74</guid>
		<description><![CDATA[Install LLVM/Clang (Optional)
This tutorial is to show how to use the clang static analyzer tool to automatically find bugs in your objective-c code.  I am going to show you the long but probably better off way by first installing llvm and clang then installing the tool.  Lets get started.
First thing first, go to [...]]]></description>
			<content:encoded><![CDATA[<h1 class="body">Install LLVM/Clang (Optional)</h1>
<p>This tutorial is to show how to use the clang static analyzer tool to automatically find bugs in your objective-c code.  I am going to show you the long but probably better off way by first installing llvm and clang then installing the tool.  Lets get started.<br />
First thing first, go to <a href="http://clang.llvm.org/get_started.html" target="blank">http://clang.llvm.org/get_started.html</a> and read up if you wish.  Otherwise here we go. Open a terminal and svn a current version of llvm down:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>llvm.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>llvm-project<span style="color: #000000; font-weight: bold;">/</span>llvm<span style="color: #000000; font-weight: bold;">/</span>trunk llvm</pre></div></div>

<p>
Next lets configure and make llvm:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> llvm
.<span style="color: #000000; font-weight: bold;">/</span>configure; <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>
This will take a minute to build.  After it&#8217;s completed lets get clang:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> tools
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>llvm.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>llvm-project<span style="color: #000000; font-weight: bold;">/</span>cfe<span style="color: #000000; font-weight: bold;">/</span>trunk clang</pre></div></div>

<p>
After this has been downloaded we need to build this as well:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> clang
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>
From here I like to install llvm and clang into the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>
Now llvm libraries are installed.  We need to install clang now:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> tools
<span style="color: #7a0874; font-weight: bold;">cd</span> clang
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>
Clang should be installed now, so lets test it.  Quit the terminal and open a new one and try this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">clang <span style="color: #660033;">--help</span></pre></div></div>

<p>
If everything worked you get something like this:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/clang-tutorial/Picture 12.png" title="clang --help output" class="thickbox" rel="singlepic301" >
	<img class="ngg-singlepic" src="http://www.therareair.com/wp-content/gallery/cache/301__460x320_Picture 12.png" alt="Picture 12.png" title="Picture 12.png" />
</a>
</div>
<p></bn><br />
</bn></p>
<h1 class="body">Install the Clang Analyzer Tool</h1>
<p>Yes, we didn&#8217;t actually need these things installed to use the static tool but it&#8217;s nice to have.  So now for the static analyzer tool.  You can find a download link here: <a href="http://clang.llvm.org/StaticAnalysis.html" target="blank">http://clang.llvm.org/StaticAnalysis.html</a>.  After you&#8217;ve downloaded the zip unzip it.  Find a place to put these files.  I personally like it in the /usr/bin but it&#8217;s up to you.  Since, I&#8217;m doing the demo I will use that.  So first lets create a directory there:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> objc-analyzer</pre></div></div>

<p>
Then just drag the files from the zipped folder in there.  So it should something like this:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/clang-tutorial/Picture 14.png" title="" class="thickbox" rel="singlepic303" >
	<img class="ngg-singlepic" src="http://www.therareair.com/wp-content/gallery/cache/303__460x320_Picture 14.png" alt="Picture 14.png" title="Picture 14.png" />
</a>
</div>
<p>Almost done, we need to set the bash path to look here.  Simply open the bash profile and export the new path like such:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>profile</pre></div></div>

<p>
And add this to the bottom:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>objc-analyzer<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PATH</pre></div></div>

<p>
Save it and quit the terminal and open a new one.  The analyzer should be working now.  Test it by typing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">scan-build</pre></div></div>

<p>
If everything worked as planned you get some output:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/clang-tutorial/Picture 18.png" title="" class="thickbox" rel="singlepic307" >
	<img class="ngg-singlepic" src="http://www.therareair.com/wp-content/gallery/cache/307__460x320_Picture 18.png" alt="Picture 18.png" title="Picture 18.png" />
</a>
</div>
<p></bn><br />
</bn></p>
<h1 class="body">Run the Clang Analyzer Tool</h1>
<p>Now we are ready to move on to the fun easy stuff.  Find an old project with a lot of bugs and go there in the terminal, clean the project first (yes you need to do this every time), and run scan build.  It was recommended to always use it on the &#8220;Debug&#8221; configuration.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>workspace<span style="color: #000000; font-weight: bold;">/</span>EyeConsoleCD
scan-build xcodebuild <span style="color: #660033;">-configuration</span> Debug clean
scan-build <span style="color: #660033;">-V</span> xcodebuild <span style="color: #660033;">-configuration</span> Debug</pre></div></div>

<p>
This should run and open the report if any bugs were found (-V automatically opens scan-view which opens the report).  Here is what it found in my project:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/clang-tutorial/Picture 21.png" title="" class="thickbox" rel="singlepic310" >
	<img class="ngg-singlepic" src="http://www.therareair.com/wp-content/gallery/cache/310__460x320_Picture 21.png" alt="Picture 21.png" title="Picture 21.png" />
</a>
</div>
<p>Whoa lets take a look at that leak:</p>
<div>
<a href="http://www.therareair.com/wp-content/gallery/clang-tutorial/Picture 25.png" title="" class="thickbox" rel="singlepic314" >
	<img class="ngg-singlepic" src="http://www.therareair.com/wp-content/gallery/cache/314__460x320_Picture 25.png" alt="Picture 25.png" title="Picture 25.png" />
</a>
</div>
<p>No way a real bug <img src='http://www.therareair.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, hope that helped and thanks for reading.  <a href="http://www.therareair.com/howto-static-analyze-your-objective-c-code-using-the-clang-static-analyzer-tool-gallery/" target="_blank">Here&#8217;s</a> the picture tutorial if you don&#8217;t like reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.therareair.com/2008/09/26/tutorial-how-to-static-analyze-your-objective-c-code-using-the-clang-static-analyzer-tool/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
