Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Swift 4.2, Adopt Hasher #164

Merged
merged 11 commits into from
Nov 8, 2018
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.2
8 changes: 7 additions & 1 deletion Geocoder Example/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import UIKit

#if swift(>=4.2)
typealias LaunchOptionsKey = UIApplication.LaunchOptionsKey
#else
typealias LaunchOptionsKey = UIApplicationLaunchOptionsKey
#endif

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [LaunchOptionsKey : Any]? = nil) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window!.rootViewController = ViewController(nibName: nil, bundle: nil)
window!.makeKeyAndVisible()
Expand Down
2 changes: 1 addition & 1 deletion MapboxGeocoder.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ Pod::Spec.new do |s|

s.requires_arc = true
s.module_name = "MapboxGeocoder"
s.swift_version = "4.0"
s.swift_version = "4.2"

end
32 changes: 7 additions & 25 deletions MapboxGeocoder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -738,19 +738,19 @@
};
DD342B4F19A140EE00219F77 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0910;
LastSwiftMigration = 1000;
};
DDC2470319A1C3B40054B0C0 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0910;
LastSwiftMigration = 1000;
};
DDC2472919A1C60E0054B0C0 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
};
DDF1E8491BD6F7BA00C40C78 = {
CreatedOnToolsVersion = 7.0.1;
LastSwiftMigration = 0920;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -1136,7 +1136,6 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1170,7 +1169,6 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -1196,7 +1194,6 @@
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1221,7 +1218,6 @@
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -1249,7 +1245,6 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -1283,7 +1278,6 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -1309,7 +1303,6 @@
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
name = Debug;
Expand All @@ -1333,7 +1326,6 @@
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
name = Release;
Expand Down Expand Up @@ -1448,7 +1440,7 @@
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -1499,7 +1491,7 @@
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -1519,8 +1511,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Geocoder.Swift;
PRODUCT_NAME = "Geocoder (Swift)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1539,8 +1530,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Geocoder.Swift;
PRODUCT_NAME = "Geocoder (Swift)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1565,8 +1555,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -1589,8 +1577,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1645,8 +1631,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1666,8 +1650,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion MapboxGeocoder/MBGeocoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let userAgent: String = {
chip = "arm64"
#elseif arch(i386)
chip = "i386"
#elseif os(watchOS) // Workaround for incorrect arch in machine.h for simulator ⌚️ gen 4
#elseif os(watchOS) // Workaround for incorrect arch in machine.h for watch simulator gen 4
chip = "i386"
#else
chip = "unknown"
Expand Down
3 changes: 3 additions & 0 deletions MapboxGeocoder/MBPlacemark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ open class Placemark: NSObject, Codable {
}
}

#if swift(>=4.2)
#else
@objc open override var hashValue: Int {
return identifier.hashValue
}
#endif

@objc open override func isEqual(_ object: Any?) -> Bool {
if let object = object as? Placemark {
Expand Down
6 changes: 4 additions & 2 deletions MapboxGeocoder/MBRectangularRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ open class RectangularRegion: CLRegion, Codable {
try container.encode(northEast, forKey: .northEast)
}

#if swift(>=4.2)
#else
@objc open override var hashValue: Int {
return (southWest.latitude.hashValue + southWest.longitude.hashValue
+ northEast.latitude.hashValue + northEast.longitude.hashValue)
return (southWest.latitude.hashValue + southWest.longitude.hashValue + northEast.latitude.hashValue + northEast.longitude.hashValue)
}
#endif

@objc open override func isEqual(_ object: Any?) -> Bool {
guard let object = object as? RectangularRegion else {
Expand Down