1
votes

I have a run script in my Xcode project's Build Phases. I want to make it run only on machines where a custom environment variable is set.

In my ~/.bash_profile file I have

export MY_VARIABLE="TRUE"

There is an appropriate check in the Xcode's run script:

if [ "$MY_VARIABLE" != "TRUE" ]; then
    exit
fi

I tested this code in Terminal, and it works well, but Xcode's run script does not see $MY_VARIABLE.

Does anybody know how to make it visible in the run script?

I tried the approach recommended in this answer but it does not work for me: XCode doesn't recognize environment variables

Thank you!

1
Apps don't see the environment variables you set in your profile. See this question on SuperUser. - trojanfoe
Why don't you set a custom userdefined setting? It will be only for your account and your machine. - Mojtaba Hosseini

1 Answers

1
votes

Try add source ~/.bash_profile to begin of your run script.