Is it possible to automatically generate Xcode projects?

耗尽温柔 提交于 2019-12-03 08:42:31

I think that your question should be "Is there a way to generate an XCode project from a SCons one?". I suppose, by your asking and by reading the others, that the answer is 'no'.

SCons people should know it better. I think they will be happy if you contribute a SCons Xcode project generator.

In the meantime you may choose to switch to CMake or to create your XCode project by hand that, given a good source tree organization, may be the best pragmatic solution.

Jared Oberhaus

Look at CMake. You can generate XCode projects from it automatically. I found a previous StackOverflow question about its usage here. To get it to generate an XCode project, you use it as such:

CMake -G xcode

You can use premake (http://industriousone.com/premake) to generate Xcode projects. It can also generate Visual Studio projects.

For the benefit of anyone who lands on this question, I’ve actually just pushed an Xcode project file generator for SCons up to Bitbucket.

qmake in the Qt toolchain generates Xcode projects. You can at least download it and take a look at its source here (LGPL).

You can generate a XCode project using the python based build system called waf. You need to download and install waf with the xcode6 extension:

$ curl -o waf-1.9.7.tar.bz2 https://waf.io/waf-1.9.7.tar.bz2
$ tar xjvf waf-1.9.7.tar.bz2
$ cd waf-1.9.7
$ ./waf-light --tools=xcode6

That will create a waf executable which can build your project. You need to configure how to generate your XCode project inside a file called wscript that should reside in your project folder. The wscript file uses Python syntax. Here's an example of how you could configure your project:

def configure(conf):

    # Use environment variables to set default project configuration
    # settings
    conf.env.FRAMEWORK_VERSION = '1.0'
    conf.env.ARCHS = 'x86_64'

    # This must be called at the end of configure()
    conf.load('xcode6')

# This will build a XCode project with one target with type 'framework'
def build(bld):
    bld.load('xcode6')
    bld.framework(
        includes='include',

        # Specify source files.
        # This will become the groups (folders) inside XCode.
        # Pass a dictionary to group by name. Use a list to add everything in one
        source_files={
            'MyLibSource': bld.path.ant_glob('src/MyLib/*.cpp|*.m|*.mm'),
            'Include': bld.path.ant_glob(incl=['include/MyLib/*.h', 'include'], dir=True)
        },

        # export_headers will put the files in the
        # 'Header Build Phase' in Xcode - i.e tell XCode to ship them with your .framework
        export_headers=bld.path.ant_glob(incl=['include/MyLib/*.h', 'include/MyLib/SupportLib'], dir=True),
        target='MyLib',
        install='~/Library/Frameworks'
    )

There are a bunch of settings you can use to configure it for your project.

Then to actually generate the XCode project, cd into your project folder where the wscript is and run your waf executable like

$ ./waf configure xcode6

You could use Automator to generate them for you.

I checked and there is no prebuilt action. Therefore you would have to record your actions with Automator to do this.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!