简体   繁体   English

在Xcode中运行没有环境变量的shell脚本?

[英]Running shell script without environment variables in Xcode?

Xcode sets variety of environment variables related build when running shell script. Xcode在运行shell脚本时设置了与构建相关的各种环境变量。 Is there a way to running shell script without setting of those variables? 有没有办法在不设置这些变量的情况下运行shell脚本?

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 Run Script 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. 这些shell命令运行以下命令忽略当前环境中的变量。

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. 这会禁用Xcode的所有预定义变量,因此脚本不受Xcode配置的影响,但它也不太有用,因为我们不能使用与Xcode路径相关的构建。

So, however, you can pass specific Xcode variable like this script. 但是,您可以像这个脚本一样传递特定的Xcode变量。

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

build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM