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

前端 未结 2 765
野的像风
野的像风 2021-01-31 08:41

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 rel

相关标签:
2条回答
  • 2021-01-31 09:22

    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.

    0 讨论(0)
  • 2021-01-31 09:33

    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

    0 讨论(0)
提交回复
热议问题