5

I have added custom script as pre-action for Build phase in my scheme (I need to perform several changes (including Info.plist manipulations) before build actually starts - thus I can't use build phase scripts because they run after Info.plist is copied to the product). Everything works fine, except the fact that this script is also executed when I clean my project. And I don't need it.

I checked environment and possible params passed to the script in different cases, but they are equal in both build and clean scenarios.

Is there any way to disable script execution during clean-up? Or may be it is possible to check somehow in the script if it was started during clean-up or during build.

I'm using Xcode 5.

Thank you in advance.

4

2 回答 2

0

您是否检查了 $ACTION 环境变量的值?它应该具有用于​​构建的“构建”值和用于清理的“清洁”值。

于 2013-11-29T10:24:04.657 回答
0

查看envbetweencleanbuildactions 的输出差异仅显示两个差异:

RUN_CLANG_STATIC_ANALYZER=NO为构建,YES为清洁, CLANG_STATIC_ANALYZER_MODE=shallow为构建,deep为清洁

我不确定这是否足以可靠地区分干净和构建,并且可能会因其他构建设置而异,但总比没有好?

FWIW,Xcode/shell 在做一个幼稚的echo $(env) > /tmp/env.log. 我用来生成可用输出的预操作片段是:diff

: > /tmp/env.log # Truncate the logfile
ENV=$(env)
while IFS= read -r line; do
    echo "$line" >> /tmp/env.log
done <<< "$ENV"

(顺便说一句,在提出问题 8 年后,这适用于 Xcode 12.5.1。YMMV!)

于 2022-01-26T11:19:05.730 回答