diff --git a/.swift-version b/.swift-version index 5186d0706..95ee81a41 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 +5.9 diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Cartfile.private b/Cartfile.private index 4222f4a9d..8d57a9491 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 3.4 -github "AliSoftware/OHHTTPStubs" ~> 6.0 \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved index 93db12e08..a2c7309db 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,2 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "3.7.8" -github "AliSoftware/OHHTTPStubs" "6.1.0" -github "raphaelmor/Polyline" "v5.1.0" \ No newline at end of file +github "raphaelmor/Polyline" "v5.1.0" diff --git a/MapboxDirections.swift.podspec b/MapboxDirections.swift.podspec deleted file mode 100644 index d7b7d4ce1..000000000 --- a/MapboxDirections.swift.podspec +++ /dev/null @@ -1,50 +0,0 @@ -Pod::Spec.new do |s| - - # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - s.name = "MapboxDirections.swift" - s.version = "0.23.0" - s.summary = "Mapbox Directions API wrapper for Swift and Objective-C." - - s.description = <<-DESC - MapboxDirections.swift makes it easy to connect your iOS, macOS, tvOS, or watchOS application to the Mapbox Directions API. Quickly get driving, cycling, or walking directions, whether the trip is nonstop or it has multiple stopping points, all using a simple interface reminiscent of MapKit’s `MKDirections` API. The Mapbox Directions API is powered by the OSRM routing engine and open data from the OpenStreetMap project. - DESC - - s.homepage = "https://www.mapbox.com/directions/" - s.documentation_url = "https://www.mapbox.com/mapbox-navigation-ios/directions/" - - # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - s.license = { :type => "ISC", :file => "LICENSE.md" } - - # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - s.author = { "Mapbox" => "mobile@mapbox.com" } - s.social_media_url = "https://twitter.com/mapbox" - - # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - # When using multiple platforms - s.ios.deployment_target = "8.0" - s.osx.deployment_target = "10.10" - s.watchos.deployment_target = "2.0" - s.tvos.deployment_target = "9.0" - - - # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - s.source = { :git => "https://github.com/mapbox/MapboxDirections.swift.git", :tag => "v#{s.version.to_s}" } - - # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - s.source_files = ["MapboxDirections", "MapboxDirections/*/*"] - - # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - - s.requires_arc = true - s.module_name = "MapboxDirections" - s.swift_version = "4.0" - - s.dependency "Polyline", "~> 4.2" - -end diff --git a/MapboxDirections/MBAttribute.swift b/MapboxDirections/MBAttribute.swift index c227628d1..b4bb18102 100644 --- a/MapboxDirections/MBAttribute.swift +++ b/MapboxDirections/MBAttribute.swift @@ -1,4 +1,5 @@ import Foundation +import MapboxDirectionsObjc public typealias AttributeOptions = MBAttributeOptions diff --git a/MapboxDirections/MBDirections.swift b/MapboxDirections/MBDirections.swift index a8e0d2355..6afb1e2db 100644 --- a/MapboxDirections/MBDirections.swift +++ b/MapboxDirections/MBDirections.swift @@ -1,3 +1,5 @@ +import CoreLocation + typealias JSONDictionary = [String: Any] /// Indicates that an error occurred in MapboxDirections. diff --git a/MapboxDirections/MBDirectionsOptions.swift b/MapboxDirections/MBDirectionsOptions.swift index f1822f511..4cb7f4df5 100644 --- a/MapboxDirections/MBDirectionsOptions.swift +++ b/MapboxDirections/MBDirectionsOptions.swift @@ -1,5 +1,6 @@ import Foundation import Polyline +import MapboxDirectionsObjc /** A `RouteShapeFormat` indicates the format of a route or match shape in the raw HTTP response. diff --git a/MapboxDirections/MBDirectionsResult.swift b/MapboxDirections/MBDirectionsResult.swift index 8c4615ed7..3999fa151 100644 --- a/MapboxDirections/MBDirectionsResult.swift +++ b/MapboxDirections/MBDirectionsResult.swift @@ -1,3 +1,4 @@ +import CoreLocation import Polyline /** diff --git a/MapboxDirections/MBIntersection.swift b/MapboxDirections/MBIntersection.swift index 84eae3ec6..e6e365c4a 100644 --- a/MapboxDirections/MBIntersection.swift +++ b/MapboxDirections/MBIntersection.swift @@ -1,4 +1,5 @@ import Foundation +import CoreLocation /** A single cross street along a step. diff --git a/MapboxDirections/MBLaneIndication.swift b/MapboxDirections/MBLaneIndication.swift index 2c51f6239..8ef63807a 100644 --- a/MapboxDirections/MBLaneIndication.swift +++ b/MapboxDirections/MBLaneIndication.swift @@ -1,4 +1,5 @@ import Foundation +import MapboxDirectionsObjc public typealias LaneIndication = MBLaneIndication diff --git a/MapboxDirections/MBLaneIndicationComponent.swift b/MapboxDirections/MBLaneIndicationComponent.swift index b6a5e932d..1827e901a 100644 --- a/MapboxDirections/MBLaneIndicationComponent.swift +++ b/MapboxDirections/MBLaneIndicationComponent.swift @@ -1,3 +1,5 @@ +import Foundation + /** A component that represents a lane representation of an instruction. */ diff --git a/MapboxDirections/MBRoadClasses.swift b/MapboxDirections/MBRoadClasses.swift index 74b8a3a58..5e3671e2b 100644 --- a/MapboxDirections/MBRoadClasses.swift +++ b/MapboxDirections/MBRoadClasses.swift @@ -1,4 +1,5 @@ import Foundation +import MapboxDirectionsObjc public typealias RoadClasses = MBRoadClasses diff --git a/MapboxDirections/MBRoute.swift b/MapboxDirections/MBRoute.swift index 4e8832597..b462b6911 100644 --- a/MapboxDirections/MBRoute.swift +++ b/MapboxDirections/MBRoute.swift @@ -1,3 +1,4 @@ +import CoreLocation import Polyline /** diff --git a/MapboxDirections/MBRouteLeg.swift b/MapboxDirections/MBRouteLeg.swift index b2ddf06be..38ee87379 100644 --- a/MapboxDirections/MBRouteLeg.swift +++ b/MapboxDirections/MBRouteLeg.swift @@ -1,4 +1,6 @@ +import CoreLocation import Polyline +import MapboxDirectionsObjc /** A `RouteLeg` object defines a single leg of a route between two waypoints. If the overall route has only two waypoints, it has a single `RouteLeg` object that covers the entire route. The route leg object includes information about the leg, such as its name, distance, and expected travel time. Depending on the criteria used to calculate the route, the route leg object may also include detailed turn-by-turn instructions. diff --git a/MapboxDirections/MBRouteOptions.swift b/MapboxDirections/MBRouteOptions.swift index 0d3a65b9d..63919273b 100644 --- a/MapboxDirections/MBRouteOptions.swift +++ b/MapboxDirections/MBRouteOptions.swift @@ -1,3 +1,6 @@ +import CoreLocation +import MapboxDirectionsObjc + /** A `RouteOptions` object is a structure that specifies the criteria for results returned by the Mapbox Directions API. diff --git a/MapboxDirections/MBRouteStep.swift b/MapboxDirections/MBRouteStep.swift index 206a6033e..f10d1f9f2 100644 --- a/MapboxDirections/MBRouteStep.swift +++ b/MapboxDirections/MBRouteStep.swift @@ -1,4 +1,6 @@ +import CoreLocation import Polyline +import MapboxDirectionsObjc /** A `TransportType` specifies the mode of transportation used for part of a route. diff --git a/MapboxDirections/MBSpokenInstruction.swift b/MapboxDirections/MBSpokenInstruction.swift index d49912e8c..2d365b56c 100644 --- a/MapboxDirections/MBSpokenInstruction.swift +++ b/MapboxDirections/MBSpokenInstruction.swift @@ -1,4 +1,4 @@ -import Foundation +import CoreLocation /** An instruction about an upcoming `RouteStep`’s maneuver, optimized for speech synthesis. diff --git a/MapboxDirections/MBVisualInstruction.swift b/MapboxDirections/MBVisualInstruction.swift index 8baa0a480..a55f02a38 100644 --- a/MapboxDirections/MBVisualInstruction.swift +++ b/MapboxDirections/MBVisualInstruction.swift @@ -1,4 +1,5 @@ import Foundation +import CoreLocation /** The contents of a banner that should be displayed as added visual guidance for a route. The banner instructions are children of the steps during which they should be displayed, but they refer to the maneuver in the following step. diff --git a/MapboxDirections/MBVisualInstructionBanner.swift b/MapboxDirections/MBVisualInstructionBanner.swift index 27d035def..d36c8c728 100644 --- a/MapboxDirections/MBVisualInstructionBanner.swift +++ b/MapboxDirections/MBVisualInstructionBanner.swift @@ -1,4 +1,4 @@ -import Foundation +import CoreLocation /** A visual instruction banner contains all the information necessary for creating a visual cue about a given `RouteStep`. diff --git a/MapboxDirections/MBWaypoint.swift b/MapboxDirections/MBWaypoint.swift index 3c34248fa..3bc5e6adb 100644 --- a/MapboxDirections/MBWaypoint.swift +++ b/MapboxDirections/MBWaypoint.swift @@ -1,3 +1,5 @@ +import CoreLocation + /** A `Waypoint` object indicates a location along a route. It may be the route’s origin or destination, or it may be another location that the route visits. A waypoint object indicates the location’s geographic location along with other optional information, such as a name or the user’s direction approaching the waypoint. You create a `RouteOptions` object using waypoint objects and also receive waypoint objects in the completion handler of the `Directions.calculate(_:completionHandler:)` method. */ diff --git a/MapboxDirections/Match/MBMatch.swift b/MapboxDirections/Match/MBMatch.swift index 079f2b9ac..7a7fb803d 100644 --- a/MapboxDirections/Match/MBMatch.swift +++ b/MapboxDirections/Match/MBMatch.swift @@ -1,3 +1,4 @@ +import CoreLocation import Polyline /** diff --git a/MapboxDirections/Match/MBMatchOptions.swift b/MapboxDirections/Match/MBMatchOptions.swift index 62b822526..55bcef271 100644 --- a/MapboxDirections/Match/MBMatchOptions.swift +++ b/MapboxDirections/Match/MBMatchOptions.swift @@ -1,4 +1,5 @@ import Foundation +import MapboxDirectionsObjc /** A `MatchOptions` object is a structure that specifies the criteria for results returned by the Mapbox Map Matching API. diff --git a/MapboxDirections/Match/MBTracepoint.swift b/MapboxDirections/Match/MBTracepoint.swift index cc89bb1d4..09c38dd78 100644 --- a/MapboxDirections/Match/MBTracepoint.swift +++ b/MapboxDirections/Match/MBTracepoint.swift @@ -1,4 +1,5 @@ -import Foundation +import CoreLocation + /** A `Tracepoint` represents a location matched to the road network. */ diff --git a/MapboxDirections/MBAttribute.h b/MapboxDirectionsObjc/MBAttribute.h similarity index 100% rename from MapboxDirections/MBAttribute.h rename to MapboxDirectionsObjc/MBAttribute.h diff --git a/MapboxDirections/MBLaneIndication.h b/MapboxDirectionsObjc/MBLaneIndication.h similarity index 100% rename from MapboxDirections/MBLaneIndication.h rename to MapboxDirectionsObjc/MBLaneIndication.h diff --git a/MapboxDirections/MBRoadClasses.h b/MapboxDirectionsObjc/MBRoadClasses.h similarity index 100% rename from MapboxDirections/MBRoadClasses.h rename to MapboxDirectionsObjc/MBRoadClasses.h diff --git a/MapboxDirections/MBRouteOptions.h b/MapboxDirectionsObjc/MBRouteOptions.h similarity index 100% rename from MapboxDirections/MBRouteOptions.h rename to MapboxDirectionsObjc/MBRouteOptions.h diff --git a/MapboxDirections/MBRouteOptions.m b/MapboxDirectionsObjc/MBRouteOptions.m similarity index 100% rename from MapboxDirections/MBRouteOptions.m rename to MapboxDirectionsObjc/MBRouteOptions.m diff --git a/MapboxDirections/MapboxDirections.h b/MapboxDirectionsObjc/include/MapboxDirections.h similarity index 71% rename from MapboxDirections/MapboxDirections.h rename to MapboxDirectionsObjc/include/MapboxDirections.h index 14040c080..b82b3e392 100644 --- a/MapboxDirections/MapboxDirections.h +++ b/MapboxDirectionsObjc/include/MapboxDirections.h @@ -7,7 +7,7 @@ FOUNDATION_EXPORT double MapboxDirectionsVersionNumber; //! Project version string for MapboxDirections. FOUNDATION_EXPORT const unsigned char MapboxDirectionsVersionString[]; -#import "MBLaneIndication.h" -#import "MBAttribute.h" -#import "MBRouteOptions.h" -#import "MBRoadClasses.h" +#import "../MBLaneIndication.h" +#import "../MBAttribute.h" +#import "../MBRouteOptions.h" +#import "../MBRoadClasses.h" diff --git a/MapboxDirectionsTests/AnnotationTests.swift b/MapboxDirectionsTests/AnnotationTests.swift index 0f52a74bf..761c64116 100644 --- a/MapboxDirectionsTests/AnnotationTests.swift +++ b/MapboxDirectionsTests/AnnotationTests.swift @@ -1,10 +1,12 @@ import XCTest +import CoreLocation import OHHTTPStubs +import OHHTTPStubsSwift @testable import MapboxDirections class AnnotationTests: XCTestCase { override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } @@ -23,8 +25,8 @@ class AnnotationTests: XCTestCase { stub(condition: isHost("api.mapbox.com") && containsQueryParams(queryParams)) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "annotation", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "annotation", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } let options = RouteOptions(coordinates: [ diff --git a/MapboxDirectionsTests/DirectionsTests.swift b/MapboxDirectionsTests/DirectionsTests.swift index 6ac420c88..4ea218740 100644 --- a/MapboxDirectionsTests/DirectionsTests.swift +++ b/MapboxDirectionsTests/DirectionsTests.swift @@ -11,7 +11,7 @@ class DirectionsTests: XCTestCase { } override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } diff --git a/MapboxDirectionsTests/IntructionsTests.swift b/MapboxDirectionsTests/IntructionsTests.swift index 705ef3e7a..3e59dcf13 100644 --- a/MapboxDirectionsTests/IntructionsTests.swift +++ b/MapboxDirectionsTests/IntructionsTests.swift @@ -1,10 +1,12 @@ import XCTest +import CoreLocation import OHHTTPStubs +import OHHTTPStubsSwift @testable import MapboxDirections class SpokenInstructionsTests: XCTestCase { override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } @@ -26,8 +28,8 @@ class SpokenInstructionsTests: XCTestCase { stub(condition: isHost("api.mapbox.com") && containsQueryParams(queryParams)) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "instructions", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "instructions", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } let startWaypoint = Waypoint(location: CLLocation(latitude: 37.780602, longitude: -122.431373), heading: nil, name: "the hotel") @@ -114,8 +116,8 @@ class SpokenInstructionsTests: XCTestCase { ] stub(condition: isHost("api.mapbox.com") && containsQueryParams(queryParams)) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "subLaneInstructions", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "subLaneInstructions", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } let startWaypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.132063, longitude: -84.531074)) @@ -181,8 +183,8 @@ class SpokenInstructionsTests: XCTestCase { ] stub(condition: isHost("api.mapbox.com") && containsQueryParams(queryParams)) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "subVisualInstructions", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "subVisualInstructions", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } let startWaypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.775469, longitude: -122.449158)) diff --git a/MapboxDirectionsTests/MatchTests.swift b/MapboxDirectionsTests/MatchTests.swift index c042bd764..4ec5dcb14 100644 --- a/MapboxDirectionsTests/MatchTests.swift +++ b/MapboxDirectionsTests/MatchTests.swift @@ -1,10 +1,12 @@ import XCTest +import CoreLocation import OHHTTPStubs +import OHHTTPStubsSwift @testable import MapboxDirections class MatchTests: XCTestCase { override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } @@ -21,8 +23,8 @@ class MatchTests: XCTestCase { stub(condition: isHost("api.mapbox.com") && isMethodPOST() && isPath("/matching/v5/mapbox/driving")) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "match", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "match", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } var match: Match! @@ -109,8 +111,8 @@ class MatchTests: XCTestCase { stub(condition: isHost("api.mapbox.com") && isMethodPOST() && isPath("/matching/v5/mapbox/driving")) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "null-tracepoint", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "null-tracepoint", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } var match: Match! diff --git a/MapboxDirectionsTests/RoutableMatchTests.swift b/MapboxDirectionsTests/RoutableMatchTests.swift index b807046bd..54be3c5a5 100644 --- a/MapboxDirectionsTests/RoutableMatchTests.swift +++ b/MapboxDirectionsTests/RoutableMatchTests.swift @@ -1,10 +1,12 @@ import XCTest +import CoreLocation import OHHTTPStubs +import OHHTTPStubsSwift @testable import MapboxDirections class RoutableMatchTest: XCTestCase { override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } @@ -21,8 +23,8 @@ class RoutableMatchTest: XCTestCase { stub(condition: isHost("api.mapbox.com") && isMethodPOST() && isPath("/matching/v5/mapbox/driving")) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "match", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "match", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } var route: Route! diff --git a/MapboxDirectionsTests/RouteOptionsTests.swift b/MapboxDirectionsTests/RouteOptionsTests.swift index 8665e6cf6..b1fc89d51 100644 --- a/MapboxDirectionsTests/RouteOptionsTests.swift +++ b/MapboxDirectionsTests/RouteOptionsTests.swift @@ -1,4 +1,5 @@ import XCTest +import CoreLocation @testable import MapboxDirections class RouteOptionsTests: XCTestCase { @@ -50,7 +51,7 @@ class RouteOptionsTests: XCTestCase { private func response(for fixtureName: String, waypoints: [Waypoint] = testWaypoints) -> (waypoints:[Waypoint], route:Route)? { - let testBundle = Bundle(for: type(of: self)) + let testBundle = Bundle.module guard let fixtureURL = testBundle.url(forResource:fixtureName, withExtension:"json") else { XCTFail(); return nil } guard let fixtureData = try? Data(contentsOf: fixtureURL, options:.mappedIfSafe) else {XCTFail(); return nil } guard let fixtureOpaque = try? JSONSerialization.jsonObject(with: fixtureData), let fixture = fixtureOpaque as? JSONDictionary else { XCTFail(); return nil } diff --git a/MapboxDirectionsTests/RouteStepTests.swift b/MapboxDirectionsTests/RouteStepTests.swift index f1dd46565..b23def21c 100644 --- a/MapboxDirectionsTests/RouteStepTests.swift +++ b/MapboxDirectionsTests/RouteStepTests.swift @@ -1,4 +1,5 @@ import XCTest +import CoreLocation @testable import MapboxDirections class RoadTests: XCTestCase { diff --git a/MapboxDirectionsTests/V4Tests.swift b/MapboxDirectionsTests/V4Tests.swift index e9a1d90c0..2dfe1781a 100644 --- a/MapboxDirectionsTests/V4Tests.swift +++ b/MapboxDirectionsTests/V4Tests.swift @@ -1,10 +1,12 @@ import XCTest +import CoreLocation import OHHTTPStubs +import OHHTTPStubsSwift @testable import MapboxDirections class V4Tests: XCTestCase { override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } @@ -21,8 +23,8 @@ class V4Tests: XCTestCase { stub(condition: isHost("api.mapbox.com") && isPath("/v4/directions/mapbox.driving/-122.42,37.78;-77.03,38.91.json") && containsQueryParams(queryParams)) { _ in - let path = Bundle(for: type(of: self)).path(forResource: "v4_driving_dc_\(shapeFormat)", ofType: "json") - return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) + let path = Bundle.module.path(forResource: "v4_driving_dc_\(shapeFormat)", ofType: "json") + return HTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"]) } let options = RouteOptionsV4(coordinates: [ diff --git a/MapboxDirectionsTests/V5Tests.swift b/MapboxDirectionsTests/V5Tests.swift index 9317452db..e23fb4c47 100644 --- a/MapboxDirectionsTests/V5Tests.swift +++ b/MapboxDirectionsTests/V5Tests.swift @@ -1,11 +1,13 @@ import XCTest +import CoreLocation import OHHTTPStubs +import OHHTTPStubsSwift import Polyline @testable import MapboxDirections class V5Tests: XCTestCase { override func tearDown() { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() super.tearDown() } @@ -25,12 +27,12 @@ class V5Tests: XCTestCase { stub(condition: isHost("api.mapbox.com") && isPath("/directions/v5/mapbox/driving/-122.42,37.78;-77.03,38.91.json") && containsQueryParams(queryParams)) { _ in - let path = Bundle(for: type(of: self)).path(forResource: filePath ?? "v5_driving_dc_\(shapeFormat)", ofType: "json") + let path = Bundle.module.path(forResource: filePath ?? "v5_driving_dc_\(shapeFormat)", ofType: "json") let filePath = URL(fileURLWithPath: path!) let data = try! Data(contentsOf: filePath, options: []) let jsonObject = try! JSONSerialization.jsonObject(with: data, options: []) let transformedData = transformer?(jsonObject as! JSONDictionary) ?? jsonObject - return OHHTTPStubsResponse(jsonObject: transformedData, statusCode: 200, headers: ["Content-Type": "application/json"]) + return HTTPStubsResponse(jsonObject: transformedData, statusCode: 200, headers: ["Content-Type": "application/json"]) } let options = RouteOptions(coordinates: [ diff --git a/MapboxDirectionsTests/Fixtures/Match/match.json b/MapboxDirectionsTests/resources/Match/match.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/Match/match.json rename to MapboxDirectionsTests/resources/Match/match.json diff --git a/MapboxDirectionsTests/Fixtures/Match/null-tracepoint.json b/MapboxDirectionsTests/resources/Match/null-tracepoint.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/Match/null-tracepoint.json rename to MapboxDirectionsTests/resources/Match/null-tracepoint.json diff --git a/MapboxDirectionsTests/Fixtures/Responses/apiDestinationName.json b/MapboxDirectionsTests/resources/Responses/apiDestinationName.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/Responses/apiDestinationName.json rename to MapboxDirectionsTests/resources/Responses/apiDestinationName.json diff --git a/MapboxDirectionsTests/Fixtures/Responses/noDestinationName.json b/MapboxDirectionsTests/resources/Responses/noDestinationName.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/Responses/noDestinationName.json rename to MapboxDirectionsTests/resources/Responses/noDestinationName.json diff --git a/MapboxDirectionsTests/Fixtures/instructions.json b/MapboxDirectionsTests/resources/instructions.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/instructions.json rename to MapboxDirectionsTests/resources/instructions.json diff --git a/MapboxDirectionsTests/Fixtures/subLaneInstructions.json b/MapboxDirectionsTests/resources/subLaneInstructions.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/subLaneInstructions.json rename to MapboxDirectionsTests/resources/subLaneInstructions.json diff --git a/MapboxDirectionsTests/Fixtures/subVisualInstructions.json b/MapboxDirectionsTests/resources/subVisualInstructions.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/subVisualInstructions.json rename to MapboxDirectionsTests/resources/subVisualInstructions.json diff --git a/MapboxDirectionsTests/Fixtures/v4/v4_driving_dc_geojson.json b/MapboxDirectionsTests/resources/v4/v4_driving_dc_geojson.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/v4/v4_driving_dc_geojson.json rename to MapboxDirectionsTests/resources/v4/v4_driving_dc_geojson.json diff --git a/MapboxDirectionsTests/Fixtures/v4/v4_driving_dc_polyline.json b/MapboxDirectionsTests/resources/v4/v4_driving_dc_polyline.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/v4/v4_driving_dc_polyline.json rename to MapboxDirectionsTests/resources/v4/v4_driving_dc_polyline.json diff --git a/MapboxDirectionsTests/Fixtures/v5/annotation.json b/MapboxDirectionsTests/resources/v5/annotation.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/v5/annotation.json rename to MapboxDirectionsTests/resources/v5/annotation.json diff --git a/MapboxDirectionsTests/Fixtures/v5/v5_driving_dc_geojson.json b/MapboxDirectionsTests/resources/v5/v5_driving_dc_geojson.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/v5/v5_driving_dc_geojson.json rename to MapboxDirectionsTests/resources/v5/v5_driving_dc_geojson.json diff --git a/MapboxDirectionsTests/Fixtures/v5/v5_driving_dc_polyline.json b/MapboxDirectionsTests/resources/v5/v5_driving_dc_polyline.json similarity index 100% rename from MapboxDirectionsTests/Fixtures/v5/v5_driving_dc_polyline.json rename to MapboxDirectionsTests/resources/v5/v5_driving_dc_polyline.json diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 000000000..ec66d1e67 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,23 @@ +{ + "pins" : [ + { + "identity" : "ohhttpstubs", + "kind" : "remoteSourceControl", + "location" : "https://github.com/AliSoftware/OHHTTPStubs", + "state" : { + "revision" : "12f19662426d0434d6c330c6974d53e2eb10ecd9", + "version" : "9.1.0" + } + }, + { + "identity" : "polyline", + "kind" : "remoteSourceControl", + "location" : "https://github.com/raphaelmor/Polyline", + "state" : { + "revision" : "353f80378dcd8f17eefe8550090c6b1ae3c9da23", + "version" : "5.1.0" + } + } + ], + "version" : 2 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 000000000..969625830 --- /dev/null +++ b/Package.swift @@ -0,0 +1,45 @@ +// swift-tools-version: 5.9 + +import PackageDescription + +let package = Package( + name: "MapboxDirections", + platforms: [.iOS(.v14)], + products: [ + .library( + name: "MapboxDirections", + targets: [ + "MapboxDirections", + "MapboxDirectionsObjc" + ] + ) + ], + dependencies: [ + .package(url: "https://github.com/raphaelmor/Polyline", exact: "5.1.0"), + .package(url: "https://github.com/AliSoftware/OHHTTPStubs", .upToNextMajor(from: "9.0.0")) + ], + targets: [ + .target( + name: "MapboxDirections", + dependencies: [ + "Polyline", + "MapboxDirectionsObjc" + ], + path: "MapboxDirections" + ), + .target( + name: "MapboxDirectionsObjc", + path: "MapboxDirectionsObjc" + ), + .testTarget( + name: "MapboxDirectionsTests", + dependencies: [ + "MapboxDirections", + .product(name: "OHHTTPStubs", package: "OHHTTPStubs"), + .product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"), + ], + path: "MapboxDirectionsTests", + resources: [.process("resources")] + ) + ] +)