Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 808
T_C Avatar asked Sep 09 '15 23:09

T_C


People also ask

Can Gradle be used for iOS?

If you are new to iOS and/or Xcode you should probably not use a mixture of Gradle and Xcode as it adds extra complexity to an already complex build environment. If you are familiar with Gradle and you also (!) have some knowledge of Xcode, then I would recommend to use Gradle.

What is Gradle in iOS?

Gradle is a build tool with a focus on build automation and support for multi-language development.

What is called Gradle in Android?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.

How many types of Gradle are there in Android?

Each module has its own build file, so every Android Studio project contains two kinds of Gradle build files.


2 Answers

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.

enter image description here

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

enter image description here

  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

like image 119
lucaslt89 Avatar answered Oct 06 '22 10:10

lucaslt89


There are several approaches you can take to build an iOS app in different flavors:

Different versions of a resource file

  • Use a custom build variable to switch between different versions of a resource file. This article discusses how to build an app with different icons.

  • For *.strings files and resources linked in *.storyboard files the suffixing approach suggested in the first item did not work for me. So I added a Run Script build phase early in the pipeline. Using a script you are free to do whatever you want before the usual build chain handles your files. This is great for dynamic file generation or advanced file selection logic. As a switch you can (again) use a custom build variable.

Modifiying code

  • Use a compiler flag as suggested here. These can be checked using the preprocessor.

  • Alternatively you can (again) check custom build variables. To make them accessible add them as a key in a plist file.

like image 25
h0b0 Avatar answered Oct 06 '22 09:10

h0b0