如何让 Xcode 4 运行我的 Pre-Actions?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6500822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make Xcode 4 run my Pre-Actions?
提问by 010110110101
I can't seem to get Xcode 4 to reliably execute my pre-actions. I've tried cleaning and rebuilding. It doesn't seem to do it consistently. Is it even trying? I can't tell. I've put some echos in it (it's a bash script) and nothing is happening. This all worked in Xcode 3.
我似乎无法让 Xcode 4 可靠地执行我的预操作。我试过清理和重建。它似乎并没有始终如一地做到这一点。它甚至尝试吗?我说不清。我在里面放了一些回声(它是一个 bash 脚本),但什么也没发生。这一切都适用于 Xcode 3。
采纳答案by Dru Freeman
Remember that pre-actions do not pick up env variables. They are primarily meant to load or notify that the build is starting. If it worked in Xcode 3, you may want to use it more as a build script than a pre-action.
请记住,预操作不会获取环境变量。它们主要用于加载或通知构建开始。如果它在 Xcode 3 中工作,您可能更希望将它用作构建脚本而不是预操作。
回答by webmat
Note that your pre-build actions are not executed in your project's source directory. They are executed somewhere in Library/Developer/XCode/DerivedData/
.
请注意,您的预构建操作不会在项目的源目录中执行。它们在Library/Developer/XCode/DerivedData/
.
If you want to play with files in your project's source directory before compilation, you need to prepend it with ${PROJECT_DIR}/
.
如果您想在编译前处理项目源目录中的文件,则需要在它前面加上${PROJECT_DIR}/
.
回答by Brad Goss
You need to add a "Run Script" to your build phases, and then drag it's position above the compile sources build phase.
您需要向构建阶段添加“运行脚本”,然后将其拖动到编译源构建阶段上方的位置。
I don't understand the purpose of a "pre-action" yet, doesn't seem to even get executed. However in my case I just needed a script to execute before my sources were compiled.
我还不明白“预行动”的目的,似乎甚至没有被执行。但是,在我的情况下,我只需要在编译我的源代码之前执行一个脚本。