我使用以下脚本在OSX Yosemite 10.10.5上运行XCode(7.0.1 7A1001):
I use the following script to run XCode (7.0.1 7A1001) on OSX Yosemite 10.10.5:
export FOO=bar #this should not be necessary, but just in case launchctl setenv FOO bar #should make it visible to all GUI applications (=XCode) open -a xcode然后,我打开一个包含两个项目的工作区: App1 和 App2 .在两个项目中,我都将$(HOME)/$(FOO)放在 Header Search Paths 字段中.
I then open a workspace with two projects: App1 and App2. In both projects I put $(HOME)/$(FOO) in the Header Search Paths field.
- 在 App1 中,按预期将其解析为/Users/ohads/bar.
- 在 App2 中,它解析为/Users/ohads/-请注意如何解析HOME变量,但不能解析FOO变量.
- In App1 it is resolved to /Users/ohads/bar as expected.
- In App2 it is resolved to /Users/ohads/ - note how the HOME variable is resolved, but the FOO variable is not.
这是怎么回事?为什么会有差异?如何使FOO在App2中工作-我缺少一些特殊的标志或声明吗?
What's going on here? Why the discrepancy? How can I make FOO work in App2 - is there some special flag or declaration I'm missing?
顺便说一句,似乎还不够怪异,即使我仅使用export,App1仍然可以工作(与launchctl相对,后者应该用于GUI应用程序,因为export应该只影响现金应用程序)
BTW, as if that's not weird enough, App1 works even when I only use export (as opposed to launchctl which is what one should use for GUI applications, seeing as export should only affect cash applications).
推荐答案看起来与新的XCode 7行为.为了使XCode使用环境变量,必须发出以下命令:
Looks like this has to do with new XCode 7 behavior. In order for XCode to use environment variables the following command must be issued:
$ defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO发出此命令后,export和launchctl均起作用(根据chepner的评论).我只能猜测它是在 App1 中工作的,因为它是在较旧的XCode版本中创建的.
Once this command is issued, both export and launchctl work (as per chepner's comment). I can only guess it was working in App1 because it was created in an older XCode version.
更多推荐
XCode无法识别环境变量
发布评论