---
title: "Building Xcode Projects from the Command Line"
url: https://deallocatedobjects.com/posts/building-xcode-projects-from-the-command-line
author: Jake Marsh
published: 2012-02-11
updated: 2013-11-16
topics: ["Xcode & Tools"]
description: "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."
---

# Building Xcode Projects from the Command Line

By Jake Marsh, February 11, 2012. HTML: https://deallocatedobjects.com/posts/building-xcode-projects-from-the-command-line

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

[`xcodebuild-rb`](https://github.com/lukeredpath/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:

``` ruby
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:

``` bash
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:

``` ruby
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:

``` bash
Building target: ExampleProject (in ExampleProject.xcproject)
=============================================================

Configuration: Release
..............

Finished in 2.226883 seconds.
Build succeeded.
```

[Read more about `xcodebuild-rb` on Github](https://github.com/lukeredpath/xcodebuild-rb)


### xcodearchive

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. 

Well, enter [`xcodearchive`](https://github.com/gcerquant/xcodearchive/blob/master/xcodearchive.rb).

Unlike `xcodebuild-rb`, `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:

``` bash
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

```

[Read more about `xcodearchive` on Github](https://github.com/gcerquant/xcodearchive/blob/master/xcodearchive.rb)

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.
