在iOS开发中是否有与Android产品风味相同的概念? [英] Is there an equivalent concept in iOS development to an Android product flavor?

查看:69
本文介绍了在iOS开发中是否有与Android产品风味相同的概念?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们利用Android中的产品风格将相同的代码保留在源代码管理下,但根据所选的风格有条件地将端点定位到dev / qa / production服务器。供参考:

We utilize product flavors in Android to keep the same code under source control, but conditionally target the endpoints to dev/qa/production servers based on the flavor selected. For reference:

http://tools.android.com/tech-docs/new-build-system/build-system-concepts

例如,当我们想要在dev环境中测试新端点时,我们可以在 src / dev / res / values / endpoints.xml 中有一个具有条目的文件这是 urlbase = https://dev-endpoint.ourserver.com/v3/ 的XML等价物,并使用dev产品风格来构建一个指向的APK我们的开发环境。

For example, when we want to test a new endpoint in the "dev" environment we can have a file in src/dev/res/values/endpoints.xml that has an entry that's the XML equivalent of urlbase = https://dev-endpoint.ourserver.com/v3/, and build using the "dev" product flavor to build an APK pointed to our dev environment.

iOS开发是否有相同的概念?

Is there an equivalent concept for iOS development?

推荐答案

是。如果您在左侧栏中选择项目,然后在内部左侧栏中选择项目下的项目,并选择内部顶部栏上的信息,您将看到标记为配置的部分。您可以在此处进行配置。

Yes. If you select your project in the left bar, then select your Project under Project in the inner left bar, and select Info on the inner top bar, you will see a section labeled Configurations. You can configurations here.

然后在内部左侧栏上选择目标并选择内部顶部栏上的构建设置。在搜索框中搜索preproc。在Apple LLVM - 预处理部分下,您可以添加自定义预处理器宏。对于您的配置,请定义类似DEV = 1等的内容。

Then select your Target on the inner left bar and select Build Settings on the inner top bar. Search for "preproc" in the search box. Under the Apple LLVM - Preprocessing section, you can add custom Preprocessor Macros. For your configurations, define something like "DEV=1", etc.

现在在您的代码中,您可以说 #if DEV 等。

Now in your code you can say #if DEV, etc.

许多项目使用 AFNetworking 与之交谈他们的后端。您可以设置 baseURL AFHTTPSessionManager 子类或其他任何内容的c $ c>

Many projects use AFNetworking to talk to their back end. You can set the baseURL for your AFHTTPSessionManager subclass, or whatever, based on the defines.

这篇关于在iOS开发中是否有与Android产品风味相同的概念?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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