How to Use Subprojects with Xcode and Jenkins

Assume, you have an Xcode project Parent and another project Child, which is registered as a subproject of Parent. Let’s further assume that Child is registered as a Git submodule of Parent. Imagine that you want to use Jenkins for continuous integration for the project Parent. Do the following:

  1. Make sure that xcuserdata folder in Parent.xcodeproj is included in the Git repository.
  2. Download ocunit2junit.rb. Yay, you don’t need GHUnit anymore!
  3. Create a free-style job in Jenkins and add an “Execute shell” step with the following
    git submodule init
    git submodule update
    git submodule -q foreach git pull -q origin master
    cp -r Parent.xcodeproj/xcuserdata/YOUR_USER_NAME.xcuserdatad Parent.xcodeproj/xcuserdata/JENKINS_USER_NAME.xcuserdatad
    xcodebuild -scheme NAME_OF_OCUNIT_SCHEME -configuration Release clean test | /PATH/TO/ocunit2junit.rb
  4. Add “Publish JUnit test result report” post-build action:
     
  5. Voilà!