How to automatically build an IPA file from XCode

 

Edit: I originally wrote this post almost a year ago to the day (before iPhone SDK 3.0). Be sure to let me know if these instructions no longer work for you.

I have long since forgotten where I first read this, but I hope this will help an iPhone developer looking to simplify the process for sending their app to their user(s) via AdHoc.

Create a View-Based application project in xcode like so:

I named mine HelloWorld ( How original!! ). After telling XCode where to store your project, you should be presented with a window similar to this:

If you expand the Nib Files smart folder you should be presented with a window similar to this:

If you named your project Hello World like I did, you should see a file called HelloWorldViewController.xib. Double click on HelloWorldViewController.xib to open the file in Interface Builder.

In Interface Builder, open up the Library ( Tools-> Library or Command-Shift-L) and Inspector  (Tools-> Inspector or Command-Shift-I) panels.  Drag over a UILabel and center in the view and change the text to HelloWorld by double clicking on the label and changing the text. You should have something similar to this:

You can close interface builder at this point. Going back to XCode, expand the Targets item and control-click ( or right click if using a multi button mouse ) and select Add->New Target and select “Other” at the bottom left and choose the Aggregate option similar to this:

And name the new target IPA:

On the next screen be sure the add HelloWord target as a direct dependency by clicking the plus button in the lower right corner under the Direct Dependencies section like this:

Close this window once you are done adding HelloWorld target as a direct dependency of IPA target. Right click or control-click on the IPA target and select the Add->New Build Phase->New Run Script Build Phase menu item and add the following code:

if [ $BUILD_STYLE != “AdHoc_Distribution” ]; then

exit

fi

# compress application.

/bin/mkdir $CONFIGURATION_BUILD_DIR/Payload

/bin/cp -R $CONFIGURATION_BUILD_DIR/HelloWorld.app $CONFIGURATION_BUILD_DIR/Payload

/bin/cp images/logo_itunes.png $CONFIGURATION_BUILD_DIR/iTunesArtwork

cd $CONFIGURATION_BUILD_DIR

# zip up the HelloWorld directory

/usr/bin/zip -r HelloWorld.ipa Payload iTunesArtwork

The run script window should look like this:

Now you can choose to run the IPA target instead of the HelloWorld target to compile the application and turn it into HelloWorld.ipa file that your users can bring directly into iTunes simply by double clicking on it.

In the directory where you apps are built, you should find a file called HelloWorld.ipa:

One last note: in the above script there are a few lines of code that will exit the shell script if the build configuration isn’t AdHoc_Distribution

if [ $BUILD_STYLE != “AdHoc_Distribution” ]; then

exit

fi

You actually don’t need these lines, I always create an AdHoc configuration that is used for sending out any betas to the testing group.  You can either create a build configuration called AdHoc_Distribution and make sure its selected before you build, or just remove the code ( three lines ) altogether.  You can download the complete project here HelloWorld_IPA.zip

If you are having problems installing your adhoc application via iTunes, check that the distribution profile that you are using has the correct device and that you have a dist.plist file in your XCode project with the following contents:

<?xml version=”1.0” encoding=”UTF-8”?>

<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>

<plist version=”1.0”>

<dict>

<key>get-task-allow</key>

<false/>

</dict>

</plist>

I Had A Hell Of Alot Of Fun At Bigomaha

I had a hell of alot of fun at BigOmaha!

andypeters:

Myself and Hasani Hunter at BigOmaha 2010 representing Ninth Division.

Bigomaha 2010 Iphone App Story

BigOmaha 2010 iPhone App Story

andypeters:

In May of 2009, the BigOmaha gathering rocked your socks off. A few months before the first BigOmaha, I got an email from Dusty one early morning… “…it’d be cool to have an iPhone app.” To which…

Why 3.3.1 matters to me

According to some sites on the internet, section 3.3.1 of new iPhone Developer Agreement reads:

3.3.1 — Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

So I take this to mean that any code to be written for iPhoneOS devices must be originally written in Objective-c,C,C++ or Javascript (WebKit).  This is mainly a non issue for NinthDivision as we only write our iPhone code in Objective-C and C.

 After reading about many developers ( and wanna bees ) coming to defend Adobe’s honor, I have to ask the question: How many developers who have released flash apps compiled for the iPhone ever optimized their application(s) to run with a great user experience?  Does Adobe create better performance tools than Apple?

At NinthDivision, we put a lot of time into the user experience of our apps. With the exception of BigOmaha iPhone app, there is usually a fair amount of performance tuning that goes on behind the scenes. 

In the case of BigOmaha, we only tested on 3GS devices ( which has a faster CPU than any previous iPhone or iPod Touch device ). The performance was more than acceptable until we tested a build on a 3G iPhone.

One hardware difference to consider is that the iPhone 3GS has a 600MHZ CPU and the 3G only has a 412MHZ CPU.  I was extremely unsatisfied with the scrolling performance in the main twitter view.  So now that BigOmaha 2010 is over, I decided to revisit the twitter view code.

As a warning, the rest of this post will be a bit technical in nature to illustrate a point that supports Apple’s changes in 3.3.1.


According to Instruments ( which all iPhone developers should be using ), my scrolling performance was peaking at 44 Frames Per Second.

This indicates to me that I am taxing the CPU much more than needed causing the scrolling performance to plummet.

After looking at this output, I noticed that we were recreating and configuring a NSDateFormatter for every cell that was being displayed. This meant that we were creating and configuring a different instance of the same object for every cell that needed to be drawn ( i.e. when the user scrolls ).

20.5% of the overall CPU usage is happening in BOTwitterViewController’s configureCell:forIndexPath: method.

The Solution?  Create only a single instance of a NSDateFormatter and configure it once. The results surprised me..  the overall CPU usage for that method dropped from 20.5% to 1.2%

The scrolling performance is now peaking at 57 FramesPer Second

What this all means is that my  iPod Touch 2G scrolls faster than my iPhone 3GS!

The bigger point is that I performed this optimization using Apple’s supported toolchain. So from a performance and user experience point of view, are Flash developers who export iPhone binaries able to get to this level of detail within their own code?  In that case where does the runtime stop and the developer begin? On the iPhone, user experience does matter, so having access to these tools is essential for finding problems with your app.

Thoughts on BigOmaha 2010

First of all I must thank both Jeff Slobotski and Dusty Davidson of Silicon Prairie News for putting on such an awesome and inspiring conference. I believe BigOmaha 2010 was a huge hit and I am definitely going to BigOmaha 2011.  I loved most of the speakers that they were able to put together.

I laughed with David Hauser when he was recounting his experience with rebranding Grasshopper.

I actually cried when Scott Harrison of Charity Water was showing his presentation on the water crisis in Africa.

Was deeply offended with Melody McCloskey and her “Move” comment. I certainly have nothing against her ( never heard of her until BigOmaha ) but I give her props for being honest on how she felt about living in bigger communities.  I think time will tell if she is ultimately right or not about that, but boy she struck a nerve in almost everyone present. With such a divisive comment, I’m sure it did alot more harm than good and her message was actually lost on the crowd after that. Ramhatter actually met with Melody and she clarified her remarks a bit better. Props to him for taking the time to talk with her and get her side of the story.

Gary Vaynerchuk was awesome as usual. I did manage to buy Crushit on my iPad.. Now I’m pumped to crushit as well.

Met Jason Fried of 37 Signals in person ( really friendly ) and made a crappy comment to him about him being shorter in person than in a video. He was gracious enough not to brand me an idiot and just walk off.

Was emotionally moved by Tony Hsieh’s story and zappos.  If I would work for a another company as an employee.. it would at zappos for sure. Got an advanced copy of his book and I’m loving it so far. He was getting a bit emotional towards the end of his talk and you could get a sense of what this all means to him ( being happy ).

BigOmaha 2010 was a huge hit and I am looking forward to what the rest of 2010 has in store for me.