Xcode - 排除自定义配置中的文件 - 更好的方法? [英] Xcode - exclude files in a custom configuration - better way?

查看:91
本文介绍了Xcode - 排除自定义配置中的文件 - 更好的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图想出一种方法来轻松切换我们的模拟数据服务和我们的实时数据服务。基本上,我们将拥有带有真实Web服务的实时服务器,但无论出于何种原因,开发人员可能希望从静态文件(文件URL)加载数据。

I'm trying to come up with a way to make it easy to switch out our "mock" data services and our live ones. Basically, we'll have live servers with real web services, but for whatever reason, a developer may want to load data from static files (file urls).

我想通过创建覆盖获取数据的方法的类别来解决这个问题,从而保持原始代码不变(它没有模拟数据的概念) )。我不想用 #ifdef 来丢弃我的代码。

I figured I would solve this problem by creating categories that override the methods that fetch the data, thus leaving original code untouched (it has no concept of the "mock" data). I don't want to litter my code with #ifdef.

我可以将#ifdef放在每个包含类别的文件的开头,我可以在配置设置中设置自定义标志,但我会而只是有办法根据配置包含或排除文件。那可能吗?你是如何解决这个问题的?

I can put an #ifdef at the very beginning of each file that has categories in it, and I can set a custom flag in the configuration settings, but I'd rather just have a way to include or exclude the files depending on the configuration. Is that possible? How do you solve this problem?

推荐答案

参见 http://lists.apple.com/archives/xcode-users/2009/Jun/msg00153.html

诀窍是在要从中排除文件的配置中定义EXCLUDED_SOURCE_FILE_NAMES,并将该自定义构建设置的值设置为文件名列表(或与之匹配的模式) ,只有那些,文件名。)

The trick is to define EXCLUDED_SOURCE_FILE_NAMES in the configuration you want to exclude the files from, and set the value of that custom build setting to a list of the file names (or a pattern that matches those, and only those, file names).

这篇关于Xcode - 排除自定义配置中的文件 - 更好的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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