Go 2.0 can be used on the Macintosh to build XCode projects, including of course iPhone and iPad apps built on the iOS platform. Here we explain how to set up a simple pipeline to build one of Apple’s standard iPhone sample applications. We are using the code samples that accompany the article “Unit Testing Applications” from Apple’s iOS reference library (see references below for links to these files). You should be able to get a basic build pipeline up and running with this example.
To run a build in Go we use the exec task to run the xcodebuild command line build tool for the project. To build Apple’s sample code and run the Logic tests we can use this command:
/Developer/usr/bin/xcodebuild -sdk iphonesimulator4.0 -target CalculatorTests -configuration Debug
Note that although there is an xcode clean command I prefer to delete the build directory to ensure that all build artifacts are cleaned out before the build.
rm -rf build
The configuration for a Go pipeline to do this is very simple. You can easily modify this for your own project:
<pipeline name="Apple_iPhoneUnitTests">
<materials>
<git url="file:///Users/skizz/Development/go-iphone/Projects/Apple_iPhoneUnitTests/.git" />
</materials>
<stage name="Test">
<jobs>
<job name="LogicTests">
<tasks>
<exec command="/bin/rm" args="-rf build" />
<exec command="/Developer/usr/bin/xcodebuild" args="-sdk iphonesimulator4.0 -target CalculatorTests -configuration Debug" />
</tasks>
</job>
</jobs>
</stage>
</pipeline>Test results and errors can be seen in the console for the LogicTests job. This is not ideal, and I have a better solution that leverages some of Go’s more advanced features, but I will save that for a future post.
Test Suite '/Users/skizz/Development/go-iphone/Cruise/cruise-agent-2.0.0/pipelines/Apple_iPhoneUnitTests/build/Debug-iphonesimulator/CalculatorTests.octest(Tests)' started at 2010-07-20 22:32:09 -0600
Test Suite 'CalculatorTests' started at 2010-07-20 22:32:09 -0600
Test Case '-[CalculatorTests testAddition]' started.
Test Case '-[CalculatorTests testAddition]' passed (0.002 seconds).
...
Test Case '-[CalculatorTests testSubtractionNegativeResult]' passed (0.002 seconds).
Test Suite 'CalculatorTests' finished at 2010-07-20 22:32:09 -0600.
Executed 6 tests, with 0 failures (0 unexpected) in 0.017 (0.018) secondsThis just scratches the surface of what you can do with Go 2.0 for iPhone application build and test. I hope to show more in future posts.
Setting up the Go Server
Install a Go Server and at least one Agent as described here: Installing Cruise Server
Once the server is running and your repository is created you just need to add a new pipeline to the Server:
- Click on the “ADMIN” link on the toolbar at the top of the screen
- Click on the “Source XML” tab. This allows you to edit the whole configuration at once.
- Click on the “EDIT” button
- Add the pipeline
- A full sample config file is shown below
Sample Configuration
<?xml version="1.0" encoding="utf-8"?>
<cruise xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cruise-config.xsd" schemaVersion="17">
<server artifactsdir="artifacts">
<license user="YOUR_USER_NAME">YOUR_LICENSE</license>
</server>
<pipelines group="defaultGroup">
<pipeline name="YOUR_PROJECT_NAME">
<materials>
<git url="YOUR_PROJECT_SCM" />
</materials>
<stage name="Test">
<jobs>
<job name="LogicTests">
<tasks>
<exec command="/bin/rm" args="-rf build" />
<exec command="/Developer/usr/bin/xcodebuild" args="-sdk iphonesimulator4.0 -target CalculatorTests -configuration Debug" />
</tasks>
</job>
</jobs>
</stage>
</pipeline>
</pipelines>
<agents>
</agents>
</cruise>
References
Note: You may need to be a registered Apple developer to see some of these documents
Apple developer documentation Unit Testing Applications
Apple Sample Code iPhoneUnitTests
Apple’s example code is distributed as a zip file, so the first step is to add the code into a source code repository. I have used git, but Go gives you the choice of Git, Mercurial, Subversion or Perforce. I won’t go into the details of how to create the repository or add the code to it.
Comments
0 comments
Please sign in to leave a comment.