TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jun 2015 |
Maintained by Lucas Medeiros Leite.
This project brings the idea of Environment variables to your iOS project in a nicely way.
Developed by Lucas Medeiros and Alisson Sales at Codeminer42 in Fortaleza
Follow us on twitter: @Codeminer42
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
Inherit from CMEnvironment class and create properties with the same name of the key attribute of your plist. For example:
#import "CMEnvironment.h"
@interface CMAppEnvironment : CMEnvironment
@property (nonatomic, copy) NSString *baseURL;
@end
@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
CMEnvironment
requires iOS 5.x or greater.
The idea came from this post by Rob Pak.
Usage is provided under the MIT License. See LICENSE for the full details.