开发者

Running shell script without environment variables in Xcode?

开发者 https://www.devze.com 2023-01-14 04:59 出处:网络
Xcode sets variety of environment variables relate开发者_如何学编程d build when running shell script.

Xcode sets variety of environment variables relate开发者_如何学编程d build when running shell script. Is there a way to running shell script without setting of those variables?


I got a solution. Use this method in Run Script Phase target phase: https://serverfault.com/questions/176966/how-to-continue-execution-of-shell-script-after-calling-other-shell-script-with/176976#176976

These shell commands run following command ignoring variables in current environment.

env -i <command>
exec -c <command>

As an example, I used this script:

env -i ./makeall.sh

This disables all of Xcode's predefined variables, so script does not affected by Xcode configuration, but it's also less useful because we cannot use Xcode paths related build.

So, however, you can pass specific Xcode variable like this script.

build()
{
    # Don't know why, however, the environment variable passed to external script even with "env -i".
    env -i ./makeall.sh "${SYMROOT}"
}

build
0

精彩评论

暂无评论...
验证码 换一张
取 消