Skip to content

Commit b8ef09a

Browse files
committed
Refactored for Swift Package Manager
Moved implementation files to the default SPM locations. Adapted a Package.swift from MapboxStatic.swift. Conditionally reimplemented enumerations in Swift. Added missing import statements. Upgraded to OHHTTPStubs v9.0.0.
1 parent 22104ba commit b8ef09a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+371
-143
lines changed

Cartfile.private

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 5.5
2-
github "frederoni/OHHTTPStubs" "563f48d3fab84ef04639649c770b00f4fa502cca"
2+
github "AliSoftware/OHHTTPStubs" ~> 9.0

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.5.0"
2-
github "frederoni/OHHTTPStubs" "563f48d3fab84ef04639649c770b00f4fa502cca"
1+
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.9.0"
2+
github "AliSoftware/OHHTTPStubs" "9.0.0"

MapboxGeocoder.xcodeproj/project.pbxproj

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
DA2E03F21CB0FE0200D1269A /* MBRectangularRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2E03F11CB0FE0200D1269A /* MBRectangularRegion.swift */; };
6565
DA2EC05C1CED72E900D4BA5D /* MBPlacemarkScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2EC05B1CED72E900D4BA5D /* MBPlacemarkScope.swift */; };
6666
DA2EC05E1CED732F00D4BA5D /* MBGeocodeOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2EC05D1CED732F00D4BA5D /* MBGeocodeOptions.swift */; };
67+
DA4B402F255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4B402E255BCBA7001A4F30 /* MBPlacemarkPrecision.swift */; };
68+
DA4B4030255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4B402E255BCBA7001A4F30 /* MBPlacemarkPrecision.swift */; };
69+
DA4B4031255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4B402E255BCBA7001A4F30 /* MBPlacemarkPrecision.swift */; };
70+
DA4B4032255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4B402E255BCBA7001A4F30 /* MBPlacemarkPrecision.swift */; };
6771
DA4C581920E195E300A61B00 /* MapboxGeocoder.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DDC2470419A1C3B40054B0C0 /* MapboxGeocoder.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
6872
DA4D90071DD63AEC006EC71A /* PlacemarkScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4D90061DD63AEC006EC71A /* PlacemarkScopeTests.swift */; };
6973
DA4D90081DD63AEC006EC71A /* PlacemarkScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4D90061DD63AEC006EC71A /* PlacemarkScopeTests.swift */; };
@@ -244,6 +248,7 @@
244248
DA2E03F11CB0FE0200D1269A /* MBRectangularRegion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBRectangularRegion.swift; sourceTree = "<group>"; };
245249
DA2EC05B1CED72E900D4BA5D /* MBPlacemarkScope.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBPlacemarkScope.swift; sourceTree = "<group>"; };
246250
DA2EC05D1CED732F00D4BA5D /* MBGeocodeOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBGeocodeOptions.swift; sourceTree = "<group>"; };
251+
DA4B402E255BCBA7001A4F30 /* MBPlacemarkPrecision.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBPlacemarkPrecision.swift; sourceTree = "<group>"; };
247252
DA4D90061DD63AEC006EC71A /* PlacemarkScopeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlacemarkScopeTests.swift; sourceTree = "<group>"; };
248253
DA5170961CF1B18F00CD6DCF /* MapboxGeocoder.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MapboxGeocoder.framework; sourceTree = BUILT_PRODUCTS_DIR; };
249254
DA51709F1CF1B18F00CD6DCF /* MapboxGeocoderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapboxGeocoderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -427,13 +432,15 @@
427432
DA2E03EF1CB0FDB400D1269A /* MBPlacemark.swift */,
428433
DA8B5C05225FB2F400CD1C99 /* MBPlacemarkPrecision.h */,
429434
DA8B5C06225FB2F400CD1C99 /* MBPlacemarkPrecision.m */,
435+
DA4B402E255BCBA7001A4F30 /* MBPlacemarkPrecision.swift */,
430436
DA29C8DE1CEBE90200E48A61 /* MBPlacemarkScope.h */,
431437
DA2EC05B1CED72E900D4BA5D /* MBPlacemarkScope.swift */,
432438
DA2E03F11CB0FE0200D1269A /* MBRectangularRegion.swift */,
433439
DDC2470619A1C3B40054B0C0 /* Supporting Files */,
434440
35D3DE382112410A00B62912 /* CoreLocation.swift */,
435441
);
436-
path = MapboxGeocoder;
442+
name = MapboxGeocoder;
443+
path = Sources/MapboxGeocoder;
437444
sourceTree = "<group>";
438445
};
439446
DDC246FD19A1C2D20054B0C0 /* Swift */ = {
@@ -477,7 +484,8 @@
477484
DDF1E84E1BD6F7BA00C40C78 /* Info.plist */,
478485
DDF1E8571BD700EB00C40C78 /* Fixtures */,
479486
);
480-
path = MapboxGeocoderTests;
487+
name = MapboxGeocoderTests;
488+
path = Tests/MapboxGeocoderTests;
481489
sourceTree = "<group>";
482490
};
483491
DDF1E8571BD700EB00C40C78 /* Fixtures */ = {
@@ -984,6 +992,7 @@
984992
isa = PBXSourcesBuildPhase;
985993
buildActionMask = 2147483647;
986994
files = (
995+
DA4B4030255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */,
987996
DA5170B31CF1B1E000CD6DCF /* MBRectangularRegion.swift in Sources */,
988997
DA5170B01CF1B1E000CD6DCF /* MBPlacemark.swift in Sources */,
989998
DA5170AF1CF1B1E000CD6DCF /* MBGeocoder.swift in Sources */,
@@ -1011,6 +1020,7 @@
10111020
isa = PBXSourcesBuildPhase;
10121021
buildActionMask = 2147483647;
10131022
files = (
1023+
DA4B4031255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */,
10141024
DA5170DE1CF2541C00CD6DCF /* MBRectangularRegion.swift in Sources */,
10151025
DA5170DB1CF2541C00CD6DCF /* MBPlacemark.swift in Sources */,
10161026
DA5170DA1CF2541C00CD6DCF /* MBGeocoder.swift in Sources */,
@@ -1038,6 +1048,7 @@
10381048
isa = PBXSourcesBuildPhase;
10391049
buildActionMask = 2147483647;
10401050
files = (
1051+
DA4B4032255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */,
10411052
DA5170F91CF2582F00CD6DCF /* MBRectangularRegion.swift in Sources */,
10421053
DA5170F61CF2582F00CD6DCF /* MBPlacemark.swift in Sources */,
10431054
DA5170F51CF2582F00CD6DCF /* MBGeocoder.swift in Sources */,
@@ -1061,6 +1072,7 @@
10611072
isa = PBXSourcesBuildPhase;
10621073
buildActionMask = 2147483647;
10631074
files = (
1075+
DA4B402F255BCBA7001A4F30 /* MBPlacemarkPrecision.swift in Sources */,
10641076
DA2EC05E1CED732F00D4BA5D /* MBGeocodeOptions.swift in Sources */,
10651077
DA2E03F21CB0FE0200D1269A /* MBRectangularRegion.swift in Sources */,
10661078
DDC2295E1A360843006BE405 /* MBGeocoder.swift in Sources */,
@@ -1148,7 +1160,7 @@
11481160
);
11491161
FRAMEWORK_VERSION = A;
11501162
GCC_NO_COMMON_BLOCKS = YES;
1151-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1163+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
11521164
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
11531165
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
11541166
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoder;
@@ -1179,7 +1191,7 @@
11791191
);
11801192
FRAMEWORK_VERSION = A;
11811193
GCC_NO_COMMON_BLOCKS = YES;
1182-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1194+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
11831195
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
11841196
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
11851197
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoder;
@@ -1205,7 +1217,7 @@
12051217
"$(PROJECT_DIR)/Carthage/Build/Mac",
12061218
);
12071219
GCC_NO_COMMON_BLOCKS = YES;
1208-
INFOPLIST_FILE = MapboxGeocoderTests/Info.plist;
1220+
INFOPLIST_FILE = Tests/MapboxGeocoderTests/Info.plist;
12091221
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/Carthage/Build/Mac";
12101222
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
12111223
PRODUCT_NAME = MapboxGeocoderTests;
@@ -1228,7 +1240,7 @@
12281240
"$(PROJECT_DIR)/Carthage/Build/Mac",
12291241
);
12301242
GCC_NO_COMMON_BLOCKS = YES;
1231-
INFOPLIST_FILE = MapboxGeocoderTests/Info.plist;
1243+
INFOPLIST_FILE = Tests/MapboxGeocoderTests/Info.plist;
12321244
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/Carthage/Build/Mac";
12331245
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
12341246
PRODUCT_NAME = MapboxGeocoderTests;
@@ -1253,7 +1265,7 @@
12531265
"$(PROJECT_DIR)/Carthage/Build/tvOS",
12541266
);
12551267
GCC_NO_COMMON_BLOCKS = YES;
1256-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1268+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
12571269
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
12581270
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
12591271
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoder;
@@ -1284,7 +1296,7 @@
12841296
"$(PROJECT_DIR)/Carthage/Build/tvOS",
12851297
);
12861298
GCC_NO_COMMON_BLOCKS = YES;
1287-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1299+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
12881300
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
12891301
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
12901302
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoder;
@@ -1310,7 +1322,7 @@
13101322
"$(PROJECT_DIR)/Carthage/Build/tvOS",
13111323
);
13121324
GCC_NO_COMMON_BLOCKS = YES;
1313-
INFOPLIST_FILE = MapboxGeocoderTests/Info.plist;
1325+
INFOPLIST_FILE = Tests/MapboxGeocoderTests/Info.plist;
13141326
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
13151327
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
13161328
PRODUCT_NAME = MapboxGeocoderTests;
@@ -1333,7 +1345,7 @@
13331345
"$(PROJECT_DIR)/Carthage/Build/tvOS",
13341346
);
13351347
GCC_NO_COMMON_BLOCKS = YES;
1336-
INFOPLIST_FILE = MapboxGeocoderTests/Info.plist;
1348+
INFOPLIST_FILE = Tests/MapboxGeocoderTests/Info.plist;
13371349
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
13381350
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
13391351
PRODUCT_NAME = MapboxGeocoderTests;
@@ -1357,7 +1369,7 @@
13571369
DYLIB_CURRENT_VERSION = 17;
13581370
DYLIB_INSTALL_NAME_BASE = "@rpath";
13591371
GCC_NO_COMMON_BLOCKS = YES;
1360-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1372+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
13611373
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
13621374
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
13631375
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoder;
@@ -1385,7 +1397,7 @@
13851397
DYLIB_CURRENT_VERSION = 17;
13861398
DYLIB_INSTALL_NAME_BASE = "@rpath";
13871399
GCC_NO_COMMON_BLOCKS = YES;
1388-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1400+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
13891401
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
13901402
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
13911403
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoder;
@@ -1562,7 +1574,7 @@
15621574
"DEBUG=1",
15631575
"$(inherited)",
15641576
);
1565-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1577+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
15661578
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
15671579
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
15681580
PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.$(PRODUCT_NAME:rfc1034identifier)";
@@ -1585,7 +1597,7 @@
15851597
DYLIB_COMPATIBILITY_VERSION = 1;
15861598
DYLIB_CURRENT_VERSION = 17;
15871599
DYLIB_INSTALL_NAME_BASE = "@rpath";
1588-
INFOPLIST_FILE = MapboxGeocoder/Info.plist;
1600+
INFOPLIST_FILE = Sources/MapboxGeocoder/Info.plist;
15891601
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
15901602
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
15911603
PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.$(PRODUCT_NAME:rfc1034identifier)";
@@ -1642,7 +1654,7 @@
16421654
"$(PROJECT_DIR)/Carthage/Build/iOS",
16431655
);
16441656
GCC_NO_COMMON_BLOCKS = YES;
1645-
INFOPLIST_FILE = MapboxGeocoderTests/Info.plist;
1657+
INFOPLIST_FILE = Tests/MapboxGeocoderTests/Info.plist;
16461658
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
16471659
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
16481660
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1662,7 +1674,7 @@
16621674
"$(PROJECT_DIR)/Carthage/Build/iOS",
16631675
);
16641676
GCC_NO_COMMON_BLOCKS = YES;
1665-
INFOPLIST_FILE = MapboxGeocoderTests/Info.plist;
1677+
INFOPLIST_FILE = Tests/MapboxGeocoderTests/Info.plist;
16661678
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
16671679
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
16681680
PRODUCT_NAME = "$(TARGET_NAME)";

