我想使用Xcode中的脚本将一些文件添加到编译源构建阶段,该脚本从某些文件夹引用中提取。到目前为止,我还找不到很多文档。
I would like to add some files to the Compile Sources build phase using a script in Xcode, which pulls from some folder references. I haven't been able to find much documentation so far.
推荐答案
要使用脚本将文件添加到编译源构建阶段,您将需要操纵项目的项目。 pbxproj 文件。
To add files to the Compile Sources build phase using a script, you will need to manipulate your project's project.pbxproj file programmatically.
通常来说,您可以通过将 project.pbxproj 文件解析为内存数据结构来完成此操作,通过程序接口操作该数据结构,然后将数据结构写到新的 project.pbxproj 文件中。
Generally speaking, you would accomplish this by parsing the project.pbxproj file into an in-memory data structure, manipulating that data structure through a programmatic interface, and then writing the data structure out to a new project.pbxproj file.
有几个项目可能会帮助您做到这一点,我还没有尝试过这些项目:
There are several projects out there that could potentially help you do this, I haven't tried any of them:
- github/owlforestry/pbxproject
- github/gonzoua/pbxproj/
- github/facebook/three20/blob/master /src/scripts/Pbxproj.py
- http ://code.googl e/p/xcodeutils
- github/appcelerator/titanium_mobile/blob/master/support/iphone/pbxproj.py
- github/owlforestry/pbxproject
- github/gonzoua/pbxproj/
- github/facebook/three20/blob/master/src/scripts/Pbxproj.py
- code.google/p/xcodeutils
- github/appcelerator/titanium_mobile/blob/master/support/iphone/pbxproj.py
这是一系列博客文章,其中包含有关XCode project.pbxproj 文件的内容和格式的大量常规信息。
And here is a series of blog posts with great general info on the contents and format of XCode project.pbxproj files.
- danwright.info/blog/2010/10/xcode-pbxproject-files/
- > danwright.info/blog/2010/10/xcode-pbxproject-files-2/
- danwright.info/ blog / 2010/10 / xcode-pbxproject-files-3 /
- danwright.info/blog/2010/10/xcode-pbxproject-files/
- danwright.info/blog/2010/10/xcode-pbxproject-files-2/
- danwright.info/blog/2010/10/xcode-pbxproject-files-3/
最后,可能是请注意,对于非常简单的操作,尤其是如果您不担心 project.pbxproj 文件的外观弄乱时,可以按照此堆栈溢出答案,以在命令行上解析 project.pbxproj 文件像这样:
Finally, it may be worth noting that for very simple manipulations, particularly if you aren't concerned about the cosmetics of your project.pbxproj file getting messed up, you can follow the suggestion over at this Stack Overflow answer to parse the project.pbxproj file on the command line like so:
plutil-转换xml1 -o-myproj.xcodeproj / project.pbxproj
解析愉快!
更多推荐
Xcode构建阶段脚本编写教程或指南
发布评论