Skip to content

Continuous Integration for iPhone/Xcode projects

I just committed an initial pass at an Xcode builder for CruiseControl. If you want to try it out you’ll need to get the latest code from svn. Right now the plugin is extremely rudimentary: it has only the single attribute ‘directory’ which is where it will invoke xcodebuild.

Here’s an example from config.xml for capturing the images below:

    <project name="RaiseMan">

        <listeners>
            <currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
        </listeners>

        <modificationset quietperiod="30">
            <svn localworkingcopy="${BookProjects}/${project.name}"/>
        </modificationset>

        <schedule interval="60">
            <xcode directory="${BookProjects}/${project.name}"/>
        </schedule>

        <publishers>
            <artifactspublisher dest="artifacts/${project.name}"
                      file="${BookProjects}/${project.name}/xcodebuild.cc.output"/>
        </publishers>

    </project>

Even though the plugin is very simple has all the basics. Like the Ant builder can monitor the build output while it’s happening from the dashboard, and you can see errors and warnings in the jsp reporting app and in email. But unlike the Ant builder you can also publish the build log as an artifact so that you an view it later as plain text.

see build progress in the dashboard

see build progress in the dashboard

view build errors

view build errors

publish log as artifact

publish log as artifact

view complete build log

view complete build log

Hope you like it!

