如何在我的应用程序中从Xcode获取环境变量 [英] How can I get an environment variable from Xcode in my app
问题描述
我已经为robbie hanson安装了XcodeColors的Xcode插件。
(参见 https://github.com/robbiehanson/XcodeColors )
I have installed the Xcode plugin for XcodeColors from robbie hanson. (see https://github.com/robbiehanson/XcodeColors)
如果我在游乐场测试它
let dict = NSProcessInfo.processInfo().environment
let env = dict["XcodeColors"] as? String
env 将为是。
但是,如果我在我的应用程序中使用相同的代码, env 将为nil,因为该应用程序正在自己的进程中运行。
But, if I use the same code in my app, env would be nil, because the app is running on their own process.
因为只有在安装了插件的情况下才打印出带有特定esc序列的彩色文本,我想获得有关Xcode env var的信息。
Because I would print out colored text with specific esc sequences only if the plugin is installed, I want get the information about the Xcode env var.
我该怎么做?
推荐答案
编辑你的计划 - >选择运行部分 - >选择参数选项卡 - >添加环境变量。
Edit your scheme -> Select the "Run" section -> Select "Arguments" tab -> Add the environment variable.
小心,如果您运行应用程序,则不设置环境变量XCode中。
Be careful, environment variables are not set if you run the app without XCode.
这篇关于如何在我的应用程序中从Xcode获取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!