MapboxGeocoder/MBPlacemarkScope.swift

Lines changed: 0 additions & 69 deletions
This file was deleted.

Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "MapboxGeocoder",
8+
platforms: [
9+
.macOS(.v10_12), .iOS(.v10), .watchOS(.v3), .tvOS(.v12)
10+
],
11+
products: [
12+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
13+
.library(
14+
name: "MapboxGeocoder",
15+
targets: ["MapboxGeocoder"]),
16+
],
17+
dependencies: [
18+
// Dependencies declare other packages that this package depends on.
19+
.package(name: "OHHTTPStubs", url: "https://github.com/AliSoftware/OHHTTPStubs.git", from: "9.0.0"),
20+
],
21+
targets: [
22+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
23+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
24+
.target(
25+
name: "MapboxGeocoder",
26+
exclude: [
27+
"Info.plist",
28+
"MBPlacemarkPrecision.h",
29+
"MBPlacemarkPrecision.m",
30+
"MBPlacemarkScope.h",
31+
]),
32+
.testTarget(
33+
name: "MapboxGeocoderTests",
34+
dependencies: [
35+
"MapboxGeocoder",
36+
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"),
37+
],
38+
exclude: [
39+
"Info.plist",
40+
"BridgingTests.m",
41+
],
42+
resources: [
43+
.process("fixtures"),
44+
]),
45+
]
46+
)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ _Forward geocoding_ takes a human-readable query, such as a place name or addres
7272

7373
```swift
7474
// main.swift
75-
#if !os(tvOS)
75+
#if canImport(Contacts)
7676
import Contacts
7777
#endif
7878

@@ -97,7 +97,7 @@ let task = geocoder.geocode(options) { (placemarks, attribution, error) in
9797
print("\(coordinate.latitude), \(coordinate.longitude)")
9898
// 45.270093, -66.050985
9999

100-
#if !os(tvOS)
100+
#if canImport(Contacts)
101101
let formatter = CNPostalAddressFormatter()
102102
print(formatter.string(from: placemark.postalAddress!))
103103
// 200 Queen St
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)