Latest 5.6.0
Homepage https://github.com/e-sites/Natrium
License MIT
Platforms ios 9.0, osx 10.10, requires ARC
Frameworks Foundation
Authors

Natrium

A pre-build swift script to alter your Xcode project at build time per environment and build configuration in combination with CocoaPods. (Swift only)

forthebadge forthebadge

Platform
CocoaPods Compatible
Quality
Carthage compatible
Travis-ci

⚠️ IMPORTANT
Natrium v5.x doesn’t need a build phase script anymore.
Open your Build Phases from your target settings and remove the [Natrium] check step.

Else your build will fail during the script steps

Roadmap

  • [x] Swift 4.0 compatible
  • [x] Use swift instead of ruby
  • [x] Remove ImageMagick dependency
  • [x] Unit tests
  • [x] Different installation options (apart from CocoaPods)
  • [ ] Better error handling / reporting

Installation

Implementation

If you installed it from cocoapods:

// AppDelegate.swift

import Natrium
typealias Config = Natrium.Config

This step is optional, but this way you can use the Config class through your entire project without having to use the import Natrium statement in every seperate class.

You can now use the Config.swift file and its underlying class.

Configuration

Configuration documentation can be found here.

Usage

The example .natrium.yml as shown above, will result in the following Config.swift file:

import Foundation

/// Natrium.Config
/// Autogenerated by natrium
///
/// - see: https://github.com/e-sites/Natrium

public class Config {
    public enum EnvironmentType: String {
        case staging = "Staging"
        case production = "Production"
    }

    public enum ConfigurationType: String {
        case debug = "Debug"
        case release = "Release"
    }

    public static let environment: EnvironmentType = .staging
    public static let configuration: ConfigurationType = .debug

    // swiftlint:disable line_length
    public static let testVariableDouble: Double = 1.0
    public static let testVariableString: String = "debugString"
    public static let testVariableBoolean: Bool = false
    public static let testVariableInteger: Int = 125
    // swiftlint:enable line_length
}

It can be used like so:

class MainViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        print("bundle identifier: (Bundle.main.bundleIdentifier!)")
        print("environment: (Config.environment)")
    }
}

Result:

bundle identifier: com.esites.app.staging
environment: staging

Advanced

Re-install

To re-run the previous natrium command with the stored arguments from the Natrium.lock file:

./natrium install

Termin

Logging

In the Pods/Natrium/bin/ folder you can find natrium.log with the logs of the previous build. It might help you with debugging.

Latest podspec

{
    "name": "Natrium",
    "version": "5.6.0",
    "platforms": {
        "ios": "9.0",
        "osx": "10.10"
    },
    "summary": "An advanced pre-build swift script to alter your project per environment and build configuration.",
    "authors": {
        "Bas van Kuijck": "[email protected]"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/e-sites/Natrium",
    "source": {
        "git": "https://github.com/e-sites/Natrium.git",
        "tag": "5.6.0"
    },
    "preserve_paths": [
        "bin/natrium",
        "bin/*.{sh,xcconfig,lock,log}"
    ],
    "source_files": "bin/*.{swift, h}",
    "requires_arc": true,
    "frameworks": "Foundation",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This