苹果下的环境变量

mac os x 10.7.4 以前可以使用 Evironment.plist 来控制全局的环境变量.

但到了 Lion 以后,这个方式被废除了. 同时 修改配置文件的一些方式,也最多会影响到终端的环境变量了..

On Mountain Lion all the /etc/paths and /etc/launchd.conf editing doesn't take any effect!
Apple's Developer Forums say:
"Change the Info.plist of the .app itself to contain an "LSEnvironment" dictionary with the environment variables you want.
~/.MacOSX/environment.plist is no longer supported."




那么如何配置.app的环境变量呢?

最开始我使用了比较trick的方式

从终端运行app.然后app继承了终端的环境变量...


慢慢在英文的世界中,找到如下方案.

Change the Info.plist of the .app itself to contain an "LSEnvironment" dictionary with the environment variables you want.

There will be an Info.plist per application in WhatEver.app/Content/Info.plist.
You can edit it.
Click the "+" on the Information Property List and add a dictionary called LSEnvironment.
If you type it correctly it will rename it to Environment variables. And It changed to a dictionary.
Then you click the "+" by that for each environment variable you want to add under this dirctionary.
QTDIR    /Users/...


关闭应用程序,重启生效...
最关键的一步:你需要使你刚才的改动刷新到系统里面去.
you need to force update the LaunchService database in the Terminal by using the lsregister command:
 使用如下命令.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/XXXX.app


你可能感兴趣的:(苹果下的环境变量)