Rostyslav Druzhchenko
Rostyslav Druzhchenko

Reputation: 3773

How to read a custom environment variable in a run script, Xcode 10?

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!

Upvotes: 1

Views: 2462

Answers (1)

Thanh Vu
Thanh Vu

Reputation: 1739

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

Upvotes: 5

Related Questions