How to automatically build an IPA file from XCode
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 call 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 http://files.idotcom.us/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>
Onload of page my antivirus put alert, check pls.
Have a nice day
Hi there,
Thanks for article. Everytime like to read you.
Thanks
SonyaSunny
Hi, gr8 post thanks for posting. Information is useful!
The best information i have found exactly here. Keep going Thank you
How soon will you update your blog? I’m interested in reading some more information on this issue.
I will update more often thanks for reading!!
Thanks,; thanks, thanks, thanks a million… You just saved me a lot of time !
help !! I downloaded your complete project, and ther is an error :
” Code Sign error: The identity ‘iPhone Developer’ doesn’t match any vaild certificate/private key pair in the default keychain”
what can i do ?
thanks a lot.
I have disabled code signing for this sample project so you should be able to create the IPA
it didnt work for me.
it didnt build the .ipa file
i did exactly wat it said to do.
Please check out the new zip file attached to this post. Thanks!
Thanks for all of your comments! I have uploaded a new version which should build the IPA correctly.
Thank you so much for providing this article, it’s great to finally find something worth reading.
http://www.workingforgoogle.com
This script works great, but doesn’t take into account the possible deletion of resources between builds – if this happens the Payload inside of the IPA file will contain stale unsigned resource(s) yielding the dreaded 0xE8008017 error when installing the IPA via iTunes. The fix is to add a new line with “/bin/rm -rf $CONFIGURATION_BUILD_DIR/Payload” before the mkdir line and “rm HelloWorld.ipa” before the zip line.
@Hasani
Can you just tell me how to disable the code signing for any project.
Thanks
Manish
i have error said
1.”cp” no such directory
2.code signing error
Sorry, i can’t see the images. Please check. Thank you very much.
Hi, can I build an application without signing or using certificate? If I can please describe it in more details. thank you
You can build an application without using a certificate.. You will just be able to run it in the iPhone Simulator
The evil “Code Sign error: The identity ‘iPhone Developer’ doesn’t match any vaild certificate/private key pair in the default keychain” error came for me also.
BTW, I’m using Xcode 3.2 for Snow Leopard. Plz help!!!
O Ya, I forgot, the download isn’t a link or… anything.
Sry about the DP
Thanks! This is exactly what I was looking for. I made some improvements to make the script completely generic:
payload_dir=”$CONFIGURATION_BUILD_DIR/Payload”
app_bundle_dir=”$CONFIGURATION_BUILD_DIR/${PROJECT_NAME}.app”
/bin/rm -rf “$payload_dir”
/bin/mkdir “$payload_dir”
/bin/cp -R “$app_bundle_dir” “$payload_dir”
/bin/cp iTunesArtwork “$CONFIGURATION_BUILD_DIR/iTunesArtwork”
cd “$CONFIGURATION_BUILD_DIR”
/usr/bin/zip -r “${PROJECT_NAME}.ipa” Payload iTunesArtwork
rm -rf “$payload_dir” iTunesArtwork
I also added $(CONFIGURATION_BUILD_DIR)/$(PROJECT_NAME).app as an input file in the configuration window, and added $(CONFIGURATION_BUILD_DIR)/$(PROJECT_NAME).ipa as an output file so that the build systems knows that the ipa needs to be rebuilt if the app dir is newer.
That is a very nice improvement.. Too bad I didn’t think of that!! I’m wondering if that can be used as a XCode template?
the ipa file is not showing up can you please help me
@Hasani Hunter
Hey man, i didn’t found the new zip on the post!
Can you put the link again? Tks a lot.
Where is the zip file??
I recently moved the blog to wordpress and forgot to update the download link appropriately.. The post has been updated with the download link.
Hi,
I am new for iPhone dev. I created an web application for iPhone using iPhone SDK.
I generated ipa file for my project.
When i install my project on iPhone using iTune, i am getting following error msg
The application “checknumber” was not installed on the iPhone “jfalexvijay” because an unknown error occured (0xE800800E).
Please any one help me…
Regards,
J Alex Antony Vijay.
I would check that your distribution profile has the correct device “jfalexvijay” and make sure that you have a dist.plist in your XCode project.
Thank you so much! This was the exact information that I was searching for. You’ll go to heaven 😀