Xcode构建阶段脚本编写教程或指南 [英] Tutorial or Guide for Scripting Xcode Build Phases

查看:293
本文介绍了Xcode构建阶段脚本编写教程或指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用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.


  1. 在哪里编写Xcode构建阶段脚本的常规文档(或好的教程)?
  1. Where is the general documentation (or a good tutorial) for scripting Xcode build phases?
  2. How can I add files to the Compile Sources phase?
  3. How can I discover information about the project and the folder references within it?
  4. Are there any special considerations if I want to script in Ruby or Python vs. bash scripting?


推荐答案

要使用脚本将文件添加到编译源构建阶段,您将需要操纵项目的项目。 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:

  • https://github.com/owlforestry/pbxproject
  • http://github.com/gonzoua/pbxproj/
  • https://github.com/facebook/three20/blob/master/src/scripts/Pbxproj.py
  • http://code.google.com/p/xcodeutils
  • https://github.com/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.

  • http://danwright.info/blog/2010/10/xcode-pbxproject-files/
  • http://danwright.info/blog/2010/10/xcode-pbxproject-files-2/
  • http://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构建阶段脚本编写教程或指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