Reading Xcode build settings into a CI scripts

965 views
Skip to first unread message

Derek Clarkson

unread,
Nov 15, 2012, 6:55:30 PM11/15/12
to cocoah...@googlegroups.com
Hi all, 

Last night at Cocoaheads Melbourne Adam Eberbach did a presentation on running XCode builds in the Jenkins CI server. During the discussions a question was asked about how to get access to the Xcode build settings in a typical shell based build script (bash for example). 

The following is an extract from a script I use at work which achieves this. Just include it at the top of your scripts and you will them have all the build settings available to you.

# This will export all the Xcode build settings into the local environment.
# THis has been Modified from the original source: http://www.tuicool.com/articles/jMF773
# SED instrutions:
# 1. Remove the first line. (It's a title)
# 2. Remove leading white space.
# 3. Convert quotes from " to \" (global) to escape them in values.
# 4. Wrap values in quotes.
# 5. Remove spaces around "=".
# 6. Remove UID entry.
xcodebuild -showBuildSettings -scheme "$SCHEME" -workspace "$WORKSPACE" -configuration Release | sed '1d;s/^ *//;s/"/\\"/g;s/ = \(.*\)/="\1"/;s/ = /=/;s/UID.*//' > xcodebuild-env.tmp
source xcodebuild-env.tmp

 
The basics of this script is - pipe build settings through SED to convert the settings to bash variable statements, and then into a file. Then include the file into the current script as source. The above script needs the $WORKSPACE and @SCHEME set, but you can also do this with just "xcodebuild -showBuildSettings" or use project and target if you choose. Whatever suites your build.

Hope this helps.

Derek

Stewart Gleadow

unread,
Nov 16, 2012, 7:26:31 AM11/16/12
to cocoah...@googlegroups.com
Thanks Derek - it was me that asked if you could post it to the list... and thanks for putting the effort into Simon, always to good to have new testing tools available, especially dev friendly ones!

Awesome cocoaheads last night... Melbourne really is a hub of CI and test-interested iOS developers. Seriously. Ask devs from other parts of the world, for some reason Melb is a real hub for this stuff.

- Stew


--
You received this message because you are subscribed to the Google Groups "Australian Cocoaheads" group.
To post to this group, send email to cocoah...@googlegroups.com.
To unsubscribe from this group, send email to cocoaheadsau...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cocoaheadsau?hl=en.

Craig Peebles

unread,
Nov 17, 2012, 7:29:16 AM11/17/12
to cocoah...@googlegroups.com
I wrote a bunch of notes fom that talk, lots of really good stuff there. Jenkins has been on my to-do list for a while, and that bumped it right up to the top :-)

I didn't have time to catch the code/command line samples though, is there any chance of requesting the presentation files?

Cheers,
Craig Peebles
www.craigpeebles.com

Reply all
Reply to author
Forward
0 new messages