要
Compile Sources使用脚本将文件添加到构建阶段,您将需要以
project.pbxproj编程方式操作项目的文件。
一般而言,您可以通过将
project.pbxproj文件解析为内存中的数据结构,然后通过编程接口操作该数据结构,然后将数据结构写到新
project.pbxproj文件中来实现此目的。
有几个项目可能会帮助您做到这一点,我没有尝试过其中的任何一个:
- https://github.com/owlforestry/pbxproject
- http://github.com/gonzoua/pbxproj/
- https://github.com/facebook/three20/blob/master/src/scripts/Pbxproj.py
- http://pre.google.com/p/xpreutils
- https://github.com/appcelerator/titanium_mobile/blob/master/support/iphone/pbxproj.py
这是一系列博客文章,其中包含有关XCode
project.pbxproj文件的内容和格式的大量常规信息。
- http://danwright.info/blog/2010/10/xpre-pbxproject-files/
- http://danwright.info/blog/2010/10/xpre-pbxproject-files-2/
- http://danwright.info/blog/2010/10/xpre-pbxproject-files-3/
最后,值得一提的是,对于非常简单的操作,尤其是如果您不担心
project.pbxproj文件的结构变得混乱,可以按照此的建议在
project.pbxproj命令行上解析文件,例如所以:
plutil -convert xml1 -o - myproj.xpreproj/project.pbxproj
解析愉快!



