From 954bd65337f2c1e1cc8d67ee37576e09dec5d875 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Wed, 27 Jun 2018 00:11:43 +0100 Subject: [PATCH 1/9] 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/9] 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/9] 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/9] 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/9] 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/9] 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 { From bbd12089acd32f26075aeafe1688602d3688ef04 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Wed, 1 Dec 2021 17:33:35 +0000 Subject: [PATCH 7/9] Added swift package --- .gitignore | 112 ++++++++++-------- .../contents.xcworkspacedata | 7 ++ Package.swift | 31 +++++ 3 files changed, 103 insertions(+), 47 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index c5c9737..996a13e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,67 @@ -/** MacOS **/ + +# Created by https://www.toptal.com/developers/gitignore/api/swiftpm,xcode,macos,cocoapods +# Edit at https://www.toptal.com/developers/gitignore?templates=swiftpm,xcode,macos,cocoapods + +### CocoaPods ### +## CocoaPods GitIgnore Template + +# CocoaPods - Only use to conserve bandwidth / Save time on Pushing +# - Also handy if you have a large number of dependant pods +# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE +Pods/ + +### macOS ### +# General .DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent -/** NPM **/ -*/node_modules -*npm* +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +### SwiftPM ### +Packages +.build/ +xcuserdata +DerivedData/ +*.xcodeproj + + +### Xcode ### # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore -## Build generated -build/ -DerivedData/ +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout -## Various settings +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +*.moved-aside *.pbxuser !default.pbxuser *.mode1v3 @@ -22,46 +70,16 @@ DerivedData/ !default.mode2v3 *.perspectivev3 !default.perspectivev3 -xcuserdata/ - -## Other -*.moved-aside -*.xcuserstate - -## Obj-C/Swift specific -*.hmap -*.ipa -*.dSYM.zip -*.dSYM - -# CocoaPods -# -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# -# Pods/ -# Carthage -# -# Add this line if you want to avoid checking in source code from Carthage dependencies. -# Carthage/Checkouts +## Gcc Patch +/*.gcno -Carthage/Build +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings -# fastlane -# -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the -# screenshots whenever they are needed. -# For more information about the recommended setup visit: -# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md - -fastlane/report.xml -fastlane/screenshots - -#Code Injection -# -# After new code Injection tools there's a generated folder /iOSInjectionProject -# https://github.com/johnno1962/injectionforxcode +# End of https://www.toptal.com/developers/gitignore/api/swiftpm,xcode,macos,cocoapods -iOSInjectionProject/ \ No newline at end of file diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..9b2dba6 --- /dev/null +++ b/Package.swift @@ -0,0 +1,31 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Semver", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "Semver", + targets: ["Semver"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "Semver", + dependencies: [], + path: "EDSemver/", + publicHeadersPath: "EDSemver", + cSettings: [ + .headerSearchPath("EDSemver"), + ] + ) + ] +) From 7f94a24a47aeb03d9315985dab0b1b90ab1c9bd4 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Wed, 1 Dec 2021 18:03:31 +0000 Subject: [PATCH 8/9] Paths fix --- Package.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index 9b2dba6..3551846 100644 --- a/Package.swift +++ b/Package.swift @@ -21,10 +21,10 @@ let package = Package( .target( name: "Semver", dependencies: [], - path: "EDSemver/", - publicHeadersPath: "EDSemver", + path: "EDSemver", + publicHeadersPath: ".", cSettings: [ - .headerSearchPath("EDSemver"), + .headerSearchPath("."), ] ) ] From 04824c4629c8e9a9fc7aaf7ddabaacce0ea69c75 Mon Sep 17 00:00:00 2001 From: Nick Brook Date: Wed, 26 Jul 2023 16:06:58 +0100 Subject: [PATCH 9/9] Added header guard --- EDSemver/EDSemver.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/EDSemver/EDSemver.h b/EDSemver/EDSemver.h index ad5d272..c0db7f2 100644 --- a/EDSemver/EDSemver.h +++ b/EDSemver/EDSemver.h @@ -8,6 +8,9 @@ #import +#ifndef EDSEMVER_EDSEMVER_H +#define EDSEMVER_EDSEMVER_H + /** `EDSemver` is a helper library for Objective-C based on the 2.0.0 spec of [Semantic Versioning](https://semver.org/). */ @@ -102,3 +105,5 @@ - (BOOL)isValid; @end + +#endif