As you may already know, it’s not allowed to use the Applivery SDK in production Apps that are released in the official Apps Stores (Google Play and Apple App Store). In addition, it is a practice that we do not recommend, and that could cause the rejection of your App during the review process.
This tutorial will guide you through the process of conditionally excluding the Applivery SDK based on the Environment of the App (i.e., Live, Test, Staging, or Quality).
For the purpose of this tutorial, we are considering that you already know the basics of how to manage different environments by using Schemas and Configurations. If not, we recommend taking a look at the following blog post.
Go to File > New > File… (Command + N) -> Configuration Settings file and choose a descriptive name for your configuration file. For this example, we will create two different Configuration Files: one for the development environment (DEV.xcconfig) and another one for the production environment (PROD.xcconfig).
DEV.xcconfig
// App Info
APP_NAME = My Awesome App [DEV]
BUNDLE_IDENTIFIER = com.acme.awesome.dev
// Environment
ENVIRONMENT = DEV
// Applivery Options
APPLIVERY_TOKEN = b7C...2I6
PROD.xcconfig
// App Info
APP_NAME = My Awesome App [PROD]
BUNDLE_IDENTIFIER = com.acme.awesome.prod
// Environment
ENVIRONMENT = PROD
// Applivery Options
APPLIVERY_TOKEN = 1gxC...66f
EXCLUDED_SOURCE_FILE_NAMES = Applivery.framework
Since we do not want the Applivery SDK to be included in the Production Environment, we have added the following line of code EXCLUDED_SOURCE_FILE_NAMES = Applivery.framework that will exclude the source files of the Applivery SDK during the process of building the App.
Additionally, we will take advantage of this Configuration File to also define a different Applivery SDK Token for each of the environments.
Now that we have multiple configuration files that describe the particularities of your Environments, it’s time to link them with your project Schemas. To do so, under your Project Configurations settings, select the appropriate Configuration File by using the Build Configurations dropdown menu.


Additionally, to use the Info.plist Keys in your code, you can follow the next approach:
// Get values from Info.plist
public func InfoDictionary(_ key: String) -> String {
guard let constant = Bundle.main.infoDictionary?[key] as? String else {
return "CONSTANT NOT FOUND"
}
return constant
}
// Example of usage of the above function when starting the Applivery SDK
applivery.start(token:InfoDictionary("APPLIVERY_TOKEN"), appStoreRelease: false)
Since the Import of the Applivery SDK has been excluded from the .xcconfig file when building the code, we recommend using Swift Compiler Custom Flags and Active Compilation Conditions to declare a set of constants that will help you conditionally start the Applivery SDK. Here is an example:
#if !APPSTORE
import Applivery
#endif
struct AppliveryWrapper {
func setup() {
#if !APPSTORE && !DEBUG
let applivery = Applivery.shared
applivery.logLevel = .info
applivery.start(token:InfoDictionary("APPLIVERY_TOKEN"), appStoreRelease: false)
#endif
}
}

Alternatively, if you do not want to use Configuration Files, you can exclude certain Source File Names under the Build Settings of your project for each of your Project Schemes.
Remember to thoroughly test your app in all environments to ensure the Applivery SDK is correctly excluded from production builds.