Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Semantic Versioning library for Objective-C
Objective-C Ruby
branch: master

README.md

Semver

EDSemver is a helper library for Objective-C based on the 2.0.0 spec of Semantic Versioning.

Basic Use

#import "EDSemver.h"
EDSemver *left  = [[EDSemver alloc] initWithString:@"1.2.3-foo"];
EDSemver *right = [[EDSemver alloc] initWithString:@"1.2.3"];
return [left isGreaterThan:right]; // NO
EDSemver *version  = [[EDSemver alloc] initWithString:@"v22.0.4-alpha+1234"];
return [version major]; // 22

Properties

@property (readonly) BOOL isValid;
@property (readonly) NSInteger major;
@property (readonly) NSInteger minor;
@property (readonly) NSInteger patch;
@property (readonly) NSString *prerelease;
@property (readonly) NSString *build;

Methods

+ (NSString *)spec;
+ (instancetype)semverWithString:(NSString *)aString;

- (instancetype)initWithString:(NSString *)aString;
- (NSComparisonResult)compare:(EDSemver *)aVersion;
- (BOOL)isEqualTo:(EDSemver *)aVersion;
- (BOOL)isLessThan:(EDSemver *)aVersion;
- (BOOL)isGreaterThan:(EDSemver *)aVersion;
- (BOOL)isValid;

Testing

The test suite for EDSemver is built using OCUnit. To run the test suite, simply open the project in XCode and choose "test" from the Product menu. Please run and augment the tests prior to submitting a pull request.

ARC

EDSemver is built using ARC. If you are including EDSemver in a project that does not use Automatic Reference Counting (ARC), you will need to set the -fobjc-arc compiler flag on all of the EDSemver source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. Now select all EDSemver source files, press Enter, insert -fobjc-arc and then "Done" to enable ARC for EDSemver.

Something went wrong with that request. Please try again.