<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;Dk8NRHoyeSp7ImA9WhRaE0U.&quot;"><id>tag:blogger.com,1999:blog-719917296498716181</id><updated>2012-02-16T01:34:55.491-08:00</updated><title>Dev-P</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://lambdadevp.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://lambdadevp.blogspot.com/" /><author><name>Cacti</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Dev-p" /><feedburner:info uri="dev-p" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CEAAQX07eyp7ImA9WhdWE0o.&quot;"><id>tag:blogger.com,1999:blog-719917296498716181.post-3487719857232196920</id><published>2011-09-06T22:19:00.000-07:00</published><updated>2011-09-06T22:19:00.303-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-06T22:19:00.303-07:00</app:edited><title>JavaScript, HTML5, and Binary Data</title><content type="html">&lt;p&gt;Lately I've been playing around with HTML5 and JavaScript, seeing what new things are possible, and in general honing up on my JS skills (HTML4 and the modern DOM were a long time ago!).&lt;/p&gt;

&lt;p&gt;In the process of all this, I started thinking about binary data and JavaScript, and, likewise, what a waste it is transmitting and manipulating strings EVERYWHERE. Yeah, the compilers and profilers help, as does compression, caches, code minimizers, etc., but still. &lt;p&gt;

&lt;span class="subhead"&gt;
Think about the worst-case, dumbest scenario:&lt;/span&gt;
&lt;span class="tab"&gt;- You're transmitting XML. &lt;br /&gt;
- You're transmitting data verbosely ('attribute="true"' instead of 'a=1').&lt;br /&gt;
- You're only effectively using ASCII (0-127) but you're transmitting in UTF-8 (0-255). &lt;br /&gt;
- You're not using Gzip compression. &lt;br /&gt;
- You're using XMLHttpRequest to poll for data regularly, and, since you don't want older browsers caching it, putting in a random number so you're always getting the data. If your protocol sucks, you may be returning several thousand bytes for "no change" instead of just "0".&lt;br /&gt; 
- Your JS sucks, so you're parsing through that load of data, and all those strings, rather slowly, making too many DOM queries, and bogging things down.
&lt;/span&gt;

&lt;p&gt;
&lt;span class="subhead"&gt;The usual solution(s) is:&lt;/span&gt;
&lt;span class="tab"&gt;
- Use Gzip compression. &lt;br /&gt;
- Use JSON instead of XML. &lt;br /&gt;
- Don't write crap code. &lt;br /&gt;
&lt;/span&gt;&lt;p&gt;
That does the trick for most sites, because, as we all should know, &lt;i&gt;premature optimization is the root of all evil! Just STOP while you're ahead!&lt;/i&gt;

&lt;p&gt;If you want to compress your data further though, and are free to use recent browser versions (this is an important caveat!), what if you want to go further? Use binary!

&lt;p&gt;
&lt;span class="subhead"&gt;
Basic idea:&lt;/span&gt;
&lt;span class="tab"&gt;
- Make sure this is appropriate for your application. You'll likely have to transmit some sort of key for the binary data, so, you'll want to use HTML5 local storage (for your key/js algorithm) to get the most benefit. Or a well-written algorithm. You can also depend on the cache if you have to, but that'll only get you so far. HTML5 local storage will serve as your traditional library, so to speak.&lt;br /&gt;
- On the server, fit the data into a PNG file format. Grayscale, 8 bits per channel, no alpha. &lt;br /&gt;
- On the client, create a &amp;lt;canvas&amp;gt; element. Make sure it's hidden. &lt;br /&gt;
- Use XMLHttpRequest to get the PNG file with the data and write it to the &amp;lt;canvas&amp;gt; element. &lt;br /&gt;
- In this case, each pixel on the &amp;lt;canvas&amp;gt; is a byte. Read the pixel, translate it to binary, and do whatever conversions you need to do.&lt;br /&gt;
- Optionally, if this is a very large data set, considering using the HTML5 &amp;lt;canvas&amp;gt; compositing methods to perform your XOR and bit-wise AND operations. Hopefully this will take advantage of the GPU acceleration! &lt;br /&gt;
&lt;/span&gt;&lt;p&gt;

&lt;span class="subhead"&gt;
Details:&lt;/span&gt;
&lt;span class="tab"&gt;
1) Generate the PNG file on the server. In this case, we are going to encode 4 bits (acting as flags). Naturally, you'll want to encode more than this because the PNG headers and file structure takes a minimum of 67 bytes! &lt;/span&gt;&lt;p&gt;

&lt;span class="tab"&gt;
&lt;b&gt;Note&lt;/b&gt;: I originally learned this idea from &lt;a href="http://garethrees.org/2007/11/14/pngcrush/"&gt;garethrees.org&lt;/a&gt;. It's a great source. You will also want to look at &lt;a href="http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html"&gt;libpng.org&lt;/a&gt; and &lt;a href="http://www.w3.org/TR/PNG/"&gt;w3.org&lt;/a&gt; for more detailed specs.&lt;/span&gt;&lt;p&gt;

&lt;span class="tab"&gt;In general, we can create a grayscale PNG file, with no alpha, 8 bits per channel, and everything else on default settings, and this will effectively result in each pixel being 8 bits. I've been working on this with a Python server, so:&lt;/span&gt;&lt;p&gt;

&lt;b&gt;Python example&lt;/b&gt;:&lt;p&gt;
&lt;div class="code"&gt;import struct, zlib

def chunk(type, data):
    &lt;span class="comment"&gt;# pack in big-endian order. format for a PNG chunk is:
    # [length of &lt;b&gt;data&lt;/b&gt; in chunk] [chunk &lt;b&gt;type&lt;/b&gt;] [&lt;b&gt;data&lt;/b&gt;] [&lt;b&gt;crc&lt;/b&gt; checksum on &lt;b&gt;data&lt;/b&gt;]&lt;/span&gt;
    return (struct.pack('&gt;I', len(data)) + type + data +
            struct.pack('&gt;i', zlib.crc32(type + data)))

      
png = ('\x89PNG\r\n\x1A\n' +    # PNG magic number
       &lt;span class="comment"&gt;# 1 = width, 1 = height, 8 = 8bit channel, 0 = color type (grayscale), 0 = compression method (standard, aka, zlib), 0 = filter method (standard), 0 = interlace method (none)&lt;/span&gt;
       chunk('IHDR', struct.pack('&gt;IIBBBBB', 1, 1, 8, 0, 0, 0, 0)) +
       &lt;span class="comment"&gt;# data. first byte is required (0=default filter). 14 = 1110 in binary, what we are trying to send over&lt;/span&gt;
       chunk('IDAT', zlib.compress(struct.pack('&gt;BBB', 0, 14))) +
       chunk('IEND', ''))
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;
&lt;span class="tab"&gt;
2) On the client, figure out a way to get to this file. Typically you'd use a XMLHTTPRequest to ask for the file, and the server send it over. Stuff it into an Image object. For the example here, I am going to assume you have a local PNG file you can read in just for testing purposes. &lt;/span&gt;&lt;br /&gt;

&lt;div class="code"&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
window.addEventListener("load", eventWindowLoaded, false);
function eventWindowLoaded () {
   canvas = document.getElementById("canvas_test")
   context = canvas.getContext("2d")
   i = new Image()
   i.src="test.png"
   i.onload = function() {
     &lt;span class="comment"&gt;// TODO&lt;/span&gt;
   }
}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;canvas id="canvas_test_"&amp;gt;&amp;lt;canvas&amp;gt;&lt;/div&gt;
&lt;p&gt;

&lt;span class="tab"&gt;
3) Write the Image object to the canvas.
&lt;/span&gt;
&lt;div class="code"&gt;&lt;span class="comment"&gt;// STARTING FROM THE "TODO" SECTION ABOVE&lt;/span&gt;
context.drawImage(i, 0, 0)   &lt;span class="comment"&gt;// write the PNG to the CANVAS&lt;/span&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;span class="tab"&gt;
4) Read back the pixel data in the canvas to figure out the bytes. Convert this to binary.
&lt;div class="code"&gt;d = context.getImageData(0, 0, 1, 1)  &lt;span class="comment"&gt;// just one pixel (1, 1)&lt;/span&gt;
d.data[0] &lt;span class="comment"&gt;// pixel values from &amp;lt;canvas&amp;gt; come in 4 bytes (r, g, b, a). in our case [0] (and [0+i*4]) give us the data&lt;/span&gt;
d.data[0].toString(2) &lt;span class="comment"&gt;// this is your binary string
// you can also go from here and use bit operations to decode your data
// or, instead of doing that, create a &amp;lt;canvas&amp;gt; image object that
// has your bitwise operations on it and go to town!&lt;/span&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/719917296498716181-3487719857232196920?l=lambdadevp.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ryNCxqRZ3ymADjJOmhuri3M7vd8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ryNCxqRZ3ymADjJOmhuri3M7vd8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ryNCxqRZ3ymADjJOmhuri3M7vd8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ryNCxqRZ3ymADjJOmhuri3M7vd8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Dev-p/~4/6OvDHEAoVgE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://lambdadevp.blogspot.com/feeds/3487719857232196920/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://lambdadevp.blogspot.com/2011/09/javascript-html5-and-binary-data.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/719917296498716181/posts/default/3487719857232196920?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/719917296498716181/posts/default/3487719857232196920?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Dev-p/~3/6OvDHEAoVgE/javascript-html5-and-binary-data.html" title="JavaScript, HTML5, and Binary Data" /><author><name>Cacti</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://lambdadevp.blogspot.com/2011/09/javascript-html5-and-binary-data.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcDSHw9eSp7ImA9Wx9VFE4.&quot;"><id>tag:blogger.com,1999:blog-719917296498716181.post-6689506276135296422</id><published>2010-11-13T19:01:00.000-08:00</published><updated>2011-01-30T17:07:59.261-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-30T17:07:59.261-08:00</app:edited><title>Creating an iPhone App "From Scratch"</title><content type="html">&lt;b&gt;Current as of:&lt;/b&gt; ~Jan. 2011 (iOS 4.2 and XCode 3.2.5).&lt;br/&gt;
&lt;b&gt;Download&lt;/b&gt; &lt;a href="https://github.com/llamarama/BasiciPhoneApp"&gt;source code&lt;/a&gt;.&lt;br/&gt;&lt;p&gt;

This tutorial explains how to compile, build, and deploy to the Simulator an iPhone application without using Xcode or Interface Builder. I don't claim that this is the best way to go about developing without Xcode/IB, but, it works well for me.&lt;p&gt;

I will attempt to explain things as I go along, however, you'd best be advised to &lt;u&gt;read through the code&lt;/u&gt; and, in particular, &lt;u&gt;read the comments in the code&lt;/u&gt;. &lt;p&gt;


&lt;span class="tab"&gt;&lt;b&gt;Pros (subjective!)&lt;/b&gt;:
&lt;span class="tab"&gt;- Better grasp of the basics and what's "under the hood".&lt;br /&gt;
- More control over the build process and the user interface.&lt;br /&gt;
- Possibly better integration with standard Unix development tools.&lt;br /&gt;
- Less reliance on the mouse. Useful as I sometimes develop on a Netbook where the UI/mouse is a real pain. Allows for more efficient development with, say, just a fullscreen emacs and fullscreen terminal, which also fits my development tools on other platforms.&lt;br /&gt;
- Lack of dependence on Xcode toolsuite.&lt;br /&gt;
- Probably others.&lt;/span&gt;
&lt;/span&gt;&lt;p&gt;

&lt;span class="tab"&gt;
&lt;b&gt;Cons (subjective!)&lt;/b&gt;:
&lt;span class="tab"&gt;- No Xcode benefits such as "intellisense" (though some editors support this). &lt;/span&gt;
&lt;span class="tab"&gt;- Syntax highlighting and formatting dependent on your editor (though almost all editors support this).&lt;/span&gt;
&lt;span class="tab"&gt;- Debugging probably both more complicated and more labor-intensive.&lt;/span&gt;
&lt;span class="tab"&gt;- Probably others.&lt;/span&gt;
&lt;/span&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;b&gt;TO DO&lt;/b&gt;:
&lt;span class="tab"&gt;- Figure out how to script the simulator to start an app automatically on launch.
- Improve the monitoring of the NSLog log file (probably with a &lt;code&gt;tail&lt;/code&gt; script).&lt;/span&gt;&lt;span class="tab"&gt;- Add some scripts and pre-processor macros for GDB integration.&lt;/span&gt;&lt;span class="tab"&gt;- Figure out how to use a Prefix file for common includes&lt;/span&gt;&lt;span class="tab"&gt;- Determine minimum entries required in Info.plist.&lt;/span&gt;&lt;span class="tab"&gt;- Determine the absolute minimum compilation and linking flags and variables.&lt;/span&gt;&lt;span class="tab"&gt;- Put together a Makefile and script for deployment to an iPhone.&lt;/span&gt;&lt;span class="tab"&gt;- Change &lt;code&gt;$DIR&lt;/code&gt; var in Makefile to not use &lt;code&gt;pwd&lt;/code&gt;.&lt;/span&gt;&lt;span class="tab"&gt;- Determine why "User" and "OS" deployment locations differ.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;
&lt;div class="code"&gt;&lt;b&gt;CHANGES&lt;/b&gt;:
&lt;span class="tab"&gt;8.9.2010 - N/A. Initial release.&lt;/span&gt;&lt;span class="tab"&gt;1.29.2011 - Updated for iOS 4.2. (minor bug fix in Makefile)&lt;/span&gt;&lt;/div&gt;

&lt;p&gt;&lt;span class="subhead"&gt;Contents&lt;/span&gt;&lt;div style="white-space: pre;"&gt;&lt;span class="tab"&gt;1. &lt;a href="#app"&gt;The App Proper&lt;/a&gt;
2. &lt;a href="#info"&gt;The Info.plist&lt;/a&gt;
3. &lt;a href="#compile"&gt;Compiling&lt;/a&gt;
4. &lt;a href="#linking"&gt;Linking&lt;/a&gt;
5. &lt;a href="#deploy"&gt;Deploying&lt;/a&gt;
6. &lt;a href="#all"&gt;Pulling it all Together, Draft 1&lt;/a&gt;
7. &lt;a href="#nslog"&gt;Improving NSLog&lt;/a&gt; &lt;i&gt;TBD&lt;/i&gt;. See note below.
8. &lt;a href="#makefile"&gt;Improving the Makefile&lt;/a&gt; &lt;i&gt;TBD&lt;/i&gt;. See note below.
9. &lt;a href="#all2"&gt;Putting it all Together, Draft 2&lt;/a&gt; &lt;i&gt;TBD&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt; 


&lt;a name="app"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;1. The App Proper&lt;/span&gt;
Files: &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/main.m"&gt;main.m&lt;/a&gt; &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/BasicApp.m"&gt;BasicApp.m&lt;/a&gt; &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/BasicApp.h"&gt;BasicApp.h&lt;/a&gt;&lt;p&gt;

Though technically it is not necessary to seperate these files, it is rather wise to do so as a foundation for a larger application where such partitioning is necessary. These files constitute what is just shy of the absolute minimum for an iPhone app using the standard Apple framework.&lt;p&gt;

These files are pretty straight-forward. First, we create a basic entry point (&lt;code&gt;main.m&lt;/code&gt;), then tell it to go grab our &lt;i&gt;application delegate&lt;/i&gt;, a basic class that inherits a protocol from &lt;a href="http://developer.apple.com/iphone/library/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html"&gt;UIApplicationDelegate&lt;/a&gt; (&lt;code&gt;BasicApp.m/.h&lt;/code&gt;). Our class, in turn, programatically creates a &lt;a href="http://developer.apple.com/iphone/library/documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html"&gt;UIWindow&lt;/a&gt; with a basic &lt;a href="http://developer.apple.com/iphone/library/documentation/uikit/reference/UIView_Class/UIView/UIView.html"&gt;UIView&lt;/a&gt; attached, sets a background color for the view, and displays the window. &lt;b&gt;Done.&lt;/b&gt;&lt;p&gt;


&lt;b&gt;main.m&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;

&lt;span class="class"&gt;int&lt;/span&gt; &lt;span class="func"&gt;main&lt;/span&gt; (&lt;span class="class"&gt;int&lt;/span&gt; &lt;span class="var"&gt;argc&lt;/span&gt;, &lt;span class="class"&gt;char&lt;/span&gt; &lt;span class="var"&gt;*argv[]&lt;/span&gt;) &lt;b&gt;{&lt;/b&gt;
     &lt;span class="class"&gt;NSAutoreleasePool&lt;/span&gt; &lt;span class="var"&gt;*pool&lt;/span&gt; = [[&lt;span class="class"&gt;NSAutoreleasePool&lt;/span&gt; &lt;span class="func"&gt;alloc&lt;/span&gt;] &lt;span class="func"&gt;init&lt;/span&gt;];
     &lt;span class="comment"&gt;// Start up the application and point it's delegate to our BasicAppDelegate class
     // (&lt;code&gt;BasicApp.m/.h&lt;/code&gt;). UIApplicationMain(int argc, char *argv[], 
     // NSString *principalClassName, NSString *delegateClassName) &lt;/span&gt;
     &lt;span class="class"&gt;int&lt;/span&gt; &lt;span class="var"&gt;r&lt;/span&gt; = &lt;span class="func"&gt;UIApplicationMain&lt;/span&gt;(argc, argv, @"UIApplication", @"BasicAppDelegate");
     [pool &lt;span class="func"&gt;release&lt;/span&gt;];
     return r;
&lt;b&gt;}&lt;/b&gt;&lt;/code&gt;&lt;/div&gt;&lt;p&gt;

&lt;b&gt;BasicApp.h&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;

&lt;span class="int_imp"&gt;@interface BasicAppDelegate&lt;/span&gt;: &lt;span class="class"&gt;NSObject&lt;/span&gt; &lt;uiapplicationdelegate&gt; &lt;b&gt;{&lt;/b&gt;
     &lt;span class="comment"&gt;// These are the class variables we will use for our UIWindow and UIView objects.
     // We could have just as easily declared these in &lt;code&gt;BasicApp.m&lt;/code&gt; but decided not to. 
     // Your call. &lt;/span&gt;
     &lt;span class="class"&gt;UIWindow&lt;/span&gt; &lt;span class="var"&gt;*mainWindow&lt;/span&gt;;
     &lt;span class="class"&gt;UIView&lt;/span&gt; &lt;span class="var"&gt;*mainView&lt;/span&gt;;
&lt;b&gt;}&lt;/b&gt;

     &lt;span class="comment"&gt;// The UIApplicationDelegate protocol requires you implement this function. 
     // It will return our main UIWindow so the application (UIApplicationMain from &lt;code&gt;main.m&lt;/code&gt;) 
     // knows where to start.&lt;/span&gt;
     - (&lt;span class="class"&gt;UIWindow *&lt;/span&gt;) &lt;span class="func"&gt;getMainWindow&lt;/span&gt;;

&lt;span class="int_imp"&gt;@end&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;p&gt;

&lt;b&gt;BasicApp.m&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;#import "BasicApp.h"

&lt;span class="int_imp"&gt;@implementation BasicAppDelegate&lt;/span&gt;
     - (&lt;span class="class"&gt;void&lt;/span&gt;) &lt;span class="func"&gt;applicationDidFinishLaunching&lt;/span&gt;: (&lt;span class="class"&gt;UIApplication *&lt;/span&gt;) &lt;span class="var"&gt;application&lt;/span&gt; &lt;b&gt;{&lt;/b&gt;
     &lt;span class="comment"&gt;// Note that &lt;code&gt;mainScreen&lt;/code&gt; is a class method that returns the device's screen 
     // and is provided by the platform by default. &lt;/span&gt;

     &lt;span class="comment"&gt;// Create the window and set it's size to the maximum.&lt;/span&gt;
     mainWindow = [[&lt;span class="class"&gt;UIWindow&lt;/span&gt; &lt;span class="func"&gt;alloc&lt;/span&gt;] &lt;span class="func"&gt;initWithFrame&lt;/span&gt;: [[&lt;span class="class"&gt;UIScreen&lt;/span&gt; &lt;span class="func"&gt;mainScreen&lt;/span&gt;] &lt;span class="func"&gt;bounds&lt;/span&gt;]];

     &lt;span class="comment"&gt;// Determine the max size allowed for the view. This is based off of the application  
     // size. This should be something like the max size minus the status bar up top.&lt;/span&gt;
     mainView = [[&lt;span class="class"&gt;UIView&lt;/span&gt; &lt;span class="func"&gt;alloc&lt;/span&gt;] &lt;span class="func"&gt;initWithFrame&lt;/span&gt;: [[&lt;span class="class"&gt;UIScreen&lt;/span&gt; &lt;span class="func"&gt;mainScreen&lt;/span&gt;] &lt;span class="func"&gt;applicationFrame&lt;/span&gt;]];

     &lt;span class="comment"&gt;// Add the view to our window and set the color of the view 
     // (the color change is really only necessary to make it more obvious 
     // that we've succeeded).&lt;/span&gt;
     [mainWindow &lt;span class="func"&gt;addSubview&lt;/span&gt;: mainView];
     [mainView &lt;span class="func"&gt;setBackgroundColor&lt;/span&gt;: [&lt;span class="class"&gt;UIColor&lt;/span&gt; lightGrayColor]];

     &lt;span class="comment"&gt;// Display the window and make it the "key" window. The "key" window is the one  
     // that will receive user input. &lt;/span&gt;
     [mainWindow &lt;span class="func"&gt;makeKeyAndVisible&lt;/span&gt;];
&lt;b&gt;}&lt;/b&gt;

&lt;b&gt;-&lt;/b&gt; (&lt;span class="class"&gt;void&lt;/span&gt;) &lt;span class="func"&gt;applicationWillTerminate&lt;/span&gt; &lt;b&gt;{&lt;/b&gt;
     [mainWindow &lt;span class="func"&gt;release&lt;/span&gt;];
&lt;b&gt;}&lt;/b&gt;

- (&lt;span class="class"&gt;UIWindow *&lt;/span&gt;) &lt;span class="func"&gt;getMainWindow&lt;/span&gt; &lt;b&gt;{&lt;/b&gt;
     return mainWindow;
&lt;b&gt;}&lt;/b&gt;

&lt;span class="int_imp"&gt;@end&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;


&lt;a name="info"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;2. The Info.plist&lt;/span&gt;
Files: &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/Info.plist"&gt;Info.plist&lt;/a&gt;&lt;p&gt;
An application under iOS/OSX usually consists of more than the application binary. In reality a ".app" is a directory with a specific structure. For example, when we finish, our application bundle will look like this:&lt;p&gt;

&lt;b&gt;.app is a directory&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;&lt;b&gt;~/BasicApp.app &amp;gt;&lt;/b&gt; ls -l
total 20
-rwx------+ 1 user domain group  15384  2010-08-08 18:51  &lt;span style="color: green;"&gt;BasicApp&lt;/span&gt;
-rwx------+ 1 user domain group    806  2010-08-08 18:51  &lt;span style="color: green;"&gt;Info.plist&lt;/span&gt;
&lt;b&gt;~/BasicApp.app &amp;gt;&lt;/b&gt;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;
If you examine other applications, you will notice plenty of other items, such as sub-directories for cache, images, data, screenshots, etc., however, the minimum requirements for an iPhone app are a) the application binary and b) the Info.plist. 
&lt;p&gt;

When you copy an app onto the Simulator, the Simulator interrogates the Info.plist to determine things such as what the application name is, what the binary is to launch, what kind of region the app was designed for, any special styles you want to apply, the version number, etc. There are many options for the Info.plist, however, the important ones are &lt;code&gt;CFBundleExecutable&lt;/code&gt; and &lt;code&gt;CFBundleIdentifier&lt;/code&gt;.
&lt;p&gt;


The Info.plist is just XML, however, one thing to keep in mind is that &lt;u&gt;the iPhone can accept either a binary "compiled" Info.plist or just a plain text plist&lt;/u&gt;. Xcode by default uses a compiled plist while we will use a regular text one (mostly because I can't really be bothered to figure out the compilation step ;)).
&lt;p&gt;

&lt;b&gt;Info.plist&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE plist PUBLIC 
             "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&amp;gt;

&amp;lt;plist version="1.0"&amp;gt;
     &amp;lt;dict&amp;gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundleDevelopmentRegion&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;English&lt;/span&gt;&amp;lt;/string&amp;gt;

          &lt;span class="comment"&gt;&amp;lt;!-- CFBundleExecutable needs to be the name of the actual application binary, 
          which, in this example, is BasicApp. --&amp;gt;&lt;/span&gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundleExecutable&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;BasicApp&lt;/span&gt;&amp;lt;/string&amp;gt;

          &lt;span class="comment"&gt;&amp;lt;!-- CFBundleIdentifier needs to be a UNIQUE name for your app. This is
          not the same thing as the display name.  --&amp;gt;&lt;/span&gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundleIdentifier&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;com.whatever.SecondTest&lt;/span&gt;&amp;lt;/string&amp;gt;

          &lt;span class="comment"&gt;&amp;lt;!-- This stuff is rather meaningless. Not sure yet if required. --&amp;gt;&lt;/span&gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundleInfoDictionaryVersion&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;6.0&lt;/span&gt;&amp;lt;/string&amp;gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundlePackageType&lt;/span&gt;&amp;lt;/key&amp;gt;

          &amp;lt;string&amp;gt;&lt;span class="var"&gt;APPL&lt;/span&gt;&amp;lt;/string&amp;gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundleSignature&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;????&lt;/span&gt;&amp;lt;/string&amp;gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;CFBundleVersion&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;1.0&lt;/span&gt;&amp;lt;/string&amp;gt;

          &lt;span class="comment"&gt;&amp;lt;!-- These are optional settings that define look-and-feel. 
          Things like this can usually be set in the application code, however, those 
          statements will not be executed until the application is run. These settings 
          take effect &lt;i&gt;before&lt;/i&gt; your application is ever displayed. --&amp;gt;&lt;/span&gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;UIStatusBarHidden&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;&lt;span class="var"&gt;false&lt;/span&gt;/&amp;gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;UIStatusBarStyle&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;UIStatusBarStyleBlackTranslucent&lt;/span&gt;&amp;lt;/string&amp;gt;
          &amp;lt;key&amp;gt;&lt;span class="class"&gt;UIViewEdgeAntialiasing&lt;/span&gt;&amp;lt;/key&amp;gt;
          &amp;lt;string&amp;gt;&lt;span class="var"&gt;YES&lt;/span&gt;&amp;lt;/string&amp;gt;
     &amp;lt;/dict&amp;gt;
&amp;lt;/plist&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;

&lt;a name="compile"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;3. Compiling&lt;/span&gt;Xcode doesn't do anything very mysterious here. After all, this is just Unix, and it is using mostly standard Unix applications. However, rather than delve too deep into the specifics of &lt;code&gt;gcc&lt;/code&gt; and build up the compilation step by hand, we will take the easy way out: &lt;i&gt;cheat!&lt;/i&gt;&lt;p&gt;

It turns out that all Xcode is really doing is using the &lt;code&gt;xcodebuild&lt;/code&gt; application, which is sort of Apple's replacement for &lt;code&gt;make&lt;/code&gt;. Not only that, but &lt;code&gt;xcodebuild&lt;/code&gt; can actually be quite verbose and tell you exactly how it is going about it's business (you can see the same info in an Xcode window but I find the command line to be clearer). &lt;p&gt;


&lt;u&gt;Try this&lt;/u&gt;: go create a new default app in Xcode, save it, build it, and run it. Pretty straight-forward, right? Now, quit Xcode, navigate to the directory of the new app, and run &lt;code&gt;xcodebuild&lt;/code&gt; to see what is going on (you may have to run &lt;code&gt;xcodebuild clean&lt;/code&gt; first):&lt;p&gt;

&lt;b&gt;Part of the compilation output from xcodebuild&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;CompileC build/Untitled.build/Release-iphonesimulator/Untitled.build/Objects-normal/i386/UntitledAppDelegate.o Classes/UntitledAppDelegate.m normal i386 objective-c com.apple.compilers.gcc.4_2
    cd /Users/x/Documents/Untitled
    setenv LANG en_US.US-ASCII
    &lt;u&gt;setenv PATH&lt;/u&gt; "&lt;u&gt;/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin&lt;/u&gt;:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin"
    &lt;u&gt;/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2&lt;/u&gt; -x objective-c &lt;u&gt;-arch i386&lt;/u&gt; -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 &lt;u&gt;-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk&lt;/u&gt; -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/Untitled-generated-files.hmap -I/Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/Untitled-own-target-headers.hmap -I/Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/Untitled-all-target-headers.hmap -iquote /Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/Untitled-project-headers.hmap -F/Users/x/Documents/Untitled/build/Release-iphonesimulator -I/Users/x/Documents/Untitled/build/Release-iphonesimulator/include -I/Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/DerivedSources/i386 -I/Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/DerivedSources -DNS_BLOCK_ASSERTIONS=1 -include /var/folders/Yv/YvDzynCUEIaYVYJCCeIbHU+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/Untitled_Prefix-bzdssktcospdfwenxzjipogpifzt/Untitled_Prefix.pch &lt;u&gt;-c /Users/x/Documents/Untitled/Classes/UntitledAppDelegate.m -o /Users/x/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/Objects-normal/i386/UntitledAppDelegate.o&lt;/u&gt;&lt;/code&gt;
&lt;/div&gt;

&lt;p&gt;So, the idea goes, if we examine this output, we can figure out what all the required compilation steps and flags are and assemble them into some start of the venerable &lt;code&gt;Makefile&lt;/code&gt;.&lt;p&gt;


&lt;b&gt;Beginnings of a Makefile&lt;/b&gt;&lt;div class="code"&gt;&lt;code&gt;&lt;span class="comment"&gt;# First-off, it looks like we need to set the PATH, so we'll just copy that over from 
# &lt;code&gt;xcodebuild&lt;/code&gt;. Note that it is including the standard Unix bin directories 
# as well as the iPhone Platform directories.&lt;/span&gt;
&lt;span class="var"&gt;PATH&lt;/span&gt;=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin: \
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin: \
/Developer/usr/bin:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin

&lt;span class="comment"&gt;# Second, we need to set the platform (not sure if this is required).&lt;/span&gt;
&lt;span class="var"&gt;MACOSX_DEPLOYMENT_TARGET&lt;/span&gt;=10.6

&lt;span class="comment"&gt;# Third, by examining the beginning of the &lt;code&gt;xcodebuild&lt;/code&gt; output, it looks like the compiler
# that's being used is gcc 4.2. We will use absolute pathing just to be sure. Note this is a  
# different location than some previous Xcode versions.&lt;/span&gt;
&lt;span class="var"&gt;CC&lt;/span&gt;=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2

&lt;span class="comment"&gt;# Now we need to dig into the &lt;code&gt;gcc-4.2&lt;/code&gt; flags. It doesn't really matter what these flags stand
# for, provided we make sure there's nothing glaringly wrong, since we are just copying 
# &lt;code&gt;xcodebuild&lt;/code&gt; to be safe. Note, however, that we are compiling for the Simulator 
# (i.e., local computer, i.e., 386) and that we have to point to the Simulator
# SDK. If you are going to compile for deployment these flags WILL change.&lt;/span&gt;
&lt;span class="var"&gt;CFLAGS&lt;/span&gt;=-x objective-c -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs \
-fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -Wreturn-type -Wunused-variable \
-D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 \
-DNS_BLOCK_ASSERTIONS=1 \
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk \
-fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 \
-fobjc-abi-version=2 -fobjc-legacy-dispatch 

&lt;span class="comment"&gt;# Of course, we also need to define which source files are going to be included in our binary!&lt;/span&gt;
&lt;span class="var"&gt;SRCS&lt;/span&gt; = \
     main.m \
     BasicApp.m&lt;/code&gt;&lt;/div&gt;

&lt;p&gt;Now, there are some other things that &lt;code&gt;xcodebuild&lt;/code&gt; is doing here on the compilation step, but they are not required, so we will skip them for now. 
&lt;p&gt;
&lt;a name="linking"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;4. Linking&lt;/span&gt;

Similar to the compiling step above, we will examine the output of &lt;code&gt;xcodebuild&lt;/code&gt; to put together the linking portion of the &lt;code&gt;Makefile&lt;/code&gt;. The linking step will assemble the individually compiled source files from above and combine them into an actual application binary.
&lt;p&gt;
&lt;b&gt;Example linking output from xcodebuild&lt;/b&gt;&lt;div class="code"&gt;&lt;code&gt;Ld build/Release-iphonesimulator/Untitled.app/Untitled normal i386
    cd /Users/p/Documents/Untitled
    setenv MACOSX_DEPLOYMENT_TARGET 10.5
    &lt;u&gt;setenv PATH&lt;/u&gt; "&lt;u&gt;/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin&lt;/u&gt;:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin"
    &lt;u&gt;/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2&lt;/u&gt; -arch i386 &lt;u&gt;-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk&lt;/u&gt; &lt;u&gt;-L/Users/p/Documents/Untitled/build/Release-iphonesimulator -F/Users/p/Documents/Untitled/build/Release-iphonesimulator&lt;/u&gt; -filelist /Users/p/Documents/Untitled/build/Untitled.build/Release-iphonesimulator/Untitled.build/Objects-normal/i386/Untitled.LinkFileList -mmacosx-version-min=10.5 &lt;u&gt;-Xlinker&lt;/u&gt; -objc_abi_version &lt;u&gt;-Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/p/Documents/Untitled/build/Release-iphonesimulator/Untitled.app/Untitled&lt;/u&gt;&lt;/code&gt;
&lt;/div&gt;

&lt;p&gt;If we example this output we can determine what sort of flags, commands, and variables are necessary to properly link an iPhone app together.


&lt;p&gt;&lt;b&gt;Additions to our Makefile&lt;/b&gt;&lt;div class="code"&gt;&lt;code&gt;&lt;span class="comment"&gt;# First, we'll just define a convenience variable to hold our directory. This probably
# should be changed from &lt;code&gt;pwd&lt;/code&gt; in case the &lt;code&gt;Makefile&lt;/code&gt; is 
# executed outside of the directory.&lt;/span&gt;
&lt;span class="var"&gt;DIR&lt;/span&gt;:=$(shell pwd)

&lt;span class="comment"&gt;# We are not going to call the linker directly. Instead we will ask gcc to invoke the linker. 
# This is why some of the flags here look similar to the compilation step. The most importing 
# thing here, other than calling the linker, is to set &lt;code&gt;isysroot&lt;/code&gt; to the Simulator SDK and to 
# make sure that we are including all the necessary frameworks. If you build off of this app 
# you will likely need to add  additional frameworks here as you add additional features. 
#
# NOTE: these flags (in particular, the framework flags) require the PATH set as per above! &lt;/span&gt;
&lt;span class="var"&gt;LDFLAGS&lt;/span&gt;=-arch i386 -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 \
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk \
-L$(DIR) \
-F$(DIR) \
-framework Foundation \
-framework UIKit \
-framework CoreGraphics

&lt;span class="comment"&gt;# This is a standard &lt;code&gt;make&lt;/code&gt; substitution command using the &lt;code&gt;SRCS&lt;/code&gt; variable that was defined 
# above. In other words, our compiled objects are the same as the source files, but with 
# &lt;code&gt;.o&lt;/code&gt; extension instead of &lt;code&gt;.m&lt;/code&gt;. &lt;/span&gt;
&lt;span class="var"&gt;OBJS&lt;/span&gt; := $(SRCS:.m=.o)&lt;/code&gt;&lt;/div&gt;




&lt;a name="deploy"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;5. Deploying&lt;/span&gt;The iPhone Simulator has a local file system where it stores, among other things, the applications. Any valid application copied to this location will show up on the Simulator home screen when you launch the Simulator. There are two locations for applications, one at the user level and one at the "OS" level:&lt;p&gt;

&lt;span class="tab"&gt;- &lt;code&gt;~/Library/Application\ Support/iPhone\ Simulator/4.0/Applications/&lt;/code&gt;&lt;/span&gt;
&lt;span class="tab"&gt;- &lt;code&gt;~/Library/Application\ Support/iPhone\ Simulator/User/Applications/&lt;/code&gt;&lt;/span&gt;
&lt;p&gt;

I have come across problems before, for reasons yet unknown, using the "User" directory so I use the "OS" directory. It doesn't really matter so go with whatever works.&lt;p&gt;

&lt;b&gt;Some Makefile additions&lt;/b&gt;&lt;div class="code"&gt;&lt;code&gt;&lt;span class="comment"&gt;# The location of the Simulator. This will be different if you are using a
# previous SDK version.&lt;/span&gt;
&lt;span class="var"&gt;SIMULATOR&lt;/span&gt;=/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app

&lt;span class="comment"&gt;# Location where to deploy the application to for the Simulator.&lt;/span&gt;
&lt;span class="var"&gt;APPDIR&lt;/span&gt;=~/Library/Application\ Support/iPhone\ Simulator/4.0/Applications/&lt;/code&gt;&lt;/div&gt;

&lt;p&gt;There is really only one last required step to deploy to the Simulator: setting up the file structure of the app.


&lt;p&gt;
Above we examined the file structure of a standard ".app". Our file structure for deployment will be the same with one addition: a parent directory who's name is a &lt;a href="http://en.wikipedia.org/wiki/Universally_unique_identifier"&gt;UUID&lt;/a&gt;. This unique identifier allows one to deploy multiple versions of the same app on a phone while still being able to keep them distinct. There don't seem to be any real rules regarding the generation of this UUID (the formula can accept a value as the seed/hash but it is not necessary). It can remain constant or it can change on every compilation, whichever you prefer (Xcode changes it on every fresh build/deploy).
&lt;p&gt;
Fortunately there is a standard function on OSX to generate a UUID:&lt;p&gt;

&lt;div class="code"&gt;&lt;code&gt;&lt;b&gt;~/BasicApp &amp;gt;&lt;/b&gt; /usr/bin/uuidgen
4663FCE9-0675-432B-8390-1E17D122859C
&lt;b&gt;~/BasicApp &amp;gt;&lt;/b&gt;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;
Since this will be the parent directory, our final file structure for deployment will look like:
&lt;div class="code"&gt;&lt;code&gt;(dir) &lt;b&gt;4663FCE9-0675-432B-8390-1E17D122859C&lt;/b&gt;
(dir) ... &lt;b&gt;BasicApp.app&lt;/b&gt;
          ... BasicApp
          ... Info.plist&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;
Copy this to one of the Simulator deployment locations listed above and start the simulator!
&lt;p&gt;
&lt;a name="all"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;6. Putting It All Together (Draft 1)&lt;/span&gt;
File: &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/Makefile"&gt;Makefile&lt;/a&gt;&lt;p&gt;

Below is the first draft of our &lt;code&gt;Makefile&lt;/code&gt;. Essentially it includes all of the steps listed above plus a few more to actually make it do something. As long as you have &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/main.m"&gt;main.m&lt;/a&gt;, &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/BasicApp.m"&gt;BasicApp.m&lt;/a&gt;, &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/BasicApp.h"&gt;BasicApp.h&lt;/a&gt;, and &lt;a href="https://github.com/llamarama/BasiciPhoneApp/blob/master/Info.plist"&gt;Info.plist&lt;/a&gt; all in the same directory as this &lt;code&gt;Makefile&lt;/code&gt;, you should be good to go. Just run either &lt;code&gt;make&lt;/code&gt; (to build and deploy), &lt;code&gt;make clean&lt;/code&gt; (clean out local build files and the app files on the Simulator), or &lt;code&gt;make sim&lt;/code&gt; (start the simulator).

&lt;p&gt;
&lt;b&gt;Makefile, Draft 1&lt;/b&gt;
&lt;div class="code"&gt;&lt;code&gt;&lt;span class="comment"&gt;# Edit this config info below.&lt;/span&gt;

&lt;span class="var"&gt;APPNAME&lt;/span&gt;=BasicApp
&lt;span class="comment"&gt;# use /usr/bin/uuidgen to generate a unique UUID for this app&lt;/span&gt;
&lt;span class="var"&gt;UUID&lt;/span&gt;=4663FCE9-0675-432B-8390-1E17D122859C

&lt;span class="var"&gt;SRCS&lt;/span&gt; = \
     main.m \
     BasicApp.m

&lt;span class="comment"&gt;# you shouldn't need to change anything below this line 
# (unless you need to add frameworks to the linker)
##########################################################&lt;/span&gt;

&lt;span class="var"&gt;PATH&lt;/span&gt;=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin: \
/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin: \
/usr/X11/bin:/Developer/usr/bin:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
&lt;span class="var"&gt;MACOSX_DEPLOYMENT_TARGET&lt;/span&gt;=10.6
&lt;span class="var"&gt;SIMULATOR&lt;/span&gt;=/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
&lt;span class="var"&gt;APP_LOC&lt;/span&gt;= ~/Library/Application\ Support/iPhone\ Simulator/4.0/Applications/$(UUID)

&lt;span class="var"&gt;DIR&lt;/span&gt;:=$(&lt;span class="func"&gt;shell pwd&lt;/span&gt;)

&lt;span class="var"&gt;CC&lt;/span&gt;=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2

&lt;span class="var"&gt;CFLAGS&lt;/span&gt;=-x objective-c -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs \
-fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -Wreturn-type -Wunused-variable \
-D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 -DNS_BLOCK_ASSERTIONS=1 \
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk \
-fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 \
-fobjc-legacy-dispatch 


&lt;span class="var"&gt;LDFLAGS&lt;/span&gt;=-arch i386 -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 \
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk \
-L$(DIR) \
-F$(DIR) \
-framework Foundation \
-framework UIKit \
-framework CoreGraphics

&lt;span class="var"&gt;OBJS&lt;/span&gt;:=$(&lt;span class="func"&gt;SRCS:.m=.o&lt;/span&gt;)
&lt;span class="comment"&gt;##########################################################&lt;/span&gt;

&lt;span class="comment"&gt;# Before we build the application, run some prep commands.&lt;/span&gt;
all: prep Application

&lt;span class="comment"&gt;# We need to make sure that we create the sub directories to hold our to-be-deployed app.&lt;/span&gt;
prep: ;
     @cd $(&lt;span class="func"&gt;DIR&lt;/span&gt;); \
     mkdir -p $(&lt;span class="func"&gt;UUID&lt;/span&gt;); \   &lt;span class="comment"&gt; # Create UUID dir and ".app" sub-dir&lt;/span&gt;
     mkdir -p $(&lt;span class="func"&gt;UUID&lt;/span&gt;)/$(&lt;span class="func"&gt;APPNAME&lt;/span&gt;).app

&lt;span class="comment"&gt;# Link our application, generate the Info.plist file, and copy the dir to the Simulator.&lt;/span&gt;
Application: $(&lt;span class="func"&gt;OBJS&lt;/span&gt;)
     $(&lt;span class="func"&gt;CC&lt;/span&gt;) $(&lt;span class="func"&gt;LDFLAGS&lt;/span&gt;) -o $(&lt;span class="func"&gt;UUID&lt;/span&gt;)/$(&lt;span class="func"&gt;APPNAME&lt;/span&gt;).app/$(&lt;span class="func"&gt;APPNAME&lt;/span&gt;) $^
     sed 's/BasicApp/$(&lt;span class="func"&gt;APPNAME&lt;/span&gt;)/g' Info.plist &amp;gt; $(&lt;span class="func"&gt;UUID&lt;/span&gt;)/$(&lt;span class="func"&gt;APPNAME&lt;/span&gt;).app/Info.plist
     cp -R $(&lt;span class="func"&gt;UUID&lt;/span&gt;) ~/Library/Application\ Support/iPhone\ Simulator/4.0/Applications/

&lt;span class="comment"&gt;# Compile our source files.&lt;/span&gt;
%.o: %.m
     $(&lt;span class="func"&gt;CC&lt;/span&gt;) $(&lt;span class="func"&gt;CFLAGS&lt;/span&gt;) -I. -c $&amp;lt; -o $@  

&lt;span class="comment"&gt;# Launch the simulator.&lt;/span&gt;
sim: ;
     open $(&lt;span class="func"&gt;SIMULATOR&lt;/span&gt;)

&lt;span class="comment"&gt;# Remove all object files, remove the application directory, and remove the app 
# from the Simulator.&lt;/span&gt;
clean:
     rm -rf $(&lt;span class="func"&gt;UUID&lt;/span&gt;)
     rm -rf *.o
     rm -rf $(&lt;span class="func"&gt;APP_LOC&lt;/span&gt;)&lt;/code&gt;&lt;/div&gt;

&lt;a name="nslog"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;7. Improving NSLog&lt;/span&gt;
&lt;i&gt;TBD&lt;/i&gt;. Note: Check the source code for the beginnings. It's mostly complete (Debug.m/.h)

&lt;a name="makefile"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;8. Improving The Makefile&lt;/span&gt;
&lt;i&gt;TBD&lt;/i&gt;. Note: Check the source code for the extra portions of the Makefile. Explanation to follow.

&lt;a name="all2"&gt;&lt;/a&gt;
&lt;span class="subhead"&gt;9. Putting It All Together (Draft 2)&lt;/span&gt;
&lt;i&gt;TBD&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/719917296498716181-6689506276135296422?l=lambdadevp.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/HbVNMppV-kDBC-Q_u7bUCxBO9us/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HbVNMppV-kDBC-Q_u7bUCxBO9us/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/HbVNMppV-kDBC-Q_u7bUCxBO9us/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HbVNMppV-kDBC-Q_u7bUCxBO9us/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Dev-p/~4/Wn3l6ZE8I-4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://lambdadevp.blogspot.com/feeds/6689506276135296422/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://lambdadevp.blogspot.com/2010/11/creating-iphone-app-from-scratch.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/719917296498716181/posts/default/6689506276135296422?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/719917296498716181/posts/default/6689506276135296422?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Dev-p/~3/Wn3l6ZE8I-4/creating-iphone-app-from-scratch.html" title="Creating an iPhone App &quot;From Scratch&quot;" /><author><name>Cacti</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>6</thr:total><feedburner:origLink>http://lambdadevp.blogspot.com/2010/11/creating-iphone-app-from-scratch.html</feedburner:origLink></entry></feed>

