Building iOS and Mac projects from the command-line could be a lot easier to work with.
Hopefully this post will give you a couple ways to make that happen.
I wanna talk about two different little tools that help ease the process of scripting or working with Xcode projects from the command line.
xcodebuild-rb is a neat little ruby gem that lets you create a
Rakefile inside the root of your Xcode project's folder that looks like this:
require 'rubygems' require 'xcodebuild' XcodeBuild::Tasks::BuildTask.new
What does that get you?
Well, after creating that
Rakefile, running a quick
rake -T (which will list all available
rake tasks) will output something like this:
rake xcode:build # Builds the specified target(s). rake xcode:clean # Cleans the build using the same build settings. rake xcode:cleanbuild # Builds the specified target(s) from a clean slate.
One of the coolest features of
xcodebuild-rb is it's use of "formatters". One of my favorite formatters is called "progress". You can enable it like this:
XcodeBuild::Tasks::BuildTask.new do |t| t.formatter = XcodeBuild::Formatters::ProgressFormatter.new end
Then when you build using
xcodebuild-rb, your output will look something like this:
Building target: ExampleProject (in ExampleProject.xcproject) ============================================================= Configuration: Release .............. Finished in 2.226883 seconds. Build succeeded.
Apple ships Xcode with a command line tool called
xcodebuild, which as the name suggests, builds an Xcode project. One drawback about the built-in
xcodebuild tool is that it can't create
.ipa archive files.
xcodearchive isn't a ruby gem. It is just a
.rb file that you can put anywhere you'd like and run.
xcodearchive has a ton of great features, check out the USAGE output:
Usage: xcodearchive [OPTIONS] --version Show version number -v, --verbose Output more information -g, --growl Show growl alerts to inform about progress of the build -n, --do_not_keep_dsym_symbols Do not keep the dSYM symbols -s, --show Show archive in Finder once created -c, --clean Do a clean before building the Xcode project -o, --ipa_export_path FOLDER Set the path of the folder where the ipa will be saved. Default is '~/Desktop' -i DEVELOPPER_IDENTITY, Force the developper identity value --developper_identity -p, --project PROJECT Specifiy xcode project -h, --help Display this screen
If you aren't already automating the tedious parts of your build and release processes, you are missing out. As any iOS developer knows, building and releasing can become some of the most monotonous and annoying parts of our jobs, hopefully these little tools will inspire you to start scripting your way to a smoother build/release cycle.