I need to set a number of Environment variables that can be seen by GUI apps (i.e. Xcode). When running from a terminal this is trivial and is simply a case of adding a. number of
export commands to my
Unfortunately GUI apps do not see values set in
.bash_profile. I am using Catalina and it appears that Apple modifies the mechanism every time MacOs is updated. Many online guides are out of date....
This article: http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-launchd-plist/ suggests that
launchctl should do what I need but even the following simple example does not work:
In a terminal:
/bin/launchctl setenv FOO BAR
Then close the terminal and open a new one
Check the value:
The output should be
But it is unset. Note it is also unset in the original terminal so I am not convinced that the command
/bin/launchctl setenv FOO BAR is doing anything.
Note: This is about setting the environment variable for GUI apps NOT just for the terminal.
open /Applications/Xcode.app? Xcode should inherit variables set in that shell.
openin Terminal is not relevant as long as the environment variables are set. The OP should confirm whether it works for him.