From 497d474fe6f6ed822fb47749c9503bd79b7c5648 Mon Sep 17 00:00:00 2001 From: Vadym Markov Date: Mon, 23 Oct 2017 09:17:38 +0200 Subject: [PATCH 1/4] Migrate source code to Swift 4 --- Compass.xcodeproj/project.pbxproj | 30 ++++++++++++++----- .../xcschemes/Compass-Mac.xcscheme | 4 ++- .../xcschemes/Compass-iOS.xcscheme | 4 ++- .../xcschemes/Compass-tvOS.xcscheme | 4 ++- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Compass.xcodeproj/project.pbxproj b/Compass.xcodeproj/project.pbxproj index eda1a68..b0046a4 100644 --- a/Compass.xcodeproj/project.pbxproj +++ b/Compass.xcodeproj/project.pbxproj @@ -308,16 +308,16 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { D5B2E89E1C3A780C00C0327D = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; D5B2E8A81C3A780C00C0327D = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; D5C6293F1C3A7FAA007F7B7C = { CreatedOnToolsVersion = 7.2; @@ -472,14 +472,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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; @@ -523,14 +529,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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; @@ -578,7 +590,8 @@ PRODUCT_NAME = Compass; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -599,7 +612,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Compass-iOS"; PRODUCT_NAME = Compass; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -613,7 +627,8 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.CompassTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -626,7 +641,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.CompassTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Compass.xcodeproj/xcshareddata/xcschemes/Compass-Mac.xcscheme b/Compass.xcodeproj/xcshareddata/xcschemes/Compass-Mac.xcscheme index fa7292e..4defbe7 100644 --- a/Compass.xcodeproj/xcshareddata/xcschemes/Compass-Mac.xcscheme +++ b/Compass.xcodeproj/xcshareddata/xcschemes/Compass-Mac.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" From 67d873695efc7870e889d3304cc9c14235a2e849 Mon Sep 17 00:00:00 2001 From: Vadym Markov Date: Mon, 23 Oct 2017 09:22:48 +0200 Subject: [PATCH 2/4] Fix warnings --- Compass.xcodeproj/project.pbxproj | 4 ++-- Sources/Navigator.swift | 2 +- Sources/String+Extensions.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Compass.xcodeproj/project.pbxproj b/Compass.xcodeproj/project.pbxproj index b0046a4..d1afc2e 100644 --- a/Compass.xcodeproj/project.pbxproj +++ b/Compass.xcodeproj/project.pbxproj @@ -590,7 +590,7 @@ PRODUCT_NAME = Compass; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; }; name = Debug; @@ -612,7 +612,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Compass-iOS"; PRODUCT_NAME = Compass; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; }; name = Release; diff --git a/Sources/Navigator.swift b/Sources/Navigator.swift index e762c9f..3cbb289 100644 --- a/Sources/Navigator.swift +++ b/Sources/Navigator.swift @@ -26,7 +26,7 @@ public struct Navigator { /// - payload: The optional payload if you want to send in app objects /// - Returns: The Location that can be used public static func parse(url: URL, payload: Any? = nil) -> Location? { - let path = url.absoluteString.substring(from: scheme.endIndex) + let path = String(url.absoluteString.suffix(from: scheme.endIndex)) guard !(path.contains("?") || path.contains("#")) else { return parseComponents(url: url, payload: payload) diff --git a/Sources/String+Extensions.swift b/Sources/String+Extensions.swift index d144cbf..4583363 100644 --- a/Sources/String+Extensions.swift +++ b/Sources/String+Extensions.swift @@ -21,8 +21,8 @@ extension String { self.components(separatedBy: separatorCharacters).forEach { (pair) in if let equalSeparator = pair.range(of: "=") { - let name = pair.substring(to: equalSeparator.lowerBound) - let value = pair.substring(from: pair.index(equalSeparator.lowerBound, offsetBy: 1)) + let name = String(pair.prefix(upTo: equalSeparator.lowerBound)) + let value = String(pair.suffix(from: pair.index(equalSeparator.lowerBound, offsetBy: 1))) let cleaned = value.removingPercentEncoding ?? value parameters[name] = cleaned From dbf7376a345f3eb1673600eab69334b985a2c948 Mon Sep 17 00:00:00 2001 From: Vadym Markov Date: Mon, 23 Oct 2017 09:25:01 +0200 Subject: [PATCH 3/4] Update project --- Compass.xcodeproj/project.pbxproj | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Compass.xcodeproj/project.pbxproj b/Compass.xcodeproj/project.pbxproj index d1afc2e..f8a04d7 100644 --- a/Compass.xcodeproj/project.pbxproj +++ b/Compass.xcodeproj/project.pbxproj @@ -321,9 +321,14 @@ }; D5C6293F1C3A7FAA007F7B7C = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0900; }; D5C629481C3A7FAA007F7B7C = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0900; + }; + FDD723341DCA20BC00D722E4 = { + LastSwiftMigration = 0900; }; }; }; @@ -627,7 +632,7 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.CompassTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; }; name = Debug; @@ -641,7 +646,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.CompassTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; }; name = Release; @@ -667,7 +672,8 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -691,7 +697,8 @@ PRODUCT_NAME = Compass; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -707,7 +714,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Compass-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -723,7 +731,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Compass-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -746,7 +755,8 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -769,7 +779,8 @@ PRODUCT_NAME = Compass; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; From 7c1d6d6781c818041143aa9ee13f2f2ebc6cb190 Mon Sep 17 00:00:00 2001 From: Vadym Markov Date: Mon, 23 Oct 2017 09:27:36 +0200 Subject: [PATCH 4/4] Update version number --- Compass.podspec | 2 +- Compass.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Compass.podspec b/Compass.podspec index c1373e3..76b05fa 100644 --- a/Compass.podspec +++ b/Compass.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Compass" s.summary = "Compass helps you setup a central navigation system for your iOS application." - s.version = "5.1.0" + s.version = "6.0.0" s.homepage = "https://github.com/hyperoslo/Compass" s.license = 'MIT' s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" } diff --git a/Compass.xcodeproj/project.pbxproj b/Compass.xcodeproj/project.pbxproj index f8a04d7..066055c 100644 --- a/Compass.xcodeproj/project.pbxproj +++ b/Compass.xcodeproj/project.pbxproj @@ -73,8 +73,8 @@ D5B2E8A91C3A780C00C0327D /* Compass-iOS-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Compass-iOS-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; D5C629401C3A7FAA007F7B7C /* Compass.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Compass.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D5C629491C3A7FAA007F7B7C /* Compass-Mac-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Compass-Mac-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + D5D70EA31F9DD13C0018736F /* Info-tvOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-tvOS.plist"; sourceTree = ""; }; FDD723411DCA20BC00D722E4 /* Compass.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Compass.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - FDD723421DCA20BC00D722E4 /* Info-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-tvOS.plist"; path = "/Users/ferruggp/workspace/Compass/Project/Info-tvOS.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -140,9 +140,9 @@ D53620121D6C743A003C3EE8 /* Project */ = { isa = PBXGroup; children = ( + D5D70EA31F9DD13C0018736F /* Info-tvOS.plist */, D53620131D6C743A003C3EE8 /* Info-iOS.plist */, D53620141D6C743A003C3EE8 /* Info-Mac.plist */, - FDD723421DCA20BC00D722E4 /* Info-tvOS.plist */, D53620151D6C743A003C3EE8 /* Info-Tests-iOS.plist */, D53620161D6C743A003C3EE8 /* Info-Tests-Mac.plist */, );