如何使用 XCode 4 在 iPhone 可执行文件中设置环境变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5295476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:29:16  来源:igfitidea点击:

How to set environment variables in iPhone executable using XCode 4?

xcodeenvironment-variablesxcode4nszombienszombieenabled

提问by Jason

Since switching to XCode 4, I have been having issues finding how to set environment variables (such a NSZombies) in iPhone executables. In XCode 3, you could right-click on your .app file, select "Get Info" and set environment variables. But it doesn't seem possible to do this in XCode 4. Where is it in the new UI?

自从切换到 XCode 4 以来,我一直在寻找如何在 iPhone 可执行文件中设置环境变量(例如 NSZombies)的问题。在 XCode 3 中,您可以右键单击您的 .app 文件,选择“获取信息”并设置环境变量。但在 XCode 4 中似乎不可能做到这一点。它在新 UI 中的什么位置?

回答by learner2010

another way would be if you click on the scheme drop down bar -> edit scheme -> arguments tab and then add NSZombieEnabled in the Environment Variables column and YES in the value column...

另一种方法是,如果您单击方案下拉栏 -> 编辑方案 -> 参数选项卡,然后在环境变量列中添加 NSZombieEnabled 并在值列中添加是...

回答by Basel

Please see this answer: How do I set up NSZombieEnabled in Xcode 4?

请参阅此答案: 如何在 Xcode 4 中设置 NSZombieEnabled?

EDIT: You can also go to this menu from Product => Edit Scheme

编辑:您也可以从 Product => Edit Scheme 转到此菜单

回答by bshirley

If you want act on the value of environment variable in your own code, use the following:

如果要在自己的代码中对环境变量的值进行操作,请使用以下命令:

NSDictionary *env = [[NSProcessInfo processInfo] environment];

Edit Scheme... / Run / Arguments / Environmentis where to go to edit the environment variables for runs from Xcode.

Edit Scheme... / Run / Arguments / Environment是编辑从 Xcode 运行的环境变量的地方。