A tool for SCons to enable the generation of Xcode project files. Unlike CMake, the idea here is to get Xcode to run scons, so that the SConstruct file is still the master project file.

Loading the tool

To use the tool, copy in this directory to a directory xcode in your tool path. See the SCons documentation for more information on where you can install the file.

You can also clone the repository directly into your site_tools directory with:

hg clone xcode

Next, add the tool to your environment with something like the following:

env = Environment(tools=['default', 'xcode'])


You need to include default so that the built-in tools remain available.


To generate an Xcode project file, simply add a call to env.XCodeProject to your SConstruct file:

env = Environment(tools=['default', 'xcode'])

myprog = env.Program('build/MyProg', ['src/'])


The resulting Xcode project file will contain only a single group, "Products", in which you will see the MyProg program. It will also contain two legacy build system targets named "Everything" and "MyProg"; the former will run scons without specifying a target, while the latter will explicitly specify MyProg. The Xcode project will also have a shared build scheme defined for MyProg that will cause it to run MyProg if asked to run/debug (this only happens for env.Program at present).

Obviously that project file is very minimal; you will probably want to include your own groups and source files in practice, which you can do by passing a dictionary into the XcodeProject builder, e.g.:

                 groups={ 'Headers': [ 'src/MyProg.h' ],
                          'Sources': [ 'src/', 'src/' ],
                          'Documentation': [ 'doc/README.rst' ] },

Note also that products accepts a list, so you can provide multiple products, in which case you will end up with additional targets in your Xcode project file.

Using the XcodeProject builder also adds a couple of options to your SConstruct file, namely

 Specifies the action Xcode was trying to take when it ran scons
 Specifies the build configuration Xcode was using when it ran scons

These options are used by the legacy build targets automatically.

The Clean action is handled automatically by the builder; if you wish to use variants, you can do so, for instance:

variant = 'Debug'
if GetOption('xcode_variant') == 'Release':
    variant = 'Release'

if variant == 'Debug':


                 variants=['Debug', 'Release'],

Take care if you do something like this:

myprog = env.Program(os.path.join('build', variant, 'MyProg'),

as you will find that the automatically generated build scheme will use the setting of variant that was active when you generated the Xcode project file (in this case, most likely the default in your scons file). You probably want to make sure the default is "Debug", or at least make sure it has some symbols.