通过Xcode方案添加预处理器定义 [英] Adding a Preprocessor Definition via a Xcode Scheme

查看:142
本文介绍了通过Xcode方案添加预处理器定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一些特殊的口味,我需要构建iPhone应用程序。理想情况下,我希望为每个风味制定一个方案,并且每个方案都会定义(或设置)一个或多个预处理器定义,我可以用它们在代码中进行分支,甚至可以预处理我的info.plist文件。这显然可以通过多个目标完成,但由于我可以有很多不同的应用程序风格,如果使用方案来保持目标计数不变,那就太好了。我目前的想法是在预执行脚本期间添加这些预处理器定义,但是我不能在我的生活中找到更新GCC_PREPROCESSOR_DEFINITIONS的方法。由于它是一个环境变量,我不应该有权访问GCC_PREPROCESSOR_DEFINITIONS?

I currently have a number of special "flavors" of an iPhone application that I need to build. Ideally, I would like to have a scheme for each "flavor" and each scheme would define (or set) one or more preprocessor definitions that I can use to branch on in my code and possibly even preprocess my info.plist file. This can obviously be done with multiple targets, but since I could have many different "flavors" of the app, it would be great to do it with schemes to keep the target count down. My current thought is to add these preprocessor definitions during a pre-action script, but I can not for the life of me find any way to update GCC_PREPROCESSOR_DEFINITIONS. Since it is an environment variable, shouldn't I have access to append onto GCC_PREPROCESSOR_DEFINITIONS?

推荐答案

为了满足我允许方案设置预处理器定义的要求,我提出的最佳解决方案是让scheme pre -action和post-action脚本修改一个xcconfig文件。该文件反过来更新构建配置,设置预处理器定义,甚至允许我定义预处理器定义以有条件地修改info.plist。如果有其他人遇到这种情况,请确保您考虑如何通过源代码管理来处理此文件。

To meet my requirement of allowing schemes to set preprocessor definitions, the best solution I have come up with is to have scheme pre-action and post-action scripts modify a xcconfig file. This file, in turn, updates the build configuration, setting the preprocessor definitions and will even allow me to define preprocessor definitions to conditionally modify the info.plist. If anyone else goes down this route, make sure you take into account how this file is handled by source control.

本文的问题和相关答案对我有帮助:< a href =https://stackoverflow.com/questions/1393987/how-to-append-values-in-xcconfig-variables>如何在xcconfig变量中追加值?

This article's question and associated answers was helpful to me: How to append values in xcconfig variables?

这篇关于通过Xcode方案添加预处理器定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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