XCode无法识别环境变量

编程入门 行业动态 更新时间:2024-10-27 20:25:45
本文介绍了XCode无法识别环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用以下脚本在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无法识别环境变量

本文发布于:2023-10-22 23:22:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519032.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环境变量   无法识别   XCode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!