Showing posts with label xcodebuild. Show all posts
Showing posts with label xcodebuild. Show all posts

Friday, July 17, 2009

iPhone app distribution made easy - Part 4

Introducing Subversion
One of the most important items for any kind of software development is a version/revision control system. There are many flavors of version control systems and many arguments for and against each one. Ultimately they all provide the ability to track changes in code over time and provide the ability to manage development paths. For the purpose of this post I'll be referencing SubVersion (http://subversion.tigris.org/).

Introducing Hudson
Hudson is a continuous integration build system that enables easy tracking and running of builds. Hudson can be downloaded from https://hudson.dev.java.net/ and is very easy to get started and can be run on the Mac with the following command "java -jar hudson.war".

Hudson is integrated with subversion so builds can be triggered by subversion code commits. Builds can also be launched manually. One of the great strengths of Hudson is that it manages all the build numbers and build artifacts for you so you don't have to think about it.

Basic steps
The steps to get Hudson building your iPhone applications are quite simple and follows the format:


  1. Create a new hudson job

  2. Point Hudson to your subversion repository

  3. Create a build step to run the build scripts developed earlier in Part 2 and Part 3.

  4. Instruct Hudson to save the build output.


Example Build step
The following build step starts by creating some variables for build folders etc using some of Hudson's built in environment variables. It then builds the AppStore and AdHoc distributions.

PROJDIR=${WORKSPACE}/myApp
ADHOC_BUILDDIR="${PROJDIR}/build/myAppAdHoc/DistributionAdHoc-iphoneos"
APPSTORE_BUILDDIR="${PROJDIR}/build/myAppAppStore/DistributionAppStore-iphoneos"
BASEFILENAME="${JOB_NAME}_${BUILD_NUMBER}(rev-${SVN_REVISION})"

echo Building AppStore release
cd "${PROJDIR}"
xcodebuild -target "myAppAppStore" -configuration "DistributionAppStore" -sdk iphoneos2.1
cd "${APPSTORE_BUILDDIR}"
zip -r -T -y "${BASEFILENAME}_AppStoreApp.zip" "myApp.app"

echo Building AdHoc release
cd "${PROJDIR}"
xcodebuild -target "myAppAdHoc" -configuration "DistributionAdHoc" -sdk iphoneos2.1
cd "${ADHOC_BUILDDIR}"
zip -r -T -y "${BASEFILENAME}_AdHocApp.zip" "myApp.app"


The output zip file name will include the build number & subversion revision number for easy reference.

Example: myApp_13(rev-99619)_ProdApp.zip

Example artifacts archive
Hudson has the ability to perform wild card searches when looking for build artifacts. The following will search both the AdHoc and AppStore build folders for their output files.

myApp/build/**/*.zip

Conclusion
So hopefully you are now inspired or atleast aware of how you can make your own iPhone development easier.

iPhone app distribution made easy - Part 2

Being able to build various distributions in the XCode IDE is great but you have to think about what you're doing very carefully. Thankfully the 3.0 version of the SDK comes with an improved command line build utility called "xcodebuild".

Here's an example of how to build the AppStore distribution:

xcodebuild -target "myAppAppStore" -configuration "DistributionAppStore" -sdk iphoneos2.1

As you'll notice the target, configuration and the sdk to use are being specified. Note: The sdk option is new for the 3.0 sdk and can take either the name or path of the sdk to use.

You can view all of the installed sdks by running the following command:

xcodebuild -showsdks

So now we have the ability to build the distributions without thinking about it. We could put this in a script and call it a day but lets not stop there. Next time we'll zip up the app bundle for submission to the AppStore or AdHoc users.