From 954bd65337f2c1e1cc8d67ee37576e09dec5d875 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Wed, 27 Jun 2018 00:11:43 +0100 Subject: [PATCH 1/6] Xcode version bumps and recommended project changes --- Project/semver.xcodeproj/project.pbxproj | 14 +++++++++++++- .../xcshareddata/xcschemes/semver-ios.xcscheme | 2 +- .../xcshareddata/xcschemes/semver-osx.xcscheme | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Project/semver.xcodeproj/project.pbxproj b/Project/semver.xcodeproj/project.pbxproj index 5aae8b0..bbfd887 100644 --- a/Project/semver.xcodeproj/project.pbxproj +++ b/Project/semver.xcodeproj/project.pbxproj @@ -381,7 +381,7 @@ attributes = { CLASSPREFIX = ED; LastTestingUpgradeCheck = 0730; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = "Andrew Sliwinski"; TargetAttributes = { 01DA90111D0ADA5F00D65599 = { @@ -802,11 +802,17 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -843,11 +849,17 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme b/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme index 16b41c7..3ff9edc 100644 --- a/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme +++ b/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 24 Sep 2018 13:08:38 +0100 Subject: [PATCH 2/6] Xcode 10 scheme updates --- .../semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme | 2 +- .../semver.xcodeproj/xcshareddata/xcschemes/semver-osx.xcscheme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme b/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme index 3ff9edc..b079a24 100644 --- a/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme +++ b/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 26 Sep 2018 17:33:06 +0100 Subject: [PATCH 3/6] Fixed documentation syntax and added documentation for class --- EDSemver/EDSemver.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/EDSemver/EDSemver.h b/EDSemver/EDSemver.h index 9c73e19..ad5d272 100644 --- a/EDSemver/EDSemver.h +++ b/EDSemver/EDSemver.h @@ -8,36 +8,39 @@ #import +/** + `EDSemver` is a helper library for Objective-C based on the 2.0.0 spec of [Semantic Versioning](https://semver.org/). + */ @interface EDSemver : NSObject -/*! +/** * The major version number (API changes) */ @property (readonly) NSInteger major; -/*! +/** * The minor version (functionality added in a backwards compatible manor) */ @property (readonly) NSInteger minor; -/*! +/** * The patch version (bug fixes made in a backwards compatible manor) */ @property (readonly) NSInteger patch; -/*! +/** * The prerelease number, preceded with -, e.g. 1.2.3-alpha1 */ @property (readonly, nullable) NSString *prerelease; -/*! +/** * The build number, preceded with +, e.g. 1.2.3+456 */ @property (readonly, nullable) NSString *build; -/*! +/** * The current semver spec version * * @return The spec version as a string */ + (nonnull NSString *)spec; -/*! +/** * Create a semver object with a version string * * @param aString The version string @@ -46,7 +49,7 @@ */ + (nonnull instancetype)semverWithString:(nonnull NSString *)aString; -/*! +/** * Create a semver object with a version string * * @param aString The version string @@ -55,7 +58,7 @@ */ - (nonnull instancetype)initWithString:(nonnull NSString *)aString; -/*! +/** * Compare semver objects * * @param aVersion The version string @@ -63,7 +66,7 @@ * @return The semver object */ - (NSComparisonResult)compare:(nonnull EDSemver *)aVersion; -/*! +/** * Is version equal to another version * Implemented using `compare:`. Returns NO parameter is nil * @@ -72,7 +75,7 @@ * @return YES if equal, NO otherwise */ - (BOOL)isEqualTo:(nullable id)object; -/*! +/** * Is version less than another version. * Implemented using `compare:`. Returns NO parameter is nil * @@ -81,7 +84,7 @@ * @return YES if less than, NO otherwise */ - (BOOL)isLessThan:(nullable id)object; -/*! +/** * Is version greater than than another version. * Implemented using `compare:`. Returns NO parameter is nil * @@ -91,7 +94,7 @@ */ - (BOOL)isGreaterThan:(nullable id)object; -/*! +/** * Is the semver object valid? * * @return YES if valid, NO otherwise From b19cc0bd597433045435f2ae32b7af8046707728 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Mon, 15 Apr 2019 21:07:11 +0100 Subject: [PATCH 4/6] Xcode 10.2 updates --- Project/semver.xcodeproj/project.pbxproj | 2 +- .../semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme | 2 +- .../semver.xcodeproj/xcshareddata/xcschemes/semver-osx.xcscheme | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project/semver.xcodeproj/project.pbxproj b/Project/semver.xcodeproj/project.pbxproj index bbfd887..1fd3eca 100644 --- a/Project/semver.xcodeproj/project.pbxproj +++ b/Project/semver.xcodeproj/project.pbxproj @@ -402,7 +402,7 @@ }; buildConfigurationList = C390380B178615E400ECBCAC /* Build configuration list for PBXProject "semver" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, diff --git a/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme b/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme index b079a24..67c46ba 100644 --- a/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme +++ b/Project/semver.xcodeproj/xcshareddata/xcschemes/semver-ios.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 4 Sep 2019 23:42:15 +0100 Subject: [PATCH 5/6] Implement isEqual --- EDSemver/EDSemver.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/EDSemver/EDSemver.m b/EDSemver/EDSemver.m index 88b31ed..12799eb 100644 --- a/EDSemver/EDSemver.m +++ b/EDSemver/EDSemver.m @@ -126,6 +126,10 @@ - (BOOL)isGreaterThan:(id)aVersion return [self compare:(EDSemver * _Nonnull)aVersion] == NSOrderedDescending; } +- (BOOL)isEqual:(id)object { + return [self isEqualTo:object]; +} + - (NSString *)description { return self.original; From 098eb4ee03325dac9bb6a2b6f609348d747cccf0 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Fri, 12 Jun 2020 11:42:06 +0100 Subject: [PATCH 6/6] Fix prerelease comparison --- EDSemver/EDSemver.m | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/EDSemver/EDSemver.m b/EDSemver/EDSemver.m index 12799eb..4c34b6c 100644 --- a/EDSemver/EDSemver.m +++ b/EDSemver/EDSemver.m @@ -101,12 +101,45 @@ - (NSComparisonResult)compare:(EDSemver *)aVersion if (self.prerelease.length > 0 || aVersion.prerelease.length > 0) { if (self.prerelease.length > 0 && aVersion.prerelease.length == 0) return NSOrderedAscending; if (self.prerelease.length == 0 && aVersion.prerelease.length > 0) return NSOrderedDescending; - return [self.prerelease compare:(NSString * _Nonnull)aVersion.prerelease]; + return [self comparePrerelease:aVersion.prerelease]; } return NSOrderedSame; } +- (NSComparisonResult)comparePrerelease:(NSString *)aPrerelease +{ + NSArray *aPr = [self parse:aPrerelease strict:NO]; + NSUInteger minCount = self.pr.count < aPr.count ? self.pr.count : aPr.count; + NSNumberFormatter *nf = [[NSNumberFormatter alloc] init]; + NSString *part, *aPart; + NSNumber *numPart, *aNumPart; + NSComparisonResult result; + for (NSUInteger i = 0; i < minCount; i++) { + part = self.pr[i]; + aPart = aPr[i]; + numPart = [nf numberFromString:part]; + aNumPart = [nf numberFromString:aPart]; + + if (numPart && aNumPart) { + result = [numPart compare:aNumPart]; + if (result != NSOrderedSame) { + return result; + } + } else if (!numPart && aNumPart) { + return NSOrderedDescending; + } else if (numPart && !aNumPart) { + return NSOrderedAscending; + } else { + result = [part compare:aPart]; + if (result != NSOrderedSame) { + return result; + } + } + } + + return [@(self.pr.count) compare:@(aPr.count)]; +} - (BOOL)isEqualTo:(id)aVersion {