在iOS中,我们是否有类似Android上的Gradle Build Flavors之类的东西 [英] In iOS do we have something like Gradle Build Flavors on Android

查看:232
本文介绍了在iOS中,我们是否有类似Android上的Gradle Build Flavors之类的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS中,我们是否有类似Android上的Gradle Build Flavors之类的东西。



基本上我想将Applause SDK与我的应用程序集成在一起,但我不希望该代码成为发行版本的一部分。我只想使用掌声sdk仅在内部分发应用程序并进行错误报告。



如果没有像口味这样的东西,那么做这件事的最佳方法是什么。

解决方案

您可以在Xcode中使用Schemes和Build配置。这是官方文档:



简而言之,过程为:


  1. 创建构建配置

  2. 设置一些自定义标志对于该配置。为此,转到目标,选择构建设置选项卡,然后搜索预处理器宏。在那里,您将能够添加自定义标志


  1. 编辑方案或创建新方案以使用您的构建配置。

  2. 在您的代码,则必须使用预处理器宏询问该标志是否可用:


#ifdef APP_STORE
//做点
#endif


In iOS do we have something like Gradle Build Flavors on Android.

Basically I want to integrate Applause SDK with my app but I dont want that code to be part of the release build. I only want to use applause sdk only to distribute the app internally and for bug reporting.

If there is nothing like flavors then what is the best way to do this.

解决方案

You can make use of Schemes and Build configurations in Xcode. Here's the official documentation: https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/BasingBuildConfigurationsonConfigurationFiles.html

After you create a build configuration, you should edit your scheme to use that build configuration. For that click on your scheme and select Edit Scheme.

In short, the process is:

  1. Create a build configuration
  2. Set some custom flags for that configuration. For this, go to your target, select Build Settings tab, and search for Preprocessor Macros. There you'll be able to add custom flags

  1. Edit your scheme, or create a new scheme, to use your build configuration.
  2. In your code, you'll have to ask if the flag is available using preprocessor macros:

#ifdef APP_STORE //do something #endif

这篇关于在iOS中,我们是否有类似Android上的Gradle Build Flavors之类的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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