X code:每次修改源$ C ​​$构建之前运行脚本C直接 [英] Xcode: Running a script before every build that modifies source code directly

查看:188
本文介绍了X code:每次修改源$ C ​​$构建之前运行脚本C直接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,


  1. 阅读一些配置文件生成源$ C ​​$ C片段

  2. 找到相关的Objective-C源文件和

  3. 在步骤1中的生成code替换源$ C ​​$ C的某些部分。

和具有特殊的时间戳文件作为make目标和配置文件作为目标源一个Makefile:

and a Makefile that has a special timestamp file as a make target and the configuration files as target sources:

SRC = $(shell find ../config -iname "*.txt")
STAMP = $(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME).stamp
$(STAMP): $(SRC)
    python inject.py
    touch $(STAMP)

我说这个Makefile作为对构建阶段的项目目标栈顶运行脚本生成阶段。

I added this Makefile as a "Run Script Build Phase" on top of the stack of build phases for the project target.

脚本生成阶段被编译源之前运行。

The script build phase was run before compiling the source.

然而,由于脚本在执行过程中修改源$ C ​​$ C,我需要建立两次,以获取最新的版本的产品版本。以下是我想象的要发生的事情:

However, since the script modifies source code during its execution, I needed to build twice to get the most recent version of the build product. Here is what I imagine to be happening:


  1. 第1趟:X code收集依赖信息--->没有改变

  2. 第1趟:X code运行运行脚本生成阶段--->源背后X code'S回变

  3. 第1趟:X code完成建设,想没有什么东西需要更新

  4. 第2趟:X $ C $Ç收集依赖信息--->来源发生了变化,需要重新

  5. 第2趟:X code同时运行运行脚本生成阶段--->一切先进的日期

  6. 第2趟:X code进入编辑

看完<一个href=\"http://gemma.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/X$c$cBuildSystem/200-Build%5FPhases/bs%5Fbuild%5Fphases.html\">X$c$c在构建阶段文档,我尝试添加这是众所周知的每个脚本运行为运行脚本生成阶段输出时间进行更新源文件,但没有改变。由于配置文件的数量可能在我的项目有所不同,我不想指定每个输入和输出文件。

After reading Xcode documentation on Build Phases, I tried adding a source file which is known to be updated every time the script is run as the output of "Run Script Build Phases", but nothing changed. Since the number of configuration files may vary in my project, I don't want to specify every input and output file.

如何让X $ C $ç意识到构建阶段运行脚本?

How do I make Xcode aware of source file changes made during "Run Script Build Phase"?


  • 补充说明,我把剧本构建阶段其他构建阶段之前

推荐答案

到目前为止提到的每一个技术是矫枉过正。重现史蒂夫金的能见度评论:

Every technique mentioned so far is an overkill. Reproducing steve kim's comment for visibility:

在构建阶段选项卡,只需将运行脚本一步一个较高的位置(例如前编译源)。

In the build phases tab, simply drag the "Run Script" step to a higher location (e.g. before "Compile Sources").

在测试了X code 6

Tested on XCode 6

这篇关于X code:每次修改源$ C ​​$构建之前运行脚本C直接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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