I'm trying to figure out exactly how schemes
work in xcode
and what they're for. I have a cross-platform product that's built on OS X using an external build system ( scons
). I'd like to be able to build/debug it from Xcode
, mostly because of the symbol search and the debugger. I've been using eclipse CDT
which mostly works well, but has some quirks.
I can mostly get this to work by creating an empty project and adding an 'external build system' target. Then, as part of the 'Info' of the target, I specify the 'Build Tool' as /usr/local/bin/scons, and the 'Arguments' are the build parameters that I send to scons. Basically I have the following build variables called $(TARGET)
and $(BUILD_TYPE)
that vary according to whether the build is debug or release, so those can be specified as conditional 'Build Settings'.
The problem is I'd like Menu->Project->Clean
to work. It looks like Xcode/xcodebuilder
use the $(ACTION)
variable to pass this on - where $(ACTTION)
is either 'build', 'clean', or some other build actions. See xcodebuild ACTION. Scons is a bit different - it has a built-in clean action that's invoked on the command line with scons -c
. So my first thought was to use a conditional 'Build Setting' to pass this parameter, but it turns out that conditional 'Build Settings' don't seem to vary based on the build ACTION
- just the build architecture and SDK.
Is it possible to add an expression to a 'Build Setting' in Xcode/xcodebuilder
? Is there another good way that I could get 'Clean' to work in Xcode
with scons?
Write a wrapper script for SCons
, and put it in your project. For example:
$(PROJECT_DIR)/scons-xcode-wrapper.sh
$(ACTION)
From an experiment, it looks like $(ACTION)
is empty when building, and set to clean
when cleaning.
#!/bin/sh
cd "$PROJECT_DIR"
case $1 in
clean)
scons -c
;;
*)
scons
;;
esac
Don't forget to chmod +x
your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With