18 Comments

  1. Jtf wrote:

    The xcode builder is part of the CruiseControl 2.8.1 release. Since this blog post I’ve added a timeout attribute and a way to specify command-line args. Documentation here.

    Monday, December 1, 2008 at 12:59 pm | Permalink
  2. applmak wrote:

    Hi. I like the new builder. Very handy.

    However, I’ve noticed a couple of issues, and the CC website doesn’t make it clear how to report them. But I’ve found my way here, hoping to get your attention. Just email me at the provided address when you get this, and I’ll tell you what I’m seeing.

    -M

    Saturday, December 13, 2008 at 6:21 pm | Permalink
  3. Jtf wrote:

    I’m a committer on CruiseControl so you can always report issues on either the CruiseControl users mailing list or on the issue tracker.

    And if by chance the issue is a problem using nested args, I committed a fix for that tonight that you can get by pulling the latest source.

    Saturday, December 13, 2008 at 8:39 pm | Permalink
  4. Jason wrote:

    When will an official CC release be made that includes the “args” support in the Xcode builder? I gather if I want to get this early I need to start with the current SVN repository. I’m not too keen on that for a production environment.

    I’m trying out the execbuilder in the meantime.

    Wednesday, December 31, 2008 at 4:22 pm | Permalink
  5. Jtf wrote:

    I’m hoping to have the next CC release out by this weekend. Would have been out already if I hadn’t been delayed by hardware problems.

    But on the good side, Time Capsule works! ;)

    Tuesday, January 6, 2009 at 11:01 pm | Permalink
  6. Jtf wrote:

    The new release is out and you can download it now.

    Monday, January 12, 2009 at 11:57 pm | Permalink
  7. IntarTech wrote:

    Just set up CC for the first time, so I could try your Xcode support.

    I have added 3 of my projects to the config.xml, but am finding that the ‘xcodebuild.cc.output’ file is not getting written into the folder specified by the ‘directory’ setting for each project.

    In fact, each project appears to have the cc.output file written out to the folder of the FIRST project that CC built when launching it. This results in a failure at the end of builds, where the cc.output file can’t be found (it attempts to find it in the project folder but it’s actually in another project’s folder).

    Has anyone else reported this to you? I will find and sign up for the appropriate mailing list and post there, but I just thought I’d leave feedback here in case that’s helpful.

    Kind Regards.

    Saturday, March 14, 2009 at 9:34 am | Permalink
  8. Jtf wrote:

    Thanks for pointing out the bug. As I mentioned on the CC mailing list I’ve fixed it and you can get the source now and build it locally or just wait until 2.8.3 is released.

    Saturday, March 14, 2009 at 10:11 pm | Permalink
  9. Jason Boehle wrote:

    Does the Xcode builder pass on the standard CC builder properties to Xcode as env vars? If not, it should. In particular, I want ${svnrevision}, so my pre-build script in my Xcode project can use it to update the version #.

    Thursday, April 30, 2009 at 2:16 pm | Permalink
  10. Jtf wrote:

    No, the Xcode builder isn’t passing any environment variables, though I agree it would be a good idea. Patches gratefully accepted. :)

    I don’t know if it helps in your case but it will do property substitution with the command-line, so if there was some way to pass a value through xcodebuild on the command-line that would work.

    Thursday, April 30, 2009 at 3:59 pm | Permalink
  11. Matt Burke wrote:

    This should be obvious, and I’ve looked at the source, but just to verify: neither the svn element in the modification set nor the xcode builder actually update the working copy.

    I assume that typically with the ant builder, the build script has a target to update the working copy. So in this case we would need to add another step. I was thinking of using a compound builder to first have an exec task do the repository update, then run the xcode builder.

    Is that more or less correct?

    Thanks.

    Thursday, July 8, 2010 at 4:59 pm | Permalink
  12. Jtf wrote:

    Hi Matt,

    Yep, you got it.

    Jtf

    Friday, July 9, 2010 at 5:56 am | Permalink
  13. I’m having problems passing arguments through to xcodebuild. In my config.xml I have the following:

    However the build doesn’t run properly and I see the following output on the Cruisecontrol console:

    [cc]Aug-04 17:15:46 XcodeBuilder – starting build
    [cc]Aug-04 17:15:46 ScriptRunner – unknown option: -project MyProject.xcodeproj
    [cc]Aug-04 17:15:46 ScriptRunner – Usage: xcodebuild [-project ] [-activetarget] [-alltargets] [-target ]… [-parallelizeTargets] [-activeconfiguration] [-configuration ] [-sdk |] [-xcconfig ] [=]… []…
    [cc]Aug-04 17:15:46 ScriptRunner – xcodebuild [-version [-sdk [|] [] ]
    [cc]Aug-04 17:15:46 ScriptRunner – xcodebuild [-showsdks]
    [cc]Aug-04 17:15:46 ScriptRunner – xcodebuild [-find -sdk |]
    [cc]Aug-04 17:15:46 ScriptRunner – xcodebuild [-list]
    [cc]Aug-04 17:15:46 XcodeBuilder – build finished with exit code 1

    If I run xcodebuild manually with these arguments, the build works perfectly:

    xcodebuild -project MyProject.xcodeproj -target LogicTests -sdk iphonesimulator4.0

    I’m using CruiseControl 2.8.3 binary release.

    Wednesday, August 4, 2010 at 9:29 am | Permalink
  14. Ratheesh wrote:

    Hi,

    I just installed CC 2.8.4 and configured a xcode project. Although, the build itself goes through fine, it throws the error about missing xcodebuild.cc.output.

    Is this a known issue or am I missing something ?

    I see different stack traces in the logs:

    [cc]Feb-03 01:10:32 ScriptRunner – setenv XCODE_APP_SUPPORT_DIR /Developer/Library/Xcode
    java.io.FileNotFoundException: /Users/ratheesh/Desktop/work/MIS/projects/Prototype/xcodebuild.cc.output/xcodebuild.cc.output (No such file or directory)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.(FileOutputStream.java:177)
    at net.sourceforge.cruisecontrol.util.BuildOutputLogger.consumeLine(BuildOutputLogger.java:88)
    at net.sourceforge.cruisecontrol.util.CompositeConsumer.consumeLine(CompositeConsumer.java:67)
    at net.sourceforge.cruisecontrol.util.StreamPumper.consumeLine(StreamPumper.java:141)
    at net.sourceforge.cruisecontrol.util.StreamPumper.run(StreamPumper.java:128)
    at java.lang.Thread.run(Thread.java:680)

    And,

    [cc]Feb-03 01:10:33 XcodeBuilder – error creating reader for file /Users/ratheesh/Desktop/work/MIS/projects/Prototype/xcodebuild.cc.output
    java.io.FileNotFoundException: /Users/ratheesh/Desktop/work/MIS/projects/Prototype/xcodebuild.cc.output (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.(FileInputStream.java:106)
    at java.io.FileReader.(FileReader.java:55)
    at net.sourceforge.cruisecontrol.builders.XcodeBuilder$OutputFile.createReader(XcodeBuilder.java:228)
    at net.sourceforge.cruisecontrol.builders.XcodeBuilder$OutputFile.hasMoreLines(XcodeBuilder.java:197)
    at net.sourceforge.cruisecontrol.builders.XcodeBuilder.elementFromFile(XcodeBuilder.java:74)
    at net.sourceforge.cruisecontrol.builders.XcodeBuilder.build(XcodeBuilder.java:46)
    at net.sourceforge.cruisecontrol.Schedule.build(Schedule.java:169)
    at net.sourceforge.cruisecontrol.Project.build(Project.java:227)
    at net.sourceforge.cruisecontrol.Project.execute(Project.java:148)
    at net.sourceforge.cruisecontrol.ProjectConfig.execute(ProjectConfig.java:408)
    at net.sourceforge.cruisecontrol.ProjectWrapper.run(ProjectWrapper.java:69)

    Wednesday, February 2, 2011 at 10:10 pm | Permalink
  15. Jtf wrote:

    That isn’t a problem I’ve encountered before, but I haven’t been building XCode projects lately. The XCodeBuilder is trying to capture the output from XCode to look for the line ** BUILD FAILED **. If you’re getting that error it means that XCode has no build output… which is strange, at least from what I had seen when I created the plugin 2 years ago.

    I recommend you try testing this by creating a compile error and then seeing if CruiseControl catches the problem. If it does, then I guess all is well. If not, then I’d see if perhaps XCode’s command-line behavior has change so that it is no longer producing the same output.

    Jtf

    Wednesday, February 2, 2011 at 10:39 pm | Permalink
  16. Ratheesh wrote:

    I had to change a few things in 2.8.4 sources to get this to work.

    1) For the first stack trace in my previous post:

    In XCodeBuilder.runScript():

    Changed

    getBuildOutputConsumer(projectName, file.file, file.file.getName());

    to

    getBuildOutputConsumer(projectName, directory.toFile(), file.file.getName());

    2) For the second stack trace, I found that ScriptRunner.runScript() deletes the output file before XCodeBuilder.elementFromFile() has a chance to read the output file.

    So, I commented out the buildOutputConsumer.clear(); call towards the end of ScriptRunner.runScript(). And, added a delete call after XCodeBuilder.elementFromFile() is done.

    Do those indicate some configuration issue on my end ? or a potential bug in 2.8.4 release ?

    Thanks

    Friday, February 4, 2011 at 8:48 am | Permalink
  17. Min wrote:

    Hi, I’m having exactly the same problem, even with the latest svn code from cruisecontrol.
    I’ve added the 1st modification mentioned by Ratheesh, but the 2nd fails in some tests, so I can’t get the final binary.
    There is a plan to fix this in the future?

    Thanks

    Tuesday, March 1, 2011 at 6:30 am | Permalink
  18. Mark wrote:

    I saw the same problem as Ratheesh when I upgraded to 2.8.4. I ended up downgrading back to 2.8.3 because of the issue.

    Thursday, March 31, 2011 at 11:51 am | Permalink

4 Trackbacks/Pingbacks

  1. iPhone Unit Testing Toolkit at Carbon Five Community on Friday, February 13, 2009 at 2:36 pm

    [...] is now a recently released Xcode builder for CruiseControl. However, we use Bamboo for CI for our Java and Ruby projects and are considering moving to [...]

  2. Agile Development Notes on iPhone Development @ GQAdonis on Sunday, November 29, 2009 at 5:52 pm

    [...] not found a lot on how to do continuous integration in iPhone development, but I did come across one interesting article by Jeffrey Fredrick that explained how to use Cruise Control on Xcode [...]

  3. [...] is now a recently released Xcode builder for CruiseControl. However, we use Bamboo for CI for our Java and Ruby projects and are considering moving to [...]

  4. iPhone Unit Testing Toolkit | The Carbon Emitter on Friday, June 10, 2011 at 5:53 pm

    [...] is now a recently released Xcode builder for CruiseControl. However, we use Bamboo for CI for our Java and Ruby projects and are considering moving to [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*