Skip to content

Commit c5fcfe1

Browse files
authored
Merge pull request #164 from hyerra/master
Update to Swift 4.2, Adopt Hasher
2 parents 0af5646 + 58d28f0 commit c5fcfe1

File tree

7 files changed

+24
-31
lines changed

7 files changed

+24
-31
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
4.2

Geocoder Example/AppDelegate.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import UIKit
22

3+
#if swift(>=4.2)
4+
typealias LaunchOptionsKey = UIApplication.LaunchOptionsKey
5+
#else
6+
typealias LaunchOptionsKey = UIApplicationLaunchOptionsKey
7+
#endif
8+
39
@UIApplicationMain
410
class AppDelegate: UIResponder, UIApplicationDelegate {
511
var window: UIWindow?
612

7-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
13+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [LaunchOptionsKey : Any]? = nil) -> Bool {
814
window = UIWindow(frame: UIScreen.main.bounds)
915
window!.rootViewController = ViewController(nibName: nil, bundle: nil)
1016
window!.makeKeyAndVisible()

MapboxGeocoder.swift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ Pod::Spec.new do |s|
4141

4242
s.requires_arc = true
4343
s.module_name = "MapboxGeocoder"
44-
s.swift_version = "4.0"
44+
s.swift_version = "4.2"
4545

4646
end

MapboxGeocoder.xcodeproj/project.pbxproj

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -738,19 +738,19 @@
738738
};
739739
DD342B4F19A140EE00219F77 = {
740740
CreatedOnToolsVersion = 6.0;
741-
LastSwiftMigration = 0910;
741+
LastSwiftMigration = 1000;
742742
};
743743
DDC2470319A1C3B40054B0C0 = {
744744
CreatedOnToolsVersion = 6.0;
745-
LastSwiftMigration = 0910;
745+
LastSwiftMigration = 1000;
746746
};
747747
DDC2472919A1C60E0054B0C0 = {
748748
CreatedOnToolsVersion = 6.0;
749749
LastSwiftMigration = 0800;
750750
};
751751
DDF1E8491BD6F7BA00C40C78 = {
752752
CreatedOnToolsVersion = 7.0.1;
753-
LastSwiftMigration = 0920;
753+
LastSwiftMigration = 1000;
754754
};
755755
};
756756
};
@@ -1136,7 +1136,6 @@
11361136
SDKROOT = macosx;
11371137
SKIP_INSTALL = YES;
11381138
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1139-
SWIFT_VERSION = 4.0;
11401139
VERSIONING_SYSTEM = "apple-generic";
11411140
VERSION_INFO_PREFIX = "";
11421141
};
@@ -1170,7 +1169,6 @@
11701169
SKIP_INSTALL = YES;
11711170
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
11721171
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1173-
SWIFT_VERSION = 4.0;
11741172
VERSIONING_SYSTEM = "apple-generic";
11751173
VERSION_INFO_PREFIX = "";
11761174
};
@@ -1196,7 +1194,6 @@
11961194
SDKROOT = macosx;
11971195
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
11981196
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1199-
SWIFT_VERSION = 4.0;
12001197
};
12011198
name = Debug;
12021199
};
@@ -1221,7 +1218,6 @@
12211218
SDKROOT = macosx;
12221219
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
12231220
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1224-
SWIFT_VERSION = 4.0;
12251221
};
12261222
name = Release;
12271223
};
@@ -1249,7 +1245,6 @@
12491245
SDKROOT = appletvos;
12501246
SKIP_INSTALL = YES;
12511247
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1252-
SWIFT_VERSION = 4.0;
12531248
TARGETED_DEVICE_FAMILY = 3;
12541249
TVOS_DEPLOYMENT_TARGET = 9.0;
12551250
VERSIONING_SYSTEM = "apple-generic";
@@ -1283,7 +1278,6 @@
12831278
SKIP_INSTALL = YES;
12841279
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
12851280
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1286-
SWIFT_VERSION = 4.0;
12871281
TARGETED_DEVICE_FAMILY = 3;
12881282
TVOS_DEPLOYMENT_TARGET = 9.0;
12891283
VERSIONING_SYSTEM = "apple-generic";
@@ -1309,7 +1303,6 @@
13091303
SDKROOT = appletvos;
13101304
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
13111305
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1312-
SWIFT_VERSION = 4.0;
13131306
TVOS_DEPLOYMENT_TARGET = 9.0;
13141307
};
13151308
name = Debug;
@@ -1333,7 +1326,6 @@
13331326
SDKROOT = appletvos;
13341327
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
13351328
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1336-
SWIFT_VERSION = 4.0;
13371329
TVOS_DEPLOYMENT_TARGET = 9.0;
13381330
};
13391331
name = Release;
@@ -1448,7 +1440,7 @@
14481440
SDKROOT = iphoneos;
14491441
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
14501442
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1451-
SWIFT_VERSION = 3.0;
1443+
SWIFT_VERSION = 4.2;
14521444
TARGETED_DEVICE_FAMILY = "1,2";
14531445
};
14541446
name = Debug;
@@ -1499,7 +1491,7 @@
14991491
SDKROOT = iphoneos;
15001492
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
15011493
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1502-
SWIFT_VERSION = 3.0;
1494+
SWIFT_VERSION = 4.2;
15031495
TARGETED_DEVICE_FAMILY = "1,2";
15041496
VALIDATE_PRODUCT = YES;
15051497
};
@@ -1519,8 +1511,7 @@
15191511
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
15201512
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Geocoder.Swift;
15211513
PRODUCT_NAME = "Geocoder (Swift)";
1522-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1523-
SWIFT_VERSION = 4.0;
1514+
SWIFT_VERSION = 4.2;
15241515
};
15251516
name = Debug;
15261517
};
@@ -1539,8 +1530,7 @@
15391530
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Geocoder.Swift;
15401531
PRODUCT_NAME = "Geocoder (Swift)";
15411532
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1542-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1543-
SWIFT_VERSION = 4.0;
1533+
SWIFT_VERSION = 4.2;
15441534
};
15451535
name = Release;
15461536
};
@@ -1565,8 +1555,6 @@
15651555
PRODUCT_NAME = "$(TARGET_NAME)";
15661556
SKIP_INSTALL = YES;
15671557
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1568-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1569-
SWIFT_VERSION = 4.0;
15701558
VERSIONING_SYSTEM = "apple-generic";
15711559
VERSION_INFO_PREFIX = "";
15721560
};
@@ -1589,8 +1577,6 @@
15891577
PRODUCT_NAME = "$(TARGET_NAME)";
15901578
SKIP_INSTALL = YES;
15911579
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1592-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1593-
SWIFT_VERSION = 4.0;
15941580
VERSIONING_SYSTEM = "apple-generic";
15951581
VERSION_INFO_PREFIX = "";
15961582
};
@@ -1645,8 +1631,6 @@
16451631
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
16461632
PRODUCT_NAME = "$(TARGET_NAME)";
16471633
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1648-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1649-
SWIFT_VERSION = 4.0;
16501634
};
16511635
name = Debug;
16521636
};
@@ -1666,8 +1650,6 @@
16661650
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
16671651
PRODUCT_NAME = "$(TARGET_NAME)";
16681652
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1669-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1670-
SWIFT_VERSION = 4.0;
16711653
};
16721654
name = Release;
16731655
};

MapboxGeocoder/MBGeocoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let userAgent: String = {
4747
chip = "arm64"
4848
#elseif arch(i386)
4949
chip = "i386"
50-
#elseif os(watchOS) // Workaround for incorrect arch in machine.h for simulator ⌚️ gen 4
50+
#elseif os(watchOS) // Workaround for incorrect arch in machine.h for watch simulator gen 4
5151
chip = "i386"
5252
#else
5353
chip = "unknown"

MapboxGeocoder/MBPlacemark.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ open class Placemark: NSObject, Codable {
125125
}
126126
}
127127

128+
#if swift(>=4.2)
129+
#else
128130
@objc open override var hashValue: Int {
129131
return identifier.hashValue
130132
}
133+
#endif
131134

132135
@objc open override func isEqual(_ object: Any?) -> Bool {
133136
if let object = object as? Placemark {

MapboxGeocoder/MBRectangularRegion.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ open class RectangularRegion: CLRegion, Codable {
5252
try container.encode(northEast, forKey: .northEast)
5353
}
5454

55+
#if swift(>=4.2)
56+
#else
5557
@objc open override var hashValue: Int {
56-
return (southWest.latitude.hashValue + southWest.longitude.hashValue
57-
+ northEast.latitude.hashValue + northEast.longitude.hashValue)
58+
return (southWest.latitude.hashValue + southWest.longitude.hashValue + northEast.latitude.hashValue + northEast.longitude.hashValue)
5859
}
60+
#endif
5961

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

0 commit comments

Comments
 (0)