Skip to content

Configuration

Jasper Blues edited this page Jan 6, 2021 · 2 revisions

Key actors in an application's architecture are defined at the composition root by declaring the co-stars they interact with and configuration. Here's how to take care of the configuration.

Define Configurations in Xcode Project

In the project's 'Info' tab, define as many Xcode configurations as needed. By default we have DEBUG and RELEASE configurations.

Add Xcode Configuration

⚠️ Note that if you're using CocoaPods it is necessary to run pod install after adding new configurations.

Add Compiler Flags

Add compiler flags.

Add Swift Compiler Flags

Define a Protocol For Configuration

protocol AppConfig {

    var serviceUrl : URL { get }
    var apiKey: String { get }
    var daysToRetrieve: Int { get }

}

Return a configuration Instance Based on Current Config

In your assemblies you can now return an instance confirming to the Config protocol, depending on the current configuration. The configuration can be set in Xcode or via XCodeBuild scripts (eg within CI/CD environment).

    var config: AppConfig {
        #if STAGING
        return StagingAppConfig()
        #else
        return ProductionAppConfig()
        #endif
    }

Quick Start!

Get started in two minutes.

Main Track

Get familiar with Pilgrim.

Advanced Topics

Become a Pilgrim expert.

Under the Hood

For contributors or curious folks.

Clone this wiki locally