Friday, March 30, 2012

Building xCode project and generating IPA file using Ant

Following is the procedure to generate IPA file.

Under “project settings” change “derived data location” to “project-relative”, and make it "DerivedData/dist/". If you want any other location, change the same in the code. This will be the location where ".app" file and all other project info is stored.

Set the values to the fields in CAPITAL LETTERS, and save the file as build.xml

<project default="buildAndPackage" basedir="." name="APP-FOLDER">
<property name="local.projectPath" location="WHERE THE PROJECT IS LOCATED" />
<property name="local.ipaPath" location="WHERE TO SAVE THE IPA FILE" />

<property name="" value="APP-ID" />
<property name="scheme" value="APP-SCHEME(MOSTLY APP-ID)" />
<property name="version" value="VERSION-NO" />
<property name="distributorName" value="NAME USED IN IOS PROVISIONING PORTAL" />

<property name="ProvisioningProfile" location="WHERE YOU KEPT THE FILE" />
<property name="configuration" value="Release/debug/AdHocDistribution/AppStore SELECT THE APPROPRIATE" />

<target name="buildAndPackage">
<exec executable="/Developer/usr/bin/xcodebuild">
<arg value="-project" />
<arg value="${local.projectPath}/${}.xcodeproj" />
<arg value="-scheme" />
<arg value="${scheme}" />
<arg value="-configuration" />
<arg value="${configuration}" />
<arg value="clean" />
<arg value="build" />

<exec executable="xcrun">
<arg value="-sdk" />
<arg value="iphoneos" />
<arg value="PackageApplication" />
<arg value="-v" />
<arg value="${local.projectPath}/DerivedData/dist/Products/${configuration}-iphoneos/${}.app" />
<arg value="-o" />
<arg value="${local.ipaPath}/${}-${version}.ipa" />
<arg value="--sign" />
<arg value="iPhone Distribution: ${distributorName}" />
<arg value="--embed" />
<arg value="${ProvisioningProfile}" />


Then run it from command line by typing "ant"