All Projects → e-sites → Natrium

e-sites / Natrium

Licence: mit
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.

Programming Languages

swift
15916 projects
scheme
763 projects
swift4
162 projects

Projects that are alternatives of or similar to Natrium

Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (+20.61%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-31.3%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Bfkit Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.
Stars: ✭ 963 (+635.11%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+800.76%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Swiftlyext
SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀
Stars: ✭ 31 (-76.34%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+28064.89%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+8072.52%)
Mutual labels:  xcode, cocoapods, carthage, swift-package-manager
Microfeatures Example
📦📱 Example of iOS app built using the uFeatures architecture
Stars: ✭ 112 (-14.5%)
Mutual labels:  xcode, cocoapods, carthage
Freedom
The Freedom to Open URLs in Third-Party Browsers on iOS with Custom UIActivity Subclasses.
Stars: ✭ 85 (-35.11%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-9.16%)
Mutual labels:  xcode, cocoapods, carthage
Pluggableappdelegate
!! No longer supported !! A lightweight service-oriented AppDelegate for iOS, made in Swift.
Stars: ✭ 96 (-26.72%)
Mutual labels:  xcode, cocoapods, carthage
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+1260.31%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Device
Light weight tool for detecting the current device and screen size written in swift.
Stars: ✭ 1,503 (+1047.33%)
Mutual labels:  xcode, cocoapods, carthage
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+828.24%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Dikit
Dependency Injection Framework for Swift, inspired by KOIN.
Stars: ✭ 77 (-41.22%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (-15.27%)
Mutual labels:  xcode, cocoapods, carthage
Dtgradientbutton
Easy way to set gradient background to your buttons.
Stars: ✭ 76 (-41.98%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Appicon
AppIcon generates *.appiconset contains each resolution image for iOS
Stars: ✭ 1,454 (+1009.92%)
Mutual labels:  cli, xcode, swift-package-manager
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+1075.57%)
Mutual labels:  xcode, cocoapods, carthage
Croc
Swift emoji string parsing library
Stars: ✭ 124 (-5.34%)
Mutual labels:  xcode, cocoapods, carthage

Natrium

Natrium is part of the E-sites iOS Suite.


A pre-build (Swift) script to alter your Xcode project at build-time per environment and build configuration.

forthebadge forthebadge

Platform CocoaPods Compatible Carthage compatible Travis-ci

TL;DR

With Natrium you can change this:

#if ENVIRONMENT_STAGING
    let apiHost = "mynice.staging-api.com"
    
#elseif ENVIRONMENT_DEVELOPMENT
    let apiHost = "mynice.dev-api.com"
    
#else
    let apiHost = "mynice.api.com"
#endif

Alamofire.request("https://\(apiHost)/items").responseJSON { response in
    // ...
}

Build configurations jungle

Into this:

let apiHost = Natrium.Config.apiHost

Alamofire.request("https://\(apiHost)/items").responseJSON { response in
    // ...
}

Build configurations jungle

🧙‍♂️ With the magic of pre-action run scripts. 😱

⚠️ To use for M1 Macs prepend arch -arch x86_64 before the pre-build script: e.g:

arch -arch x86_64 "${PROJECT_DIR}/Pods/Natrium/Natrium/natrium" Production

Migration

To v8.x

  • The location of the binary is changed from (for instance in Cocoapods) Pods/Natrium/bin/natrium to Pods/Natrium/Natrium/natrium
  • The location of the generated Natrium.swift is changed to (for instance in Cocoapods): Pods/Natrium/Natrium/Natrium.swift

To v7.x

  • natrium install is removed
  • Both .natrium-env and .env files can be used for environment variables
  • CLI no longer needs --project argument
  • No longer supports Objective-c, use v6.4.0 if you still need it.

To v6.x

For Natrium v6.x you need to manually import the Natrium.swift file to your project to make it work in the new xcode build system. Read the Installation guide.

From v5.x

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.2 compatible
  • [x] Use swift instead of ruby
  • [x] Remove ImageMagick dependency
  • [x] Unit tests
  • [x] Different installation options (apart from CocoaPods)
  • [x] Better error handling / reporting

Installation

Implementation

Swift

Just add Natrium.swift (from the designated location, see installation guide) to your project's target (do not copy).

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.swift
/// Autogenerated by natrium
///
/// - see: https://github.com/e-sites/Natrium

enum Natrium {

    enum Environment: String {
        case staging = "Staging"
        case production = "Production"
    }

    enum Configuration: String {
        case debug = "Debug"
        case release = "Release"
        case adhoc = "Adhoc"
    }

    enum Config {
        static let environment: Natrium.Environment = .staging
        static let configuration: Natrium.Configuration = .debug
        static let testVariableDouble: Double = 1.0
        static let testVariableString: String = "debugString"
        static let testVariableBoolean: Bool = false
        static let testVariableInteger: Int = 125
    }
}

It can be used like so:

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

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

Result:

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

Development

Run

make xcodeproj

and open Natrium.xcodeproj

Advanced

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.

Environment variables

If you place .env in the root of your project. Natrium will use that fill to add environment variables to your already existing environment variables. The .env file should have to following format:

KEY=VALUE

for instance:

PRODUCTION_SECRET_API_TOKEN=3489uierhjkfbnvcx
STAGING_SECRET_API_TOKEN=iujk9qijs41

This way you can use #env(PRODUCTION_SECRET_API_TOKEN) in your .natrium.yml file.

For CI/CD pipelines you can simply add those environment variables to your build pipeline (in travis or buddybuild for instance).

But if you want to use it for local (debug) builds, this file can be helpful.
⚠️ Don't forget to add .env to your .gitignore

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].