如何在不改变Xcode项目的情况下#ifdef环境变量? [英] How can I #ifdef an environment variable without changing Xcode project?

查看:265
本文介绍了如何在不改变Xcode项目的情况下#ifdef环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测Xcode设置外的环境变量。我可以在运行时检查环境,如检测iOS应用程序是否在调试器中运行,但是有没有办法使用这样的预处理器宏?

I want to detect an environment variable outside of Xcode's settings. I can do this at runtime checking the environment like specified in Detecting if iOS app is run in debugger, but is there a way to do it with a preprocessor macro like this?

#ifdef USER_GRADHA
    // do some stuff
#else
    // do other stuff
#endif

我的环境变量已设置,但尚未到达.m文件的编译阶段。我想完成这个,而不用修改项目的预处理器宏变量,因为我希望编译对于每个用户而言都是不同的,而不必修改它。

My environment variable is set, but it is not reaching the compilation phase of the .m files. I want to accomplish this without having to modify the project's preprocessor macro variable, because I want compilation to be different for each user without them having to modify it.

推荐答案

没有。汇编非常有意地是一个确定性的过程,不依赖于外部环境。根据编译人员的不同,我所知道的编译方式的唯一方法是通过Xcode中的Source Trees偏好设计,这显然是为了让用户将源代码树保存在不同机器上的不同位置,但构建设置是一样的(因为它可以参考首选项中设置的源树位置。)

No. Compilation is very intentionally a deterministic process and does not depend on the outside environment. The only way I know of for compilation to differ based on who's compiling is via the Source Trees preference in Xcode, and that's explicitly intended for users to keep source trees in different locations on different machines but have the build setting be the same (because it can refer to the source tree location set in the preferences).

这篇关于如何在不改变Xcode项目的情况下#ifdef环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