Latest 1.2.0
Homepage https://github.com/lucasmedeirosleite/CMEnvironment
License MIT
Platforms ios 7.0, requires ARC
Dependencies NSDictionary+TRVSUnderscoreCamelCaseAdditions
Authors

This project brings the idea of Environment variables to your iOS project in a nicely way.

Contact:

Developed by Lucas Medeiros and Alisson Sales at Codeminer42 in Fortaleza

Follow us on twitter: @Codeminer42

Development requirements

Install cocoapods

To install cocoapods you will need ruby.

gem install cocoapods

More information about cocoapods:

CocoaPods

Add the dependency to your Podfile:

platform :ios
pod 'CMEnvironment'
...

Run pod install to install the dependencies.

Setup

  • On your App-info.plist under the Information Property List put a key called Configuration with value ${CONFIGURATION}

  • Create files Debug.plist, Release.plist, Adhoc.plist under the root path of your app

  • Put your configuration values on your plists

  • In your code create an objective-c class that inherits from CMEnvironment and create properties with the same key name of your plists keys

  • See the example code

Usage

Inherit from CMEnvironment class and create properties with the same name of the key attribute of your plist. For example:

  • If you have, on your Environment.plist, a key named baseURL with the value https://api.app.com, you can do this:

#import "CMEnvironment.h"

@interface CMAppEnvironment : CMEnvironment

@property (nonatomic, copy) NSString *baseURL;

@end
  • The class and its methods:

@interface CMEnvironment : NSObject

@property (nonatomic, copy) NSString *name;

+ (id) sharedInstance; //returns a singleton instance using the application main bundle
- (id)initWithBundle:(NSBundle *)bundle;
- (BOOL)isDebug;
- (BOOL)isRelease;
- (void)changeToEnvironmenNamed:(NSString *)environment;

@end

Requirements

CMEnvironment requires iOS 5.x or greater.

The idea

The idea came from this post by Rob Pak.

License

Usage is provided under the MIT License. See LICENSE for the full details.

Latest podspec

{
    "name": "CMEnvironment",
    "version": "1.2.0",
    "summary": "Environment variables to your iOS project in a nicely way.",
    "homepage": "https://github.com/lucasmedeirosleite/CMEnvironment",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Lucas Medeiros": "[email protected]"
    },
    "source": {
        "git": "https://github.com/lucasmedeirosleite/CMEnvironment.git",
        "tag": "1.2.0"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "CMEnvironmentExample/CMEnvironment",
    "dependencies": {
        "NSDictionary+TRVSUnderscoreCamelCaseAdditions": [
            "~> 0.1.0"
        ]
    }
}

Pin It on Pinterest

Share This