From 0351a3b29f703b3bdbf37034050ecf8a8a62f5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 18 Feb 2021 12:08:26 -0800 Subject: [PATCH 01/41] Turf v2.0.0-alpha.1 (#517) * Change Turf dependency to a binary version * Turf v2.0.0-alpha.2 * Removed tvOS, watchOS, Linux support Co-authored-by: Alexander Pristavko --- .circleci/config.yml | 22 ---------------------- Cartfile | 2 +- Cartfile.resolved | 2 +- MapboxDirections.podspec | 4 +--- Package.resolved | 4 ++-- Package.swift | 4 ++-- 6 files changed, 7 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c5a681dd..ef8efdcef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,12 +68,6 @@ jobs: iOS: type: string default: "12.1" - watchOS: - type: string - default: "5.0" - tvOS: - type: string - default: "12.0" test: type: boolean default: true @@ -107,19 +101,9 @@ jobs: condition: << parameters.codecoverage >> steps: - publish-codecov - - run: - name: tvOS - command: xcodebuild -project MapboxDirections.xcodeproj -scheme 'MapboxDirections tvOS' -destination 'platform=tvOS Simulator,name=Apple TV 4K (at 1080p),OS=<< parameters.tvOS >>' clean build <<# parameters.test >>test <> <<# parameters.codecoverage >>-enableCodeCoverage YES<> - - when: - condition: << parameters.codecoverage >> - steps: - - publish-codecov - run: name: macOS command: xcodebuild -project MapboxDirections.xcodeproj -scheme 'MapboxDirections Mac' clean build<<# parameters.test >> test <><<# parameters.codecoverage >>-enableCodeCoverage YES<> - - run: - name: watchOS - command: xcodebuild -project MapboxDirections.xcodeproj -scheme 'MapboxDirections watchOS' -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 44mm,OS=<< parameters.watchOS >>' clean build - save-cache workflows: @@ -129,17 +113,11 @@ workflows: name: "Xcode_12.1" xcode: "12.0.0" iOS: "14.0" - tvOS: "14.0" - watchOS: "7.0" - build-job: name: "Xcode_11.1" xcode: "11.1.0" iOS: "13.1" - tvOS: "13.0" - watchOS: "6.0" codecoverage: true - spm-job: name: "SPM_build" xcode: "12.0.0" - - spm-linux-job: - name: "SPM_Ubuntu_build" diff --git a/Cartfile b/Cartfile index 70c46e7cf..b857cd721 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "raphaelmor/Polyline" ~> 5.0 -github "mapbox/turf-swift" ~> 1.0 +github "mapbox/turf-swift" "v2.0.0-alpha.2" github "Udumft/SwiftCLI" "carthage-fix" diff --git a/Cartfile.resolved b/Cartfile.resolved index f804a2dab..71758dbb9 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -2,5 +2,5 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.9.0" github "AliSoftware/OHHTTPStubs" "9.1.0" github "Udumft/SwiftCLI" "da19d2a16cd5aa838d8fb7256e28c171bc67dd82" github "mapbox/mapbox-events-ios" "v0.10.7" -github "mapbox/turf-swift" "v1.2.0" +github "mapbox/turf-swift" "v2.0.0-alpha.2" github "raphaelmor/Polyline" "v5.0.2" diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 39c22d785..13a9691c0 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -27,8 +27,6 @@ Pod::Spec.new do |s| # When using multiple platforms s.ios.deployment_target = "10.0" s.osx.deployment_target = "10.12" - s.watchos.deployment_target = "3.0" - s.tvos.deployment_target = "10.0" # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # @@ -46,6 +44,6 @@ Pod::Spec.new do |s| s.swift_version = "5.0" s.dependency "Polyline", "~> 5.0" - s.dependency "Turf", "~> 1.0" + s.dependency "Turf", "~> 2.0.0-alpha.2" end diff --git a/Package.resolved b/Package.resolved index 0cff404cb..b0fb876d7 100644 --- a/Package.resolved +++ b/Package.resolved @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/mapbox/turf-swift.git", "state": { "branch": null, - "revision": "ee24a33eb9f02bf2715d3e0d3bcebbf302376af6", - "version": "1.1.0" + "revision": "d347d3651823422bd7b645d8691f3816e26cac73", + "version": "2.0.0-alpha.2" } } ] diff --git a/Package.swift b/Package.swift index 503c4679a..d67a27802 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "MapboxDirections", platforms: [ - .macOS(.v10_12), .iOS(.v10), .watchOS(.v3), .tvOS(.v12) + .macOS(.v10_12), .iOS(.v10), ], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. @@ -21,7 +21,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/raphaelmor/Polyline.git", from: "5.0.2"), - .package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "1.1.0"), + .package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "2.0.0-alpha.2"), .package(url: "https://github.com/jakeheis/SwiftCLI", from: "6.0.0") ], targets: [ From 9af4ddd923031fb283e30c401db27e11c0058098 Mon Sep 17 00:00:00 2001 From: Dersim Davaod Date: Thu, 18 Feb 2021 23:44:38 +0300 Subject: [PATCH 02/41] Turn Incident.Impact type into an enumeration (#519) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Implement initial IncidentImpact enum. * Make Impact codable. * Update RouteStepTests: add XCTAssert for Incident.Impact. * Update CHANGELOG.md Co-authored-by: Minh Nguyễn --- CHANGELOG.md | 6 +++++ Sources/MapboxDirections/Incident.swift | 22 +++++++++++++++---- .../RouteStepTests.swift | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa9ecef83..845576299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changes to Mapbox Directions for Swift +## main + +* This library requires Turf v2.0.0-alpha.2. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) +* This library does not support tvOS, watchOS, or Linux. Support for these platforms will be restored before the final release. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) +* The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) + ## v1.2.0 ### Packaging diff --git a/Sources/MapboxDirections/Incident.swift b/Sources/MapboxDirections/Incident.swift index 7baf5ae27..38a91a88b 100644 --- a/Sources/MapboxDirections/Incident.swift +++ b/Sources/MapboxDirections/Incident.swift @@ -50,7 +50,21 @@ public struct Incident: Codable, Equatable { /// Weather case weather = "weather" } - + + /// Represents the impact of the incident on local traffic. + public enum Impact: String, Codable { + /// Unknown impact + case unknown + /// Critical impact + case critical + /// Major impact + case major + /// Minor impact + case minor + /// Low impact + case low + } + /// Incident identifier public var identifier: String /// The kind of an incident @@ -69,7 +83,7 @@ public struct Incident: Codable, Equatable { /// Date when incident shall end. public var endDate: Date /// Shows severity of an incident. May be not available for all incident types. - public var impact: String? + public var impact: Impact? /// Provides additional classification of an incident. May be not available for all incident types. public var subtype: String? /// Breif description of the subtype. May be not available for all incident types and is not available if `subtype` is `nil` @@ -91,7 +105,7 @@ public struct Incident: Codable, Equatable { creationDate: Date, startDate: Date, endDate: Date, - impact: String?, + impact: Impact?, subtype: String?, subtypeDescription: String?, alertCodes: Set, @@ -142,7 +156,7 @@ public struct Incident: Codable, Equatable { debugDescription: "`Intersection.endTime` is encoded with invalid format.") } - impact = try container.decodeIfPresent(String.self, forKey: .impact) + impact = try container.decodeIfPresent(Impact.self, forKey: .impact) subtype = try container.decodeIfPresent(String.self, forKey: .subtype) subtypeDescription = try container.decodeIfPresent(String.self, forKey: .subtypeDescription) alertCodes = try container.decode(Set.self, forKey: .alertCodes) diff --git a/Tests/MapboxDirectionsTests/RouteStepTests.swift b/Tests/MapboxDirectionsTests/RouteStepTests.swift index 3d4d9a708..78a4a4dfb 100644 --- a/Tests/MapboxDirectionsTests/RouteStepTests.swift +++ b/Tests/MapboxDirectionsTests/RouteStepTests.swift @@ -329,6 +329,7 @@ class RouteStepTests: XCTestCase { XCTAssertNotNil(newRoute) XCTAssert(newRoute!.legs.first!.incidents!.first!.kind == Incident.Kind.miscellaneous) + XCTAssert(newRoute!.legs.first!.incidents!.first!.impact == Incident.Impact.minor) XCTAssert(newRoute!.legs.first!.incidents![0].lanesBlocked!.contains(.right)) XCTAssertNil(newRoute!.legs.first!.incidents![1].lanesBlocked) XCTAssert(newRoute!.legs.first!.incidents![2].lanesBlocked!.isEmpty) From ef9d8cd9436f9dbc800c5f3458b39c900078e217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 19 Feb 2021 11:52:48 -0800 Subject: [PATCH 03/41] v2.0.0-alpha.1 --- Directions Example/Info.plist | 4 +-- MapboxDirections.podspec | 2 +- MapboxDirections.xcodeproj/project.pbxproj | 32 +++++++++++----------- README.md | 6 ++-- Sources/MapboxDirections/Info.plist | 4 +-- Tests/MapboxDirectionsTests/Info.plist | 4 +-- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist index 4545e111e..1b87ee0e2 100644 --- a/Directions Example/Info.plist +++ b/Directions Example/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.0 + 2.0.0 CFBundleSignature ???? CFBundleVersion - 61 + 62 LSRequiresIPhoneOS NSLocationWhenInUseUsageDescription diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 13a9691c0..d4bb377eb 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # s.name = "MapboxDirections" - s.version = "1.2.0" + s.version = "2.0.0-alpha.1" s.summary = "Mapbox Directions API wrapper for Swift." s.description = <<-DESC diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index 57a425102..8891c51bb 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -1858,11 +1858,11 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1887,10 +1887,10 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1956,11 +1956,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1985,10 +1985,10 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2056,11 +2056,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2086,10 +2086,10 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2114,12 +2114,12 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2142,11 +2142,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 61; + CURRENT_PROJECT_VERSION = 62; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 61; + DYLIB_CURRENT_VERSION = 62; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/README.md b/README.md index e5a3dd6bb..638d3546f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Specify the following dependency in your [Carthage](https://github.com/Carthage/ # Latest stable release github "mapbox/mapbox-directions-swift" ~> 1.2 # Latest prerelease -github "mapbox/mapbox-directions-swift" "v1.2.0-rc.1" +github "mapbox/mapbox-directions-swift" "v2.0.0-alpha.1" ``` Or in your [CocoaPods](http://cocoapods.org/) Podfile: @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections', :git => 'https://github.com/mapbox/mapbox-directions-swift.git', :tag => 'v1.2.0-rc.1' +pod 'MapboxDirections', :git => 'https://github.com/mapbox/mapbox-directions-swift.git', :tag => 'v2.0.0-alpha.1' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: @@ -36,7 +36,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s // Latest stable release .package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") // Latest prerelease -.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") +.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-alpha.1") ``` Then `import MapboxDirections`. diff --git a/Sources/MapboxDirections/Info.plist b/Sources/MapboxDirections/Info.plist index d74930f96..7646600cb 100644 --- a/Sources/MapboxDirections/Info.plist +++ b/Sources/MapboxDirections/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.2.0 + 2.0.0 CFBundleSignature ???? CFBundleVersion - 61 + 62 NSHumanReadableCopyright Copyright © 2014–2020 Mapbox. All rights reserved. NSPrincipalClass diff --git a/Tests/MapboxDirectionsTests/Info.plist b/Tests/MapboxDirectionsTests/Info.plist index 75a66471b..0d11a9b3b 100644 --- a/Tests/MapboxDirectionsTests/Info.plist +++ b/Tests/MapboxDirectionsTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.2.0 + 2.0.0 CFBundleSignature ???? CFBundleVersion - 61 + 62 From 075b959405edbea9585035ca690d714307655176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 19 Feb 2021 12:29:09 -0800 Subject: [PATCH 04/41] Updated instructions for prereleasing on CocoaPods --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 909f7a3d9..1fd62decd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,7 +83,7 @@ To release a new version of the MapboxDirections package: 1. Run `./scripts/update-version.sh v#.#.#`, where _#.#.#_ is a new version number conforming to [Semantic Versioning](https://semver.org/). Commit the changes with a commit message like `v#.#.#` and open a pull request to get it reviewed and merged. 1. Tag the merged changes as `v#.#.#`. Push the tag by running `git pull && git push origin v#.#.#`. 1. [Create a new release](https://github.com/mapbox/mapbox-directions-swift/releases/new/). Add release notes based on the release’s section in the changelog. (Unlike the changelog, release notes accept `#123` syntax for linking to PRs.) Title the release `v#.#.#`. Check “This is a pre-release” if applicable, then click “Publish release”. -1. Run `pod repo update && pod trunk push` to publish the release on CocoaPods trunk. +1. Run `pod repo update && pod trunk push MapboxDirections.podspec` (or `pod trunk push MapboxDirections-pre.podspec` for a prerelease) to publish the release on CocoaPods trunk. 1. Run `./scripts/publish-documentation.sh v#.#.#` to generate and publish the documentation. Create a pull request and set the base branch to `publisher-production`. 1. Wait for new documentation to be live. Once you merge the branch into `publisher-production`, the new version will be available within 10 minutes. (Mapbox employees can check the #publisher channel in Slack for a notification of when the commit has been published.) 1. _(Mapbox employees only.)_ [Update various links](https://github.com/mapbox/ios-sdk#mapboxdirectionsswift) to the current docset in the [iOS documentation] site. From 1a2cf780570e36ce975be342754f40dd6822ae41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 19 Feb 2021 12:33:10 -0800 Subject: [PATCH 05/41] Added podspec for prereleases --- README.md | 2 +- scripts/update-version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 638d3546f..67ff1c337 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections', :git => 'https://github.com/mapbox/mapbox-directions-swift.git', :tag => 'v2.0.0-alpha.1' +pod 'MapboxDirections-pre', '2.0.0-alpha.1' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: diff --git a/scripts/update-version.sh b/scripts/update-version.sh index 91cde4739..40145e3c6 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -40,7 +40,7 @@ if [[ $SHORT_VERSION == $SEM_VERSION && $SHORT_VERSION == *.0 ]]; then sed -i '' -E "s/~> *[^']+/~> ${MINOR_VERSION}/g; s/.git\", from: \"*[^\"]+/.git\", from: \"${SEM_VERSION}/g" README.md elif [[ $SHORT_VERSION != $SEM_VERSION ]]; then step "Updating readmes to version ${SEM_VERSION}…" - sed -i '' -E "s/:tag => 'v[^']+'/:tag => 'v${SEM_VERSION}'/g; s/\"mapbox\/mapbox-directions-swift\" \"v[^\"]+\"/\"mapbox\/mapbox-directions-swift\" \"v${SEM_VERSION}\"/g;" README.md + sed -i '' -E "s/:tag => 'v[^']+'/:tag => 'v${SEM_VERSION}'/g; s/'MapboxDirections-pre', *'[^']+'/'MapboxDirections-pre', '${SEM_VERSION}'/g; s/\"mapbox\/mapbox-directions-swift\" \"v[^\"]+\"/\"mapbox\/mapbox-directions-swift\" \"v${SEM_VERSION}\"/g;" README.md sed -i '' -e ":a" -e "N" -e "\$!ba" -e "s/from: \"[^\"]*/from: \"${SEM_VERSION}/2" README.md fi From b18218815528bbfdfb06ac4f211a6da12a376e0e Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Thu, 25 Feb 2021 17:02:21 -0800 Subject: [PATCH 06/41] Add fallback access token. --- Sources/MapboxDirections/DirectionsCredentials.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/MapboxDirections/DirectionsCredentials.swift b/Sources/MapboxDirections/DirectionsCredentials.swift index 3d1e58708..36576fe7d 100644 --- a/Sources/MapboxDirections/DirectionsCredentials.swift +++ b/Sources/MapboxDirections/DirectionsCredentials.swift @@ -1,7 +1,8 @@ import Foundation /// The Mapbox access token specified in the main application bundle’s Info.plist. -let defaultAccessToken = Bundle.main.object(forInfoDictionaryKey: "MGLMapboxAccessToken") as? String +let defaultAccessToken = Bundle.main.object(forInfoDictionaryKey: "MBXAccessToken") as? String +let fallbackAccessToken = Bundle.main.object(forInfoDictionaryKey: "MGLMapboxAccessToken") as? String let defaultApiEndPointURLString = Bundle.main.object(forInfoDictionaryKey: "MGLMapboxAPIBaseURL") as? String public struct DirectionsCredentials: Equatable { @@ -36,7 +37,7 @@ public struct DirectionsCredentials: Equatable { - parameter host: Optional. A parameter to pass a custom host. If `nil` is provided, the SDK will attempt to find a host from your app's `info.plist`, and barring that will default to `https://api.mapbox.com`. */ public init(accessToken token: String? = nil, host: URL? = nil) { - let accessToken = token ?? defaultAccessToken + let accessToken = token ?? defaultAccessToken ?? fallbackAccessToken precondition(accessToken != nil && !accessToken!.isEmpty, "A Mapbox access token is required. Go to . In Info.plist, set the MGLMapboxAccessToken key to your access token, or use the Directions(accessToken:host:) initializer.") self.accessToken = accessToken From 46e1ef165d15e48239e505b34fe65aa3b1d56072 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Mon, 1 Mar 2021 11:13:09 -0800 Subject: [PATCH 07/41] Update documentation to mention `MBXAccessToken` instead of `MGLMapboxAccessToken`. --- CHANGELOG.md | 1 + README.md | 4 ++-- Sources/MapboxDirections/Directions.swift | 2 +- Sources/MapboxDirections/DirectionsCredentials.swift | 9 +++++---- docs/cover.md | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 845576299..281adedad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## main +* To gain access to the Mapbox Directions and Map Matching APIs, set `MBXAccessToken` in your Info.plist. `MGLMapboxAccessToken` is still supported but is now deprecated. ([#522](https://github.com/mapbox/mapbox-directions-swift/pull/522)) * This library requires Turf v2.0.0-alpha.2. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) * This library does not support tvOS, watchOS, or Linux. Support for these platforms will be restored before the final release. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) * The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) diff --git a/README.md b/README.md index 638d3546f..d12f5f5b5 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ v0.30.0 is the last release of MapboxDirections.swift that supports a minimum de **[API reference](https://docs.mapbox.com/ios/api/directions/)** -You’ll need a [Mapbox access token](https://docs.mapbox.com/api/#access-tokens-and-token-scopes) in order to use the API. If you’re already using the [Mapbox Maps SDK for iOS](https://docs.mapbox.com/ios/maps/) or [macOS SDK](https://mapbox.github.io/mapbox-gl-native/macos/), Mapbox Directions automatically recognizes your access token, as long as you’ve placed it in the `MGLMapboxAccessToken` key of your application’s Info.plist file. +You’ll need a [Mapbox access token](https://docs.mapbox.com/api/#access-tokens-and-token-scopes) in order to use the API. If you’re already using the [Mapbox Maps SDK for iOS](https://docs.mapbox.com/ios/maps/) or [macOS SDK](https://mapbox.github.io/mapbox-gl-native/macos/), Mapbox Directions automatically recognizes your access token, as long as you’ve placed it in the `MBXAccessToken` key of your application’s Info.plist file. The examples below are each provided in Swift (denoted with `main.swift`), For further details, see the [Mapbox Directions for Swift API reference](https://docs.mapbox.com/ios/api/directions/). @@ -78,7 +78,7 @@ import MapboxDirections let directions = Directions(credentials: DirectionsCredentials(accessToken: "<#your access token#>")) ``` -Alternatively, you can place your access token in the `MGLMapboxAccessToken` key of your application’s Info.plist file, then use the shared directions object: +Alternatively, you can place your access token in the `MBXAccessToken` key of your application’s Info.plist file, then use the shared directions object: ```swift // main.swift diff --git a/Sources/MapboxDirections/Directions.swift b/Sources/MapboxDirections/Directions.swift index 4b1484515..3b477eab5 100644 --- a/Sources/MapboxDirections/Directions.swift +++ b/Sources/MapboxDirections/Directions.swift @@ -110,7 +110,7 @@ open class Directions: NSObject { /** The shared directions object. - To use this object, a Mapbox [access token](https://docs.mapbox.com/help/glossary/access-token/) should be specified in the `MGLMapboxAccessToken` key in the main application bundle’s Info.plist. + To use this object, a Mapbox [access token](https://docs.mapbox.com/help/glossary/access-token/) should be specified in the `MBXAccessToken` key in the main application bundle’s Info.plist. */ public static let shared = Directions() diff --git a/Sources/MapboxDirections/DirectionsCredentials.swift b/Sources/MapboxDirections/DirectionsCredentials.swift index 36576fe7d..f06b9fd76 100644 --- a/Sources/MapboxDirections/DirectionsCredentials.swift +++ b/Sources/MapboxDirections/DirectionsCredentials.swift @@ -1,8 +1,9 @@ import Foundation /// The Mapbox access token specified in the main application bundle’s Info.plist. -let defaultAccessToken = Bundle.main.object(forInfoDictionaryKey: "MBXAccessToken") as? String -let fallbackAccessToken = Bundle.main.object(forInfoDictionaryKey: "MGLMapboxAccessToken") as? String +let defaultAccessToken = + Bundle.main.object(forInfoDictionaryKey: "MBXAccessToken") as? String ?? + Bundle.main.object(forInfoDictionaryKey: "MGLMapboxAccessToken") as? String let defaultApiEndPointURLString = Bundle.main.object(forInfoDictionaryKey: "MGLMapboxAPIBaseURL") as? String public struct DirectionsCredentials: Equatable { @@ -37,9 +38,9 @@ public struct DirectionsCredentials: Equatable { - parameter host: Optional. A parameter to pass a custom host. If `nil` is provided, the SDK will attempt to find a host from your app's `info.plist`, and barring that will default to `https://api.mapbox.com`. */ public init(accessToken token: String? = nil, host: URL? = nil) { - let accessToken = token ?? defaultAccessToken ?? fallbackAccessToken + let accessToken = token ?? defaultAccessToken - precondition(accessToken != nil && !accessToken!.isEmpty, "A Mapbox access token is required. Go to . In Info.plist, set the MGLMapboxAccessToken key to your access token, or use the Directions(accessToken:host:) initializer.") + precondition(accessToken != nil && !accessToken!.isEmpty, "A Mapbox access token is required. Go to . In Info.plist, set the MBXAccessToken key to your access token, or use the Directions(accessToken:host:) initializer.") self.accessToken = accessToken if let host = host { self.host = host diff --git a/docs/cover.md b/docs/cover.md index 1fa4f193a..c87c5a5f0 100644 --- a/docs/cover.md +++ b/docs/cover.md @@ -28,7 +28,7 @@ Then `import MapboxDirections`. ## Configuration -You’ll need a [Mapbox access token](https://docs.mapbox.com/api/#access-tokens-and-token-scopes) in order to use the API. If you’re already using the [Mapbox Maps SDK for iOS](https://docs.mapbox.com/ios/maps/) or [macOS SDK](https://mapbox.github.io/mapbox-gl-native/macos/), Mapbox Directions automatically recognizes your access token, as long as you’ve placed it in the `MGLMapboxAccessToken` key of your application’s Info.plist file. +You’ll need a [Mapbox access token](https://docs.mapbox.com/api/#access-tokens-and-token-scopes) in order to use the API. If you’re already using the [Mapbox Maps SDK for iOS](https://docs.mapbox.com/ios/maps/) or [macOS SDK](https://mapbox.github.io/mapbox-gl-native/macos/), Mapbox Directions automatically recognizes your access token, as long as you’ve placed it in the `MBXAccessToken` key of your application’s Info.plist file. ## Starting points From 7d12e4dfdc66296fb9f39a23e383cd6375500d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 2 Mar 2021 21:33:56 -0800 Subject: [PATCH 08/41] Turf v2.0.0-alpha.3 --- Cartfile | 2 +- Cartfile.resolved | 2 +- MapboxDirections.podspec | 2 +- Package.resolved | 4 ++-- Package.swift | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cartfile b/Cartfile index b857cd721..a0efe614d 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "raphaelmor/Polyline" ~> 5.0 -github "mapbox/turf-swift" "v2.0.0-alpha.2" +github "mapbox/turf-swift" "v2.0.0-alpha.3" github "Udumft/SwiftCLI" "carthage-fix" diff --git a/Cartfile.resolved b/Cartfile.resolved index 71758dbb9..83330e8c6 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -2,5 +2,5 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.9.0" github "AliSoftware/OHHTTPStubs" "9.1.0" github "Udumft/SwiftCLI" "da19d2a16cd5aa838d8fb7256e28c171bc67dd82" github "mapbox/mapbox-events-ios" "v0.10.7" -github "mapbox/turf-swift" "v2.0.0-alpha.2" +github "mapbox/turf-swift" "v2.0.0-alpha.3" github "raphaelmor/Polyline" "v5.0.2" diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index d4bb377eb..6615e340f 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -44,6 +44,6 @@ Pod::Spec.new do |s| s.swift_version = "5.0" s.dependency "Polyline", "~> 5.0" - s.dependency "Turf", "~> 2.0.0-alpha.2" + s.dependency "Turf", "~> 2.0.0-alpha.3" end diff --git a/Package.resolved b/Package.resolved index b0fb876d7..f409f9e53 100644 --- a/Package.resolved +++ b/Package.resolved @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/mapbox/turf-swift.git", "state": { "branch": null, - "revision": "d347d3651823422bd7b645d8691f3816e26cac73", - "version": "2.0.0-alpha.2" + "revision": "23e72d4174eacd76cc6414f063b427d2dac81cfb", + "version": "2.0.0-alpha.3" } } ] diff --git a/Package.swift b/Package.swift index d67a27802..409dd173d 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/raphaelmor/Polyline.git", from: "5.0.2"), - .package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "2.0.0-alpha.2"), + .package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "2.0.0-alpha.3"), .package(url: "https://github.com/jakeheis/SwiftCLI", from: "6.0.0") ], targets: [ From 612e4e90f430663fbbb450d67bf4cd4d19eb1c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 2 Mar 2021 21:32:50 -0800 Subject: [PATCH 09/41] Restored support for tvOS, watchOS --- .circleci/config.yml | 22 ++++++++++++++++++++++ CHANGELOG.md | 3 +-- MapboxDirections.podspec | 2 ++ Package.swift | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef8efdcef..8c5a681dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,6 +68,12 @@ jobs: iOS: type: string default: "12.1" + watchOS: + type: string + default: "5.0" + tvOS: + type: string + default: "12.0" test: type: boolean default: true @@ -101,9 +107,19 @@ jobs: condition: << parameters.codecoverage >> steps: - publish-codecov + - run: + name: tvOS + command: xcodebuild -project MapboxDirections.xcodeproj -scheme 'MapboxDirections tvOS' -destination 'platform=tvOS Simulator,name=Apple TV 4K (at 1080p),OS=<< parameters.tvOS >>' clean build <<# parameters.test >>test <> <<# parameters.codecoverage >>-enableCodeCoverage YES<> + - when: + condition: << parameters.codecoverage >> + steps: + - publish-codecov - run: name: macOS command: xcodebuild -project MapboxDirections.xcodeproj -scheme 'MapboxDirections Mac' clean build<<# parameters.test >> test <><<# parameters.codecoverage >>-enableCodeCoverage YES<> + - run: + name: watchOS + command: xcodebuild -project MapboxDirections.xcodeproj -scheme 'MapboxDirections watchOS' -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 44mm,OS=<< parameters.watchOS >>' clean build - save-cache workflows: @@ -113,11 +129,17 @@ workflows: name: "Xcode_12.1" xcode: "12.0.0" iOS: "14.0" + tvOS: "14.0" + watchOS: "7.0" - build-job: name: "Xcode_11.1" xcode: "11.1.0" iOS: "13.1" + tvOS: "13.0" + watchOS: "6.0" codecoverage: true - spm-job: name: "SPM_build" xcode: "12.0.0" + - spm-linux-job: + name: "SPM_Ubuntu_build" diff --git a/CHANGELOG.md b/CHANGELOG.md index 281adedad..082d13b28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,7 @@ ## main * To gain access to the Mapbox Directions and Map Matching APIs, set `MBXAccessToken` in your Info.plist. `MGLMapboxAccessToken` is still supported but is now deprecated. ([#522](https://github.com/mapbox/mapbox-directions-swift/pull/522)) -* This library requires Turf v2.0.0-alpha.2. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) -* This library does not support tvOS, watchOS, or Linux. Support for these platforms will be restored before the final release. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) +* This library requires Turf v2.0.0-alpha.3. ([#525](https://github.com/mapbox/mapbox-directions-swift/pull/525)) * The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) ## v1.2.0 diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 6615e340f..9d32d598d 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -27,6 +27,8 @@ Pod::Spec.new do |s| # When using multiple platforms s.ios.deployment_target = "10.0" s.osx.deployment_target = "10.12" + s.watchos.deployment_target = "3.0" + s.tvos.deployment_target = "10.0" # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # diff --git a/Package.swift b/Package.swift index 409dd173d..14b4212f6 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "MapboxDirections", platforms: [ - .macOS(.v10_12), .iOS(.v10), + .macOS(.v10_12), .iOS(.v10), .watchOS(.v3), .tvOS(.v12) ], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. From 714c524aea2f188d4edb45cf3055cc5e6e5db5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 2 Mar 2021 22:26:14 -0800 Subject: [PATCH 10/41] Migrated to Turf shims for Core Location types --- .../MapboxDirections/DirectionsResult.swift | 9 ++-- .../MapboxDirections/Extensions/Codable.swift | 40 ++++++++-------- .../Extensions/CoreLocation.swift | 31 ++----------- .../MapboxDirections/Extensions/GeoJSON.swift | 10 ++-- Sources/MapboxDirections/Intersection.swift | 20 ++++---- .../MapboxDirections/MapMatching/Match.swift | 6 +-- .../MapMatching/MatchOptions.swift | 5 +- .../MapMatching/Tracepoint.swift | 6 +-- Sources/MapboxDirections/Route.swift | 5 +- Sources/MapboxDirections/RouteLeg.swift | 11 ++--- .../MapboxDirections/RouteLegAttributes.swift | 8 +--- Sources/MapboxDirections/RouteOptions.swift | 5 +- Sources/MapboxDirections/RouteStep.swift | 23 ++++------ .../MapboxDirections/SpokenInstruction.swift | 8 +--- .../MapboxDirections/VisualInstruction.swift | 10 ++-- .../VisualInstructionBanner.swift | 10 ++-- Sources/MapboxDirections/Waypoint.swift | 33 +++++++------ .../DirectionsTests.swift | 19 ++++---- .../IntersectionTests.swift | 12 ++--- .../MatchOptionsTests.swift | 18 +++----- Tests/MapboxDirectionsTests/MatchTests.swift | 9 ++-- .../OfflineDirectionsTests.swift | 4 +- .../QuickLookTests.swift | 7 +-- .../MapboxDirectionsTests/RouteLegTests.swift | 21 ++++----- .../RouteOptionsTests.swift | 28 +++++------ .../RouteRefreshTests.swift | 6 +-- .../RouteResponseTests.swift | 6 +-- .../RouteStepTests.swift | 22 ++++----- Tests/MapboxDirectionsTests/RouteTests.swift | 12 ++--- .../SpokenInstructionTests.swift | 8 +--- .../WalkingOptionsTests.swift | 8 +--- .../MapboxDirectionsTests/WaypointTests.swift | 46 +++++++++---------- 32 files changed, 174 insertions(+), 292 deletions(-) diff --git a/Sources/MapboxDirections/DirectionsResult.swift b/Sources/MapboxDirections/DirectionsResult.swift index eb5a48802..f5942c50f 100644 --- a/Sources/MapboxDirections/DirectionsResult.swift +++ b/Sources/MapboxDirections/DirectionsResult.swift @@ -1,8 +1,5 @@ import Foundation import Polyline -#if canImport(CoreLocation) -import CoreLocation -#endif import Turf /** @@ -24,7 +21,7 @@ open class DirectionsResult: Codable { // MARK: Creating a Directions Result - init(legs: [RouteLeg], shape: LineString?, distance: CLLocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil) { + init(legs: [RouteLeg], shape: LineString?, distance: Turf.LocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil) { self.legs = legs self.shape = shape self.distance = distance @@ -50,7 +47,7 @@ open class DirectionsResult: Codable { throw DirectionsCodingError.missingOptions } - distance = try container.decode(CLLocationDistance.self, forKey: .distance) + distance = try container.decode(Turf.LocationDistance.self, forKey: .distance) expectedTravelTime = try container.decode(TimeInterval.self, forKey: .expectedTravelTime) typicalTravelTime = try container.decodeIfPresent(TimeInterval.self, forKey: .typicalTravelTime) @@ -134,7 +131,7 @@ open class DirectionsResult: Codable { The value of this property accounts for the distance that the user must travel to traverse the path of the route. It is the sum of the `distance` properties of the route’s legs, not the sum of the direct distances between the route’s waypoints. You should not assume that the user would travel along this distance at a fixed speed. */ - public let distance: CLLocationDistance + public let distance: Turf.LocationDistance /** The route’s expected travel time, measured in seconds. diff --git a/Sources/MapboxDirections/Extensions/Codable.swift b/Sources/MapboxDirections/Extensions/Codable.swift index 80360b3dc..6ed7afa0e 100644 --- a/Sources/MapboxDirections/Extensions/Codable.swift +++ b/Sources/MapboxDirections/Extensions/Codable.swift @@ -1,9 +1,11 @@ import Foundation -import Polyline -import Turf +import func Polyline.encodeCoordinates #if canImport(CoreLocation) -import CoreLocation +import typealias Polyline.LocationCoordinate2D +#else +import struct Polyline.LocationCoordinate2D #endif +import Turf extension LineString { /** @@ -11,10 +13,11 @@ extension LineString { */ func polylineEncodedString(precision: Double = 1e5) -> String { #if canImport(CoreLocation) - return encodeCoordinates(coordinates, precision: precision) + let coordinates = self.coordinates #else - return encodeCoordinates(coordinates.map { LocationCoordinate2D($0) }, precision: precision) + let coordinates = self.coordinates.map { Polyline.LocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude) } #endif + return encodeCoordinates(coordinates, precision: precision) } } @@ -45,7 +48,7 @@ extension PolyLineString: Codable { switch options?.shapeFormat ?? .default { case .geoJSON: let lineStringContainer = try decoder.container(keyedBy: LineStringCodingKeys.self) - let coordinates = try lineStringContainer.decode([CLLocationCoordinate2DCodable].self, forKey: .coordinates).map { $0.decodedCoordinates } + let coordinates = try lineStringContainer.decode([LocationCoordinate2DCodable].self, forKey: .coordinates).map { $0.decodedCoordinates } self = .lineString(LineString(coordinates)) case .polyline, .polyline6: let precision = options?.shapeFormat == .polyline6 ? 1e6 : 1e5 @@ -59,19 +62,18 @@ extension PolyLineString: Codable { switch self { case let .lineString(lineString): var lineStringContainer = encoder.container(keyedBy: LineStringCodingKeys.self) - try lineStringContainer.encode(lineString.coordinates.map { CLLocationCoordinate2DCodable($0) }, forKey: .coordinates) + try lineStringContainer.encode(lineString.coordinates.map { LocationCoordinate2DCodable($0) }, forKey: .coordinates) case let .polyline(encodedPolyline, precision: _): try container.encode(encodedPolyline) } } } -struct CLLocationCoordinate2DCodable: Codable { - var latitude: CLLocationDegrees - var longitude: CLLocationDegrees - var decodedCoordinates: CLLocationCoordinate2D { - return CLLocationCoordinate2D(latitude: latitude, - longitude: longitude) +struct LocationCoordinate2DCodable: Codable { + var latitude: Turf.LocationDegrees + var longitude: Turf.LocationDegrees + var decodedCoordinates: Turf.LocationCoordinate2D { + return Turf.LocationCoordinate2D(latitude: latitude, longitude: longitude) } func encode(to encoder: Encoder) throws { @@ -82,18 +84,12 @@ struct CLLocationCoordinate2DCodable: Codable { init(from decoder: Decoder) throws { var container = try decoder.unkeyedContainer() - longitude = try container.decode(CLLocationDegrees.self) - latitude = try container.decode(CLLocationDegrees.self) + longitude = try container.decode(Turf.LocationDegrees.self) + latitude = try container.decode(Turf.LocationDegrees.self) } - init(_ coordinate: CLLocationCoordinate2D) { + init(_ coordinate: Turf.LocationCoordinate2D) { latitude = coordinate.latitude longitude = coordinate.longitude } } - -extension CLLocationCoordinate2D { - var codableCoordinates: CLLocationCoordinate2DCodable { - return CLLocationCoordinate2DCodable(self) - } -} diff --git a/Sources/MapboxDirections/Extensions/CoreLocation.swift b/Sources/MapboxDirections/Extensions/CoreLocation.swift index f0e7d1606..9cd6513ee 100644 --- a/Sources/MapboxDirections/Extensions/CoreLocation.swift +++ b/Sources/MapboxDirections/Extensions/CoreLocation.swift @@ -1,10 +1,9 @@ import Foundation #if canImport(CoreLocation) import CoreLocation -#else -import Turf -import Polyline #endif +import Turf + #if canImport(CoreLocation) /** @@ -30,34 +29,10 @@ public typealias LocationSpeed = Double The accuracy of a geographical coordinate. */ public typealias LocationAccuracy = Double - -extension CLLocationCoordinate2D { - init(_ locationCoordinate2D: LocationCoordinate2D) { - self.init(latitude: locationCoordinate2D.latitude, longitude: locationCoordinate2D.longitude) - } -} - -extension LocationCoordinate2D { - init(_ clLocationCoordinate2D: CLLocationCoordinate2D) { - self.init(latitude: clLocationCoordinate2D.latitude, longitude: clLocationCoordinate2D.longitude) - } -} #endif -extension CLLocationCoordinate2D { +extension LocationCoordinate2D { internal var requestDescription: String { return "\(longitude.rounded(to: 1e6)),\(latitude.rounded(to: 1e6))" } } - -#if canImport(CoreLocation) -extension CLLocation { - /** - Initializes a CLLocation object with the given coordinate pair. - */ - internal convenience init(coordinate: CLLocationCoordinate2D) { - self.init(latitude: coordinate.latitude, longitude: coordinate.longitude) - } -} -#endif - diff --git a/Sources/MapboxDirections/Extensions/GeoJSON.swift b/Sources/MapboxDirections/Extensions/GeoJSON.swift index 4fa353cdf..ea47fbd99 100644 --- a/Sources/MapboxDirections/Extensions/GeoJSON.swift +++ b/Sources/MapboxDirections/Extensions/GeoJSON.swift @@ -1,8 +1,10 @@ import Foundation +import func Polyline.decodePolyline #if canImport(CoreLocation) -import CoreLocation +import typealias Polyline.LocationCoordinate2D +#else +import struct Polyline.LocationCoordinate2D #endif -import Polyline import Turf extension BoundingBox: CustomStringConvertible { @@ -22,7 +24,7 @@ extension LineString { } init(encodedPolyline: String, precision: Double) throws { - guard var coordinates = decodePolyline(encodedPolyline, precision: precision) as [LocationCoordinate2D]? else { + guard var coordinates = decodePolyline(encodedPolyline, precision: precision) as [Polyline.LocationCoordinate2D]? else { throw GeometryError.cannotDecodePolyline(precision: precision) } // If the polyline has zero length with both endpoints at the same coordinate, Polyline drops one of the coordinates. @@ -34,7 +36,7 @@ extension LineString { #if canImport(CoreLocation) self.init(coordinates) #else - self.init(coordinates.map { CLLocationCoordinate2D($0) }) + self.init(coordinates.map { Turf.LocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude) }) #endif } } diff --git a/Sources/MapboxDirections/Intersection.swift b/Sources/MapboxDirections/Intersection.swift index ad5569dd2..f5f8ac646 100644 --- a/Sources/MapboxDirections/Intersection.swift +++ b/Sources/MapboxDirections/Intersection.swift @@ -1,9 +1,5 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif /** A single cross street along a step. @@ -11,8 +7,8 @@ import Turf public struct Intersection { // MARK: Creating an Intersection - public init(location: CLLocationCoordinate2D, - headings: [CLLocationDirection], + public init(location: LocationCoordinate2D, + headings: [LocationDirection], approachIndex: Int, outletIndex: Int, outletIndexes: IndexSet, @@ -46,18 +42,18 @@ public struct Intersection { /** The geographic coordinates at the center of the intersection. */ - public let location: CLLocationCoordinate2D + public let location: LocationCoordinate2D // MARK: Getting the Roads that Meet at the Intersection /** - An array of `CLLocationDirection`s indicating the absolute headings of the roads that meet at the intersection. + An array of `LocationDirection`s indicating the absolute headings of the roads that meet at the intersection. A road is represented in this array by a heading indicating the direction from which the road meets the intersection. To get the direction of travel when leaving the intersection along the road, rotate the heading 180 degrees. A single road that passes through this intersection is represented by two items in this array: one for the segment that enters the intersection and one for the segment that exits it. */ - public let headings: [CLLocationDirection] + public let headings: [LocationDirection] /** The indices of the items in the `headings` array that correspond to the roads that may be used to leave the intersection. @@ -232,7 +228,7 @@ extension Intersection: Codable { func encode(to encoder: Encoder, administrativeRegionIndex: Int?, geometryIndex: Int?) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(CLLocationCoordinate2DCodable(location), forKey: .location) + try container.encode(LocationCoordinate2DCodable(location), forKey: .location) try container.encode(headings, forKey: .headings) try container.encodeIfPresent(approachIndex, forKey: .approachIndex) @@ -290,8 +286,8 @@ extension Intersection: Codable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - location = try container.decode(CLLocationCoordinate2DCodable.self, forKey: .location).decodedCoordinates - headings = try container.decode([CLLocationDirection].self, forKey: .headings) + location = try container.decode(LocationCoordinate2DCodable.self, forKey: .location).decodedCoordinates + headings = try container.decode([LocationDirection].self, forKey: .headings) if let lanes = try container.decodeIfPresent([Lane].self, forKey: .lanes) { approachLanes = lanes.map { $0.indications } diff --git a/Sources/MapboxDirections/MapMatching/Match.swift b/Sources/MapboxDirections/MapMatching/Match.swift index 089df30ae..e8b4f17b0 100644 --- a/Sources/MapboxDirections/MapMatching/Match.swift +++ b/Sources/MapboxDirections/MapMatching/Match.swift @@ -1,8 +1,4 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#endif -import Polyline import Turf /** @@ -65,7 +61,7 @@ open class Match: DirectionsResult { - parameter confidence: A number between 0 and 1 that indicates the Map Matching API’s confidence that the match is accurate. A higher confidence means the match is more likely to be accurate. - parameter weight: A `Weight` enum, which represents the weight given to a specific `Match`. */ - public init(legs: [RouteLeg], shape: LineString?, distance: CLLocationDistance, expectedTravelTime: TimeInterval, confidence: Float, weight: Weight) { + public init(legs: [RouteLeg], shape: LineString?, distance: LocationDistance, expectedTravelTime: TimeInterval, confidence: Float, weight: Weight) { self.confidence = confidence self.weight = weight super.init(legs: legs, shape: shape, distance: distance, expectedTravelTime: expectedTravelTime) diff --git a/Sources/MapboxDirections/MapMatching/MatchOptions.swift b/Sources/MapboxDirections/MapMatching/MatchOptions.swift index d86d9f90e..ac2a6f61c 100644 --- a/Sources/MapboxDirections/MapMatching/MatchOptions.swift +++ b/Sources/MapboxDirections/MapMatching/MatchOptions.swift @@ -1,9 +1,8 @@ import Foundation #if canImport(CoreLocation) import CoreLocation -#else -import Turf #endif +import Turf /** A `MatchOptions` object is a structure that specifies the criteria for results returned by the Mapbox Map Matching API. @@ -34,7 +33,7 @@ open class MatchOptions: DirectionsOptions { - parameter coordinates: An array of geographic coordinates representing locations to attempt to match against the road network. The array should contain at least two locations (the source and destination) and at most 100 locations. (Some profiles, such as `DirectionsProfileIdentifier.automobileAvoidingTraffic`, [may have lower limits](https://docs.mapbox.com/api/navigation/#directions).) Each coordinate is converted into a `Waypoint` object. - parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. `DirectionsProfileIdentifier.automobile` is used by default. */ - public convenience init(coordinates: [CLLocationCoordinate2D], profileIdentifier: DirectionsProfileIdentifier? = nil) { + public convenience init(coordinates: [LocationCoordinate2D], profileIdentifier: DirectionsProfileIdentifier? = nil) { let waypoints = coordinates.map { Waypoint(coordinate: $0) } diff --git a/Sources/MapboxDirections/MapMatching/Tracepoint.swift b/Sources/MapboxDirections/MapMatching/Tracepoint.swift index 4043f5efa..8d1b4f29f 100644 --- a/Sources/MapboxDirections/MapMatching/Tracepoint.swift +++ b/Sources/MapboxDirections/MapMatching/Tracepoint.swift @@ -1,9 +1,5 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif /** A `Tracepoint` represents a location matched to the road network. @@ -18,7 +14,7 @@ public class Tracepoint: Waypoint { case countOfAlternatives = "alternatives_count" } - init(coordinate: CLLocationCoordinate2D, countOfAlternatives: Int, name: String?) { + init(coordinate: LocationCoordinate2D, countOfAlternatives: Int, name: String?) { self.countOfAlternatives = countOfAlternatives super.init(coordinate: coordinate, name: name) } diff --git a/Sources/MapboxDirections/Route.swift b/Sources/MapboxDirections/Route.swift index ed3030bdb..c0b1bba23 100644 --- a/Sources/MapboxDirections/Route.swift +++ b/Sources/MapboxDirections/Route.swift @@ -1,7 +1,4 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#endif import Turf /** @@ -20,7 +17,7 @@ open class Route: DirectionsResult { - parameter expectedTravelTime: The route’s expected travel time, measured in seconds. - parameter typicalTravelTime: The route’s typical travel time, measured in seconds. */ - public override init(legs: [RouteLeg], shape: LineString?, distance: CLLocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil) { + public override init(legs: [RouteLeg], shape: LineString?, distance: LocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil) { super.init(legs: legs, shape: shape, distance: distance, expectedTravelTime: expectedTravelTime, typicalTravelTime: typicalTravelTime) } diff --git a/Sources/MapboxDirections/RouteLeg.swift b/Sources/MapboxDirections/RouteLeg.swift index d536958e4..9cc359371 100644 --- a/Sources/MapboxDirections/RouteLeg.swift +++ b/Sources/MapboxDirections/RouteLeg.swift @@ -1,7 +1,4 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#endif import Polyline import Turf @@ -36,7 +33,7 @@ open class RouteLeg: Codable { - parameter typicalTravelTime: The route leg’s typical travel time, measured in seconds. - parameter profileIdentifier: The primary mode of transportation for the route leg. */ - public init(steps: [RouteStep], name: String, distance: CLLocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil, profileIdentifier: DirectionsProfileIdentifier) { + public init(steps: [RouteStep], name: String, distance: Turf.LocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil, profileIdentifier: DirectionsProfileIdentifier) { self.steps = steps self.name = name self.distance = distance @@ -61,7 +58,7 @@ open class RouteLeg: Codable { source = try container.decodeIfPresent(Waypoint.self, forKey: .source) destination = try container.decodeIfPresent(Waypoint.self, forKey: .destination) name = try container.decode(String.self, forKey: .name) - distance = try container.decode(CLLocationDistance.self, forKey: .distance) + distance = try container.decode(Turf.LocationDistance.self, forKey: .distance) expectedTravelTime = try container.decode(TimeInterval.self, forKey: .expectedTravelTime) typicalTravelTime = try container.decodeIfPresent(TimeInterval.self, forKey: .typicalTravelTime) @@ -175,7 +172,7 @@ open class RouteLeg: Codable { This property is set if the `RouteOptions.attributeOptions` property contains `AttributeOptions.distance`. */ - open var segmentDistances: [CLLocationDistance]? + open var segmentDistances: [Turf.LocationDistance]? /** An array containing the expected travel time (measured in seconds) between each coordinate in the route leg geometry. @@ -269,7 +266,7 @@ open class RouteLeg: Codable { The value of this property accounts for the distance that the user must travel to arrive at the destination from the source. It is not the direct distance between the source and destination, nor should not assume that the user would travel along this distance at a fixed speed. */ - public let distance: CLLocationDistance + public let distance: Turf.LocationDistance /** The route leg’s expected travel time, measured in seconds. diff --git a/Sources/MapboxDirections/RouteLegAttributes.swift b/Sources/MapboxDirections/RouteLegAttributes.swift index 0f87d6ff4..190eea721 100644 --- a/Sources/MapboxDirections/RouteLegAttributes.swift +++ b/Sources/MapboxDirections/RouteLegAttributes.swift @@ -1,9 +1,5 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif extension RouteLeg { /** @@ -15,7 +11,7 @@ extension RouteLeg { This property is set if the `RouteOptions.attributeOptions` property contains `AttributeOptions.distance`. */ - public var segmentDistances: [CLLocationDistance]? + public var segmentDistances: [LocationDistance]? /** An array containing the expected travel time (measured in seconds) between each coordinate in the route leg geometry. @@ -71,7 +67,7 @@ extension RouteLeg.Attributes: Codable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - segmentDistances = try container.decodeIfPresent([CLLocationDistance].self, forKey: .segmentDistances) + segmentDistances = try container.decodeIfPresent([LocationDistance].self, forKey: .segmentDistances) expectedSegmentTravelTimes = try container.decodeIfPresent([TimeInterval].self, forKey: .expectedSegmentTravelTimes) segmentSpeeds = try container.decodeIfPresent([LocationSpeed].self, forKey: .segmentSpeeds) segmentCongestionLevels = try container.decodeIfPresent([CongestionLevel].self, forKey: .segmentCongestionLevels) diff --git a/Sources/MapboxDirections/RouteOptions.swift b/Sources/MapboxDirections/RouteOptions.swift index 14f64f452..1b8eeb86f 100644 --- a/Sources/MapboxDirections/RouteOptions.swift +++ b/Sources/MapboxDirections/RouteOptions.swift @@ -1,9 +1,8 @@ import Foundation #if canImport(CoreLocation) import CoreLocation -#else -import Turf #endif +import Turf /** A `RouteOptions` object is a structure that specifies the criteria for results returned by the Mapbox Directions API. @@ -46,7 +45,7 @@ open class RouteOptions: DirectionsOptions { - parameter coordinates: An array of geographic coordinates representing locations that the route should visit in chronological order. The array should contain at least two locations (the source and destination) and at most 25 locations. Each coordinate is converted into a `Waypoint` object. - parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. `DirectionsProfileIdentifier.automobile` is used by default. */ - public convenience init(coordinates: [CLLocationCoordinate2D], profileIdentifier: DirectionsProfileIdentifier? = nil) { + public convenience init(coordinates: [LocationCoordinate2D], profileIdentifier: DirectionsProfileIdentifier? = nil) { let waypoints = coordinates.map { Waypoint(coordinate: $0) } self.init(waypoints: waypoints, profileIdentifier: profileIdentifier) } diff --git a/Sources/MapboxDirections/RouteStep.swift b/Sources/MapboxDirections/RouteStep.swift index 1486140c2..e6fafaec0 100644 --- a/Sources/MapboxDirections/RouteStep.swift +++ b/Sources/MapboxDirections/RouteStep.swift @@ -1,7 +1,4 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#endif import Polyline import Turf @@ -460,7 +457,7 @@ open class RouteStep: Codable { - parameter instructionsSpokenAlongStep: Instructions about the next step’s maneuver, optimized for speech synthesis. - parameter instructionsDisplayedAlongStep: Instructions about the next step’s maneuver, optimized for display in real time. */ - public init(transportType: TransportType, maneuverLocation: CLLocationCoordinate2D, maneuverType: ManeuverType, maneuverDirection: ManeuverDirection? = nil, instructions: String, initialHeading: CLLocationDirection? = nil, finalHeading: CLLocationDirection? = nil, drivingSide: DrivingSide, exitCodes: [String]? = nil, exitNames: [String]? = nil, phoneticExitNames: [String]? = nil, distance: CLLocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil, names: [String]? = nil, phoneticNames: [String]? = nil, codes: [String]? = nil, destinationCodes: [String]? = nil, destinations: [String]? = nil, intersections: [Intersection]? = nil, speedLimitSignStandard: SignStandard? = nil, speedLimitUnit: UnitSpeed? = nil, instructionsSpokenAlongStep: [SpokenInstruction]? = nil, instructionsDisplayedAlongStep: [VisualInstructionBanner]? = nil, administrativeAreaContainerByIntersection: [Int?]? = nil, segmentIndicesByIntersection: [Int?]? = nil) { + public init(transportType: TransportType, maneuverLocation: Turf.LocationCoordinate2D, maneuverType: ManeuverType, maneuverDirection: ManeuverDirection? = nil, instructions: String, initialHeading: Turf.LocationDirection? = nil, finalHeading: Turf.LocationDirection? = nil, drivingSide: DrivingSide, exitCodes: [String]? = nil, exitNames: [String]? = nil, phoneticExitNames: [String]? = nil, distance: Turf.LocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil, names: [String]? = nil, phoneticNames: [String]? = nil, codes: [String]? = nil, destinationCodes: [String]? = nil, destinations: [String]? = nil, intersections: [Intersection]? = nil, speedLimitSignStandard: SignStandard? = nil, speedLimitUnit: UnitSpeed? = nil, instructionsSpokenAlongStep: [SpokenInstruction]? = nil, instructionsDisplayedAlongStep: [VisualInstructionBanner]? = nil, administrativeAreaContainerByIntersection: [Int?]? = nil, segmentIndicesByIntersection: [Int?]? = nil) { self.transportType = transportType self.maneuverLocation = maneuverLocation self.maneuverType = maneuverType @@ -534,7 +531,7 @@ open class RouteStep: Codable { try maneuver.encode(instructions, forKey: .instruction) try maneuver.encode(maneuverType, forKey: .type) try maneuver.encodeIfPresent(maneuverDirection, forKey: .direction) - try maneuver.encode(CLLocationCoordinate2DCodable(maneuverLocation), forKey: .location) + try maneuver.encode(LocationCoordinate2DCodable(maneuverLocation), forKey: .location) try maneuver.encodeIfPresent(initialHeading, forKey: .initialHeading) try maneuver.encodeIfPresent(finalHeading, forKey: .finalHeading) @@ -586,12 +583,12 @@ open class RouteStep: Codable { let container = try decoder.container(keyedBy: CodingKeys.self) let maneuver = try container.nestedContainer(keyedBy: ManeuverCodingKeys.self, forKey: .maneuver) - maneuverLocation = try maneuver.decode(CLLocationCoordinate2DCodable.self, forKey: .location).decodedCoordinates + maneuverLocation = try maneuver.decode(LocationCoordinate2DCodable.self, forKey: .location).decodedCoordinates maneuverType = (try? maneuver.decode(ManeuverType.self, forKey: .type)) ?? .default maneuverDirection = try maneuver.decodeIfPresent(ManeuverDirection.self, forKey: .direction) - initialHeading = try maneuver.decodeIfPresent(CLLocationDirection.self, forKey: .initialHeading) - finalHeading = try maneuver.decodeIfPresent(CLLocationDirection.self, forKey: .finalHeading) + initialHeading = try maneuver.decodeIfPresent(Turf.LocationDirection.self, forKey: .initialHeading) + finalHeading = try maneuver.decodeIfPresent(Turf.LocationDirection.self, forKey: .finalHeading) if let polyLineString = try container.decodeIfPresent(PolyLineString.self, forKey: .shape) { shape = try LineString(polyLineString: polyLineString) @@ -618,7 +615,7 @@ open class RouteStep: Codable { } exitIndex = try container.decodeIfPresent(Int.self, forKey: .exitIndex) - distance = try container.decode(CLLocationDirection.self, forKey: .distance) + distance = try container.decode(Turf.LocationDirection.self, forKey: .distance) expectedTravelTime = try container.decode(TimeInterval.self, forKey: .expectedTravelTime) typicalTravelTime = try container.decodeIfPresent(TimeInterval.self, forKey: .typicalTravelTime) @@ -692,7 +689,7 @@ open class RouteStep: Codable { /** The location of the maneuver at the beginning of this step. */ - public let maneuverLocation: CLLocationCoordinate2D + public let maneuverLocation: Turf.LocationCoordinate2D /** The type of maneuver required for beginning this step. @@ -716,14 +713,14 @@ open class RouteStep: Codable { /** The user’s heading immediately before performing the maneuver. */ - public let initialHeading: CLLocationDirection? + public let initialHeading: Turf.LocationDirection? /** The user’s heading immediately after performing the maneuver. The value of this property may differ from the user’s heading after traveling along the road past the maneuver. */ - public let finalHeading: CLLocationDirection? + public let finalHeading: Turf.LocationDirection? /** Indicates what side of a bidirectional road the driver must be driving on. Also referred to as the rule of the road. @@ -773,7 +770,7 @@ open class RouteStep: Codable { The value of this property accounts for the distance that the user must travel to go from this step’s maneuver location to the next step’s maneuver location. It is not the sum of the direct distances between the route’s waypoints, nor should you assume that the user would travel along this distance at a fixed speed. */ - public let distance: CLLocationDistance + public let distance: Turf.LocationDistance /** The step’s expected travel time, measured in seconds. diff --git a/Sources/MapboxDirections/SpokenInstruction.swift b/Sources/MapboxDirections/SpokenInstruction.swift index fee33699a..c886a7e31 100644 --- a/Sources/MapboxDirections/SpokenInstruction.swift +++ b/Sources/MapboxDirections/SpokenInstruction.swift @@ -1,9 +1,5 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif /** An instruction about an upcoming `RouteStep`’s maneuver, optimized for speech synthesis. @@ -28,7 +24,7 @@ open class SpokenInstruction: Codable { - parameter text: A plain-text representation of the speech-optimized instruction. - parameter ssmlText: A formatted representation of the speech-optimized instruction. */ - public init(distanceAlongStep: CLLocationDistance, text: String, ssmlText: String) { + public init(distanceAlongStep: LocationDistance, text: String, ssmlText: String) { self.distanceAlongStep = distanceAlongStep self.text = text self.ssmlText = ssmlText @@ -41,7 +37,7 @@ open class SpokenInstruction: Codable { The distance is measured in meters from the beginning of the associated step. */ - public let distanceAlongStep: CLLocationDistance + public let distanceAlongStep: LocationDistance // MARK: Getting the Instruction to Say diff --git a/Sources/MapboxDirections/VisualInstruction.swift b/Sources/MapboxDirections/VisualInstruction.swift index f98a3b8fd..fe8ca0080 100644 --- a/Sources/MapboxDirections/VisualInstruction.swift +++ b/Sources/MapboxDirections/VisualInstruction.swift @@ -1,9 +1,5 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif /** 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. @@ -22,7 +18,7 @@ open class VisualInstruction: Codable { /** Initializes a new visual instruction banner object that displays the given information. */ - public init(text: String?, maneuverType: ManeuverType?, maneuverDirection: ManeuverDirection?, components: [Component], degrees: CLLocationDegrees? = nil) { + public init(text: String?, maneuverType: ManeuverType?, maneuverDirection: ManeuverDirection?, components: [Component], degrees: LocationDegrees? = nil) { self.text = text self.maneuverType = maneuverType self.maneuverDirection = maneuverDirection @@ -45,7 +41,7 @@ open class VisualInstruction: Codable { maneuverType = try container.decodeIfPresent(ManeuverType.self, forKey: .maneuverType) maneuverDirection = try container.decodeIfPresent(ManeuverDirection.self, forKey: .maneuverDirection) components = try container.decode([Component].self, forKey: .components) - finalHeading = try container.decodeIfPresent(CLLocationDegrees.self, forKey: .finalHeading) + finalHeading = try container.decodeIfPresent(LocationDegrees.self, forKey: .finalHeading) } // MARK: Displaying the Instruction Text @@ -81,7 +77,7 @@ open class VisualInstruction: Codable { This property is only relevant if the `maneuverType` is any of the following values: `ManeuverType.takeRoundabout`, `ManeuverType.takeRotary`, `ManeuverType.turnAtRoundabout`, `ManeuverType.exitRoundabout`, or `ManeuverType.exitRotary`. */ - public var finalHeading: CLLocationDegrees? + public var finalHeading: LocationDegrees? } extension VisualInstruction: Equatable { diff --git a/Sources/MapboxDirections/VisualInstructionBanner.swift b/Sources/MapboxDirections/VisualInstructionBanner.swift index 9fd66a960..9d2b7c4ed 100644 --- a/Sources/MapboxDirections/VisualInstructionBanner.swift +++ b/Sources/MapboxDirections/VisualInstructionBanner.swift @@ -1,9 +1,5 @@ import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif internal extension CodingUserInfoKey { static let drivingSide = CodingUserInfoKey(rawValue: "drivingSide")! @@ -27,7 +23,7 @@ open class VisualInstructionBanner: Codable { /** Initializes a visual instruction banner with the given instructions. */ - public init(distanceAlongStep: CLLocationDistance, primary: VisualInstruction, secondary: VisualInstruction?, tertiary: VisualInstruction?, quaternary: VisualInstruction?, drivingSide: DrivingSide) { + public init(distanceAlongStep: LocationDistance, primary: VisualInstruction, secondary: VisualInstruction?, tertiary: VisualInstruction?, quaternary: VisualInstruction?, drivingSide: DrivingSide) { self.distanceAlongStep = distanceAlongStep primaryInstruction = primary secondaryInstruction = secondary @@ -48,7 +44,7 @@ open class VisualInstructionBanner: Codable { required public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - distanceAlongStep = try container.decode(CLLocationDistance.self, forKey: .distanceAlongStep) + distanceAlongStep = try container.decode(LocationDistance.self, forKey: .distanceAlongStep) primaryInstruction = try container.decode(VisualInstruction.self, forKey: .primaryInstruction) secondaryInstruction = try container.decodeIfPresent(VisualInstruction.self, forKey: .secondaryInstruction) tertiaryInstruction = try container.decodeIfPresent(VisualInstruction.self, forKey: .tertiaryInstruction) @@ -65,7 +61,7 @@ open class VisualInstructionBanner: Codable { /** The distance at which the visual instruction should be shown, measured in meters from the beginning of the step. */ - public let distanceAlongStep: CLLocationDistance + public let distanceAlongStep: LocationDistance // MARK: Getting the Instructions to Display diff --git a/Sources/MapboxDirections/Waypoint.swift b/Sources/MapboxDirections/Waypoint.swift index 8221b4ef0..1833f2d80 100644 --- a/Sources/MapboxDirections/Waypoint.swift +++ b/Sources/MapboxDirections/Waypoint.swift @@ -1,8 +1,7 @@ #if canImport(CoreLocation) import CoreLocation -#else -import Turf #endif +import Turf /** 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. @@ -24,15 +23,15 @@ public class Waypoint: Codable { required public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - coordinate = try container.decode(CLLocationCoordinate2DCodable.self, forKey: .coordinate).decodedCoordinates + coordinate = try container.decode(LocationCoordinate2DCodable.self, forKey: .coordinate).decodedCoordinates coordinateAccuracy = try container.decodeIfPresent(LocationAccuracy.self, forKey: .coordinateAccuracy) - targetCoordinate = try container.decodeIfPresent(CLLocationCoordinate2DCodable.self, forKey: .targetCoordinate)?.decodedCoordinates + targetCoordinate = try container.decodeIfPresent(LocationCoordinate2DCodable.self, forKey: .targetCoordinate)?.decodedCoordinates - heading = try container.decodeIfPresent(CLLocationDirection.self, forKey: .heading) + heading = try container.decodeIfPresent(LocationDirection.self, forKey: .heading) - headingAccuracy = try container.decodeIfPresent(CLLocationDirection.self, forKey: .headingAccuracy) + headingAccuracy = try container.decodeIfPresent(LocationDirection.self, forKey: .headingAccuracy) if let separates = try container.decodeIfPresent(Bool.self, forKey: .separatesLegs) { separatesLegs = separates @@ -53,9 +52,9 @@ public class Waypoint: Codable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(CLLocationCoordinate2DCodable(coordinate), forKey: .coordinate) + try container.encode(LocationCoordinate2DCodable(coordinate), forKey: .coordinate) try container.encode(coordinateAccuracy, forKey: .coordinateAccuracy) - let targetCoordinateCodable = targetCoordinate != nil ? CLLocationCoordinate2DCodable(targetCoordinate!) : nil + let targetCoordinateCodable = targetCoordinate != nil ? LocationCoordinate2DCodable(targetCoordinate!) : nil try container.encode(targetCoordinateCodable, forKey: .targetCoordinate) try container.encodeIfPresent(heading, forKey: .heading) try container.encodeIfPresent(headingAccuracy, forKey: .headingAccuracy) @@ -73,7 +72,7 @@ public class Waypoint: Codable { It is recommended that the value of this argument be greater than the `horizontalAccuracy` property of a `CLLocation` object obtained from a `CLLocationManager` object. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway or inside a building. - parameter name: The name of the waypoint. This argument does not affect the route but may help you to distinguish one waypoint from another. */ - public init(coordinate: CLLocationCoordinate2D, coordinateAccuracy: LocationAccuracy? = nil, name: String? = nil) { + public init(coordinate: LocationCoordinate2D, coordinateAccuracy: LocationAccuracy? = nil, name: String? = nil) { self.coordinate = coordinate self.coordinateAccuracy = coordinateAccuracy self.name = name @@ -84,13 +83,13 @@ public class Waypoint: Codable { /** Initializes a new waypoint object with the given `CLLocation` object and an optional heading value and name. - - note: This initializer is intended for `CLLocation` objects created using the `CLLocation.init(latitude:longitude:)` initializer. If you intend to use a `CLLocation` object obtained from a `CLLocationManager` object, consider increasing the `horizontalAccuracy` or set it to a negative value to avoid overfitting, since the `Waypoint` class’s `coordinateAccuracy` property represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway of inside a building. + - note: This initializer is intended for `CLLocation` objects created using the `CLLocation(latitude:longitude:)` initializer. If you intend to use a `CLLocation` object obtained from a `CLLocationManager` object, consider increasing the `horizontalAccuracy` or set it to a negative value to avoid overfitting, since the `Waypoint` class’s `coordinateAccuracy` property represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway of inside a building. - parameter location: A `CLLocation` object representing the waypoint’s location. This initializer respects the `CLLocation` class’s `coordinate` and `horizontalAccuracy` properties, converting them into the `coordinate` and `coordinateAccuracy` properties, respectively. - - parameter heading: A `CLLocationDirection` value representing the direction from which the route must approach the waypoint in order to be considered viable. This value is stored in the `headingAccuracy` property. + - parameter heading: A `LocationDirection` value representing the direction from which the route must approach the waypoint in order to be considered viable. This value is stored in the `headingAccuracy` property. - parameter name: The name of the waypoint. This argument does not affect the route but may help you to distinguish one waypoint from another. */ - public init(location: CLLocation, heading: CLLocationDirection? = nil, name: String? = nil) { + public init(location: CLLocation, heading: LocationDirection? = nil, name: String? = nil) { coordinate = location.coordinate coordinateAccuracy = location.horizontalAccuracy if let heading = heading , heading >= 0 { @@ -102,7 +101,7 @@ public class Waypoint: Codable { /** Initializes a new waypoint object with the given `CLLocation` object and an optional `CLHeading` object and name. - - note: This initializer is intended for `CLLocation` objects created using the `CLLocation.init(latitude:longitude:)` initializer. If you intend to use a `CLLocation` object obtained from a `CLLocationManager` object, consider increasing the `horizontalAccuracy` or set it to a negative value to avoid overfitting, since the `Waypoint` class’s `coordinateAccuracy` property represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway of inside a building. + - note: This initializer is intended for `CLLocation` objects created using the `CLLocation(latitude:longitude:)` initializer. If you intend to use a `CLLocation` object obtained from a `CLLocationManager` object, consider increasing the `horizontalAccuracy` or set it to a negative value to avoid overfitting, since the `Waypoint` class’s `coordinateAccuracy` property represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway of inside a building. - parameter location: A `CLLocation` object representing the waypoint’s location. This initializer respects the `CLLocation` class’s `coordinate` and `horizontalAccuracy` properties, converting them into the `coordinate` and `coordinateAccuracy` properties, respectively. - parameter heading: A `CLHeading` object representing the direction from which the route must approach the waypoint in order to be considered viable. This initializer respects the `CLHeading` class’s `trueHeading` property or `magneticHeading` property, converting it into the `headingAccuracy` property. @@ -124,7 +123,7 @@ public class Waypoint: Codable { /** The geographic coordinate of the waypoint. */ - public let coordinate: CLLocationCoordinate2D + public let coordinate: LocationCoordinate2D /** The radius of uncertainty for the waypoint, measured in meters. @@ -144,7 +143,7 @@ public class Waypoint: Codable { This property corresponds to the [`waypoint_targets`](https://docs.mapbox.com/api/navigation/#retrieve-directions) query parameter in the Mapbox Directions and Map Matching APIs. */ - public var targetCoordinate: CLLocationCoordinate2D? + public var targetCoordinate: LocationCoordinate2D? // MARK: Getting the Direction of Approach @@ -161,7 +160,7 @@ public class Waypoint: Codable { By default, the value of this property is `nil`, meaning that a route is considered viable regardless of the direction of approach. */ - public var heading: CLLocationDirection? = nil + public var heading: LocationDirection? = nil /** The maximum amount, in degrees, by which a route’s approach to a waypoint may differ from `heading` in either direction in order to be considered viable. @@ -172,7 +171,7 @@ public class Waypoint: Codable { By default, the value of this property is `nil`, meaning that a route is considered viable regardless of the direction of approach. */ - public var headingAccuracy: CLLocationDirection? = nil + public var headingAccuracy: LocationDirection? = nil internal var headingDescription: String { guard let heading = heading, heading >= 0, diff --git a/Tests/MapboxDirectionsTests/DirectionsTests.swift b/Tests/MapboxDirectionsTests/DirectionsTests.swift index c8552fd11..fd2fa09d4 100644 --- a/Tests/MapboxDirectionsTests/DirectionsTests.swift +++ b/Tests/MapboxDirectionsTests/DirectionsTests.swift @@ -4,9 +4,8 @@ import OHHTTPStubs #endif #if canImport(CoreLocation) import CoreLocation -#else -import Turf #endif +import Turf @testable import MapboxDirections let BogusToken = "pk.feedCafeDadeDeadBeef-BadeBede.FadeCafeDadeDeed-BadeBede" @@ -52,7 +51,7 @@ class DirectionsTests: XCTestCase { func testGETRequest() { // Bumps right up against MaximumURLLength - let coordinates = Array(repeating: CLLocationCoordinate2D(latitude: 0, longitude: 0), count: maximumCoordinateCount) + let coordinates = Array(repeating: LocationCoordinate2D(latitude: 0, longitude: 0), count: maximumCoordinateCount) let options = RouteOptions(coordinates: coordinates) let directions = Directions(credentials: BogusCredentials) @@ -69,7 +68,7 @@ class DirectionsTests: XCTestCase { } func testPOSTRequest() { - let coordinates = Array(repeating: CLLocationCoordinate2D(latitude: 0, longitude: 0), count: maximumCoordinateCount + 1) + let coordinates = Array(repeating: LocationCoordinate2D(latitude: 0, longitude: 0), count: maximumCoordinateCount + 1) let options = RouteOptions(coordinates: coordinates) let directions = Directions(credentials: BogusCredentials) @@ -92,8 +91,8 @@ class DirectionsTests: XCTestCase { return HTTPStubsResponse(data: BadResponse.data(using: .utf8)!, statusCode: 413, headers: ["Content-Type" : "text/html"]) } let expectation = self.expectation(description: "Async callback") - let one = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)) - let two = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 2.0, longitude: 2.0)) + let one = CLLocation(latitude: 0.0, longitude: 0.0) + let two = CLLocation(latitude: 2.0, longitude: 2.0) let directions = Directions(credentials: BogusCredentials) let opts = RouteOptions(locations: [one, two]) @@ -118,8 +117,8 @@ class DirectionsTests: XCTestCase { return HTTPStubsResponse(data: message.data(using: .utf8)!, statusCode: 420, headers: ["Content-Type" : "text/plain"]) } let expectation = self.expectation(description: "Async callback") - let one = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)) - let two = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 2.0, longitude: 2.0)) + let one = CLLocation(latitude: 0.0, longitude: 0.0) + let two = CLLocation(latitude: 2.0, longitude: 2.0) let directions = Directions(credentials: BogusCredentials) let opts = RouteOptions(locations: [one, two]) @@ -165,8 +164,8 @@ class DirectionsTests: XCTestCase { } let expectation = self.expectation(description: "Async callback") - let one = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)) - let two = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 2.0, longitude: 2.0)) + let one = CLLocation(latitude: 0.0, longitude: 0.0) + let two = CLLocation(latitude: 2.0, longitude: 2.0) let directions = Directions(credentials: BogusCredentials) let opts = RouteOptions(locations: [one, two]) diff --git a/Tests/MapboxDirectionsTests/IntersectionTests.swift b/Tests/MapboxDirectionsTests/IntersectionTests.swift index 73ecd355c..043c146c4 100644 --- a/Tests/MapboxDirectionsTests/IntersectionTests.swift +++ b/Tests/MapboxDirectionsTests/IntersectionTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class IntersectionTests: XCTestCase { @@ -54,12 +50,12 @@ class IntersectionTests: XCTestCase { if let intersection = intersections?.first { XCTAssertEqual(intersection.outletRoadClasses, [.toll, .restricted]) XCTAssertEqual(intersection.headings, [80.0]) - XCTAssertEqual(intersection.location, CLLocationCoordinate2D(latitude: 52.508068, longitude: 13.426579)) + XCTAssertEqual(intersection.location, LocationCoordinate2D(latitude: 52.508068, longitude: 13.426579)) XCTAssertEqual(intersection.outletMapboxStreetsRoadClass, MapboxStreetsRoadClass.streetLimited) } intersections = [ - Intersection(location: CLLocationCoordinate2D(latitude: 52.508068, longitude: 13.426579), + Intersection(location: LocationCoordinate2D(latitude: 52.508068, longitude: 13.426579), headings: [80.0], approachIndex: -1, outletIndex: 0, @@ -72,7 +68,7 @@ class IntersectionTests: XCTestCase { restStop: nil, isUrban: nil, outletMapboxStreetsRoadClass: .streetLimited), - Intersection(location: CLLocationCoordinate2D(latitude: 52.508022, longitude: 13.426688), + Intersection(location: LocationCoordinate2D(latitude: 52.508022, longitude: 13.426688), headings: [30.0, 120.0, 300.0], approachIndex: 2, outletIndex: 1, @@ -84,7 +80,7 @@ class IntersectionTests: XCTestCase { tunnelName: nil, restStop: nil, isUrban: nil), - Intersection(location: CLLocationCoordinate2D(latitude: 39.102483, longitude: -84.503956), + Intersection(location: LocationCoordinate2D(latitude: 39.102483, longitude: -84.503956), headings: [45, 135, 255], approachIndex: 2, outletIndex: 0, diff --git a/Tests/MapboxDirectionsTests/MatchOptionsTests.swift b/Tests/MapboxDirectionsTests/MatchOptionsTests.swift index 31d658ac3..4b7f86d8d 100644 --- a/Tests/MapboxDirectionsTests/MatchOptionsTests.swift +++ b/Tests/MapboxDirectionsTests/MatchOptionsTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class MatchOptionsTests: XCTestCase { @@ -33,15 +29,15 @@ class MatchOptionsTests: XCTestCase { // MARK: API name-handling tests private static var testTracepoints: [Tracepoint] { - let one = CLLocationCoordinate2D(latitude: 39.27664, longitude:-84.41139) - let two = CLLocationCoordinate2D(latitude: 39.27277, longitude:-84.41226) + let one = LocationCoordinate2D(latitude: 39.27664, longitude:-84.41139) + let two = LocationCoordinate2D(latitude: 39.27277, longitude:-84.41226) return [one, two].map { Tracepoint(coordinate: $0, countOfAlternatives: 0, name: nil) } } func testWaypointSerialization() { - let origin = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.15031, longitude: -84.47182), name: "XU") - let destination = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.12971, longitude: -84.51638), name: "UC") + let origin = Waypoint(coordinate: LocationCoordinate2D(latitude: 39.15031, longitude: -84.47182), name: "XU") + let destination = Waypoint(coordinate: LocationCoordinate2D(latitude: 39.12971, longitude: -84.51638), name: "UC") let options = MatchOptions(waypoints: [origin, destination]) XCTAssertEqual(options.coordinates, "-84.47182,39.15031;-84.51638,39.12971") XCTAssertTrue(options.urlQueryItems.contains(URLQueryItem(name: "waypoint_names", value: "XU;UC"))) @@ -62,9 +58,9 @@ class MatchOptionsTests: XCTestCase { } fileprivate let testCoordinates = [ - CLLocationCoordinate2D(latitude: 52.5109, longitude: 13.4301), - CLLocationCoordinate2D(latitude: 52.5080, longitude: 13.4265), - CLLocationCoordinate2D(latitude: 52.5021, longitude: 13.4316), + LocationCoordinate2D(latitude: 52.5109, longitude: 13.4301), + LocationCoordinate2D(latitude: 52.5080, longitude: 13.4265), + LocationCoordinate2D(latitude: 52.5021, longitude: 13.4316), ] diff --git a/Tests/MapboxDirectionsTests/MatchTests.swift b/Tests/MapboxDirectionsTests/MatchTests.swift index 3bc7427b9..5a395de64 100644 --- a/Tests/MapboxDirectionsTests/MatchTests.swift +++ b/Tests/MapboxDirectionsTests/MatchTests.swift @@ -1,9 +1,8 @@ import XCTest #if canImport(CoreLocation) import CoreLocation -#else -import Turf #endif +import Turf #if !SWIFT_PACKAGE import OHHTTPStubs #endif @@ -193,9 +192,9 @@ class MatchTests: XCTestCase { let matchData = try! JSONSerialization.data(withJSONObject: matchJSON, options: []) let options = MatchOptions(coordinates: [ - CLLocationCoordinate2D(latitude: 39.09740, longitude: -84.51200), - CLLocationCoordinate2D(latitude: 39.09638, longitude: -84.51118), - CLLocationCoordinate2D(latitude: 39.09687, longitude: -84.51021), + LocationCoordinate2D(latitude: 39.09740, longitude: -84.51200), + LocationCoordinate2D(latitude: 39.09638, longitude: -84.51118), + LocationCoordinate2D(latitude: 39.09687, longitude: -84.51021), ]) options.routeShapeResolution = .none diff --git a/Tests/MapboxDirectionsTests/OfflineDirectionsTests.swift b/Tests/MapboxDirectionsTests/OfflineDirectionsTests.swift index 1a9c867df..dc51caadf 100644 --- a/Tests/MapboxDirectionsTests/OfflineDirectionsTests.swift +++ b/Tests/MapboxDirectionsTests/OfflineDirectionsTests.swift @@ -38,8 +38,8 @@ class OfflineDirectionsTests: XCTestCase { func testDownloadTiles() { let directions = Directions(credentials: BogusCredentials) - let bounds = BoundingBox(CLLocationCoordinate2D(latitude: 37.7890, longitude: -122.4337), - CLLocationCoordinate2D(latitude: 37.7881, longitude: -122.4318)) + let bounds = BoundingBox(southWest: CLLocationCoordinate2D(latitude: 37.7890, longitude: -122.4337), + northEast: CLLocationCoordinate2D(latitude: 37.7881, longitude: -122.4318)) let version = "2018-10-16" let downloadExpectation = self.expectation(description: "Download tile expectation") diff --git a/Tests/MapboxDirectionsTests/QuickLookTests.swift b/Tests/MapboxDirectionsTests/QuickLookTests.swift index 8ebafe9b5..4b0467de0 100644 --- a/Tests/MapboxDirectionsTests/QuickLookTests.swift +++ b/Tests/MapboxDirectionsTests/QuickLookTests.swift @@ -1,15 +1,12 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#endif import Turf @testable import MapboxDirections class QuickLookTests: XCTestCase { func testQuickLookURL() { let lineString = LineString([ - CLLocationCoordinate2D(latitude: 0, longitude: 0), - CLLocationCoordinate2D(latitude: 1, longitude: 1), + LocationCoordinate2D(latitude: 0, longitude: 0), + LocationCoordinate2D(latitude: 1, longitude: 1), ]) XCTAssertNil(debugQuickLookURL(illustrating: lineString)) XCTAssertEqual(debugQuickLookURL(illustrating: lineString, accessToken: BogusToken), URL(string: "https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/path-10+3802DA-0.6(%3F%3F_ibE_ibE)/auto/680x360@2x?before_layer=building-number-label&access_token=\(BogusToken)")) diff --git a/Tests/MapboxDirectionsTests/RouteLegTests.swift b/Tests/MapboxDirectionsTests/RouteLegTests.swift index 2fa847007..becc03dfe 100644 --- a/Tests/MapboxDirectionsTests/RouteLegTests.swift +++ b/Tests/MapboxDirectionsTests/RouteLegTests.swift @@ -1,26 +1,23 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#endif import Turf @testable import MapboxDirections class RouteLegTests: XCTestCase { func testSegmentRanges() { - let departureStep = RouteStep(transportType: .automobile, maneuverLocation: CLLocationCoordinate2D(latitude: 0, longitude: 0), maneuverType: .depart, instructions: "Depart", drivingSide: .right, distance: 10, expectedTravelTime: 10) + let departureStep = RouteStep(transportType: .automobile, maneuverLocation: LocationCoordinate2D(latitude: 0, longitude: 0), maneuverType: .depart, instructions: "Depart", drivingSide: .right, distance: 10, expectedTravelTime: 10) departureStep.shape = LineString([ - CLLocationCoordinate2D(latitude: 0, longitude: 0), - CLLocationCoordinate2D(latitude: 1, longitude: 1), + LocationCoordinate2D(latitude: 0, longitude: 0), + LocationCoordinate2D(latitude: 1, longitude: 1), ]) - let turnStep = RouteStep(transportType: .automobile, maneuverLocation: CLLocationCoordinate2D(latitude: 1, longitude: 1), maneuverType: .turn, maneuverDirection: .left, instructions: "Turn left at Albuquerque", drivingSide: .right, distance: 10, expectedTravelTime: 10) + let turnStep = RouteStep(transportType: .automobile, maneuverLocation: LocationCoordinate2D(latitude: 1, longitude: 1), maneuverType: .turn, maneuverDirection: .left, instructions: "Turn left at Albuquerque", drivingSide: .right, distance: 10, expectedTravelTime: 10) turnStep.shape = LineString([ - CLLocationCoordinate2D(latitude: 1, longitude: 1), - CLLocationCoordinate2D(latitude: 2, longitude: 2), - CLLocationCoordinate2D(latitude: 3, longitude: 3), - CLLocationCoordinate2D(latitude: 4, longitude: 4), + LocationCoordinate2D(latitude: 1, longitude: 1), + LocationCoordinate2D(latitude: 2, longitude: 2), + LocationCoordinate2D(latitude: 3, longitude: 3), + LocationCoordinate2D(latitude: 4, longitude: 4), ]) let typicalTravelTime = 10.0 - let arrivalStep = RouteStep(transportType: .automobile, maneuverLocation: CLLocationCoordinate2D(latitude: 4, longitude: 4), maneuverType: .arrive, instructions: "Arrive at Elmer’s House", drivingSide: .right, distance: 0, expectedTravelTime: 0) + let arrivalStep = RouteStep(transportType: .automobile, maneuverLocation: LocationCoordinate2D(latitude: 4, longitude: 4), maneuverType: .arrive, instructions: "Arrive at Elmer’s House", drivingSide: .right, distance: 0, expectedTravelTime: 0) let leg = RouteLeg(steps: [departureStep, turnStep, arrivalStep], name: "", distance: 10, expectedTravelTime: 10, typicalTravelTime: typicalTravelTime, profileIdentifier: .automobile) leg.segmentDistances = [ 10, diff --git a/Tests/MapboxDirectionsTests/RouteOptionsTests.swift b/Tests/MapboxDirectionsTests/RouteOptionsTests.swift index 05736b816..dd6325f74 100644 --- a/Tests/MapboxDirectionsTests/RouteOptionsTests.swift +++ b/Tests/MapboxDirectionsTests/RouteOptionsTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class RouteOptionsTests: XCTestCase { @@ -39,8 +35,8 @@ class RouteOptionsTests: XCTestCase { private static var testWaypoints: [Waypoint] { return [ - Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.27664, longitude:-84.41139)), - Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.27277, longitude:-84.41226)), + Waypoint(coordinate: LocationCoordinate2D(latitude: 39.27664, longitude:-84.41139)), + Waypoint(coordinate: LocationCoordinate2D(latitude: 39.27277, longitude:-84.41226)), ] } @@ -94,7 +90,7 @@ class RouteOptionsTests: XCTestCase { } func testApproachesURLQueryParams() { - let coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0) + let coordinate = LocationCoordinate2D(latitude: 0, longitude: 0) let wp1 = Waypoint(coordinate: coordinate, coordinateAccuracy: 0) wp1.allowsArrivingOnOppositeSide = false let waypoints = [ @@ -111,7 +107,7 @@ class RouteOptionsTests: XCTestCase { } func testMissingApproaches() { - let coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0) + let coordinate = LocationCoordinate2D(latitude: 0, longitude: 0) let waypoints = [ Waypoint(coordinate: coordinate, coordinateAccuracy: 0), Waypoint(coordinate: coordinate, coordinateAccuracy: 0), @@ -126,8 +122,8 @@ class RouteOptionsTests: XCTestCase { } func testDecimalPrecision() { - let start = CLLocationCoordinate2D(latitude: 9.945497000000003, longitude: 53.03218800000006) - let end = CLLocationCoordinate2D(latitude: 10.945497000000003, longitude: 54.03218800000006) + let start = LocationCoordinate2D(latitude: 9.945497000000003, longitude: 53.03218800000006) + let end = LocationCoordinate2D(latitude: 10.945497000000003, longitude: 54.03218800000006) let answer = [start.requestDescription, end.requestDescription] let correct = ["53.032188,9.945497", "54.032188,10.945497"] @@ -135,9 +131,9 @@ class RouteOptionsTests: XCTestCase { } func testWaypointSerialization() { - let origin = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.15031, longitude: -84.47182), name: "XU") - let destination = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.12971, longitude: -84.51638), name: "UC") - destination.targetCoordinate = CLLocationCoordinate2D(latitude: 39.13115, longitude: -84.51619) + let origin = Waypoint(coordinate: LocationCoordinate2D(latitude: 39.15031, longitude: -84.47182), name: "XU") + let destination = Waypoint(coordinate: LocationCoordinate2D(latitude: 39.12971, longitude: -84.51638), name: "UC") + destination.targetCoordinate = LocationCoordinate2D(latitude: 39.13115, longitude: -84.51619) let options = RouteOptions(waypoints: [origin, destination]) XCTAssertEqual(options.coordinates, "-84.47182,39.15031;-84.51638,39.12971") XCTAssertTrue(options.urlQueryItems.contains(URLQueryItem(name: "waypoint_names", value: "XU;UC"))) @@ -146,9 +142,9 @@ class RouteOptionsTests: XCTestCase { } fileprivate let testCoordinates = [ - CLLocationCoordinate2D(latitude: 52.5109, longitude: 13.4301), - CLLocationCoordinate2D(latitude: 52.5080, longitude: 13.4265), - CLLocationCoordinate2D(latitude: 52.5021, longitude: 13.4316), + LocationCoordinate2D(latitude: 52.5109, longitude: 13.4301), + LocationCoordinate2D(latitude: 52.5080, longitude: 13.4265), + LocationCoordinate2D(latitude: 52.5021, longitude: 13.4316), ] var testRouteOptions: RouteOptions { diff --git a/Tests/MapboxDirectionsTests/RouteRefreshTests.swift b/Tests/MapboxDirectionsTests/RouteRefreshTests.swift index db76c715f..3ff8a6a6a 100644 --- a/Tests/MapboxDirectionsTests/RouteRefreshTests.swift +++ b/Tests/MapboxDirectionsTests/RouteRefreshTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif #if !SWIFT_PACKAGE import OHHTTPStubs #endif @@ -199,7 +195,7 @@ class RouteRefreshTests: XCTestCase { let annotationJSON = legJSON["annotation"] as? [String: Any] XCTAssertNotNil(annotationJSON) if let annotationJSON = annotationJSON { - XCTAssertEqual(annotationJSON["distance"] as? [CLLocationDistance], [0]) + XCTAssertEqual(annotationJSON["distance"] as? [LocationDistance], [0]) XCTAssertEqual(annotationJSON["duration"] as? [TimeInterval], [0]) XCTAssertEqual(annotationJSON["speed"] as? [LocationSpeed], [0]) XCTAssertEqual(annotationJSON["congestion"] as? [String], ["severe"]) diff --git a/Tests/MapboxDirectionsTests/RouteResponseTests.swift b/Tests/MapboxDirectionsTests/RouteResponseTests.swift index 12757f1c5..cb31b40b9 100644 --- a/Tests/MapboxDirectionsTests/RouteResponseTests.swift +++ b/Tests/MapboxDirectionsTests/RouteResponseTests.swift @@ -1,15 +1,11 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class RouteResponseTests: XCTestCase { func testRouteResponseEncodingAndDecoding() { - let originCoordinate = CLLocationCoordinate2D(latitude: 39.15031, longitude: -84.47182) + let originCoordinate = LocationCoordinate2D(latitude: 39.15031, longitude: -84.47182) let originWaypoint = Waypoint(coordinate: originCoordinate, name: "Test waypoint") originWaypoint.targetCoordinate = originCoordinate originWaypoint.coordinateAccuracy = 1.0 diff --git a/Tests/MapboxDirectionsTests/RouteStepTests.swift b/Tests/MapboxDirectionsTests/RouteStepTests.swift index 78a4a4dfb..a1b6c2e4b 100644 --- a/Tests/MapboxDirectionsTests/RouteStepTests.swift +++ b/Tests/MapboxDirectionsTests/RouteStepTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class RoadTests: XCTestCase { @@ -138,7 +134,7 @@ class RouteStepTests: XCTestCase { XCTAssertEqual(step.shape?.coordinates.last?.longitude ?? 0, -122.220021, accuracy: 1e-5) XCTAssertEqual(step.finalHeading, 73) XCTAssertEqual(step.initialHeading, 60) - XCTAssertEqual(step.maneuverLocation, CLLocationCoordinate2D(latitude: -122.220291, longitude: 37.854109)) + XCTAssertEqual(step.maneuverLocation, LocationCoordinate2D(latitude: -122.220291, longitude: 37.854109)) XCTAssertEqual(step.maneuverDirection, .slightRight) XCTAssertEqual(step.maneuverType, .reachFork) XCTAssertEqual(step.instructions, "Keep right onto CA 24") @@ -153,8 +149,8 @@ class RouteStepTests: XCTestCase { func testCoding() { let options = RouteOptions(coordinates: [ - CLLocationCoordinate2D(latitude: 52.50881, longitude: 13.42467), - CLLocationCoordinate2D(latitude: 52.506794, longitude: 13.42326), + LocationCoordinate2D(latitude: 52.50881, longitude: 13.42467), + LocationCoordinate2D(latitude: 52.506794, longitude: 13.42326), ]) options.shapeFormat = .polyline @@ -260,10 +256,10 @@ class RouteStepTests: XCTestCase { func testEncodingPronunciations() { let options = RouteOptions(coordinates: [ - CLLocationCoordinate2D(latitude: 0, longitude: 0), - CLLocationCoordinate2D(latitude: 1, longitude: 1), + LocationCoordinate2D(latitude: 0, longitude: 0), + LocationCoordinate2D(latitude: 1, longitude: 1), ]) - let step = RouteStep(transportType: .automobile, maneuverLocation: CLLocationCoordinate2D(latitude: 0, longitude: 0), maneuverType: .turn, maneuverDirection: .left, instructions: "", initialHeading: 0, finalHeading: 0, drivingSide: .right, distance: 10, expectedTravelTime: 10, names: ["iPhone X", "iPhone XS"], phoneticNames: ["ˈaɪˌfoʊ̯n ˈtɛn", "ˈaɪˌfoʊ̯n ˈtɛnz"]) + let step = RouteStep(transportType: .automobile, maneuverLocation: LocationCoordinate2D(latitude: 0, longitude: 0), maneuverType: .turn, maneuverDirection: .left, instructions: "", initialHeading: 0, finalHeading: 0, drivingSide: .right, distance: 10, expectedTravelTime: 10, names: ["iPhone X", "iPhone XS"], phoneticNames: ["ˈaɪˌfoʊ̯n ˈtɛn", "ˈaɪˌfoʊ̯n ˈtɛnz"]) let encoder = JSONEncoder() encoder.userInfo[.options] = options @@ -284,7 +280,7 @@ class RouteStepTests: XCTestCase { let typicalTravelTime = 2.5 let route = RouteStep(transportType: .automobile, - maneuverLocation: CLLocationCoordinate2D(latitude: 0, longitude: 0), + maneuverLocation: LocationCoordinate2D(latitude: 0, longitude: 0), maneuverType: .turn, instructions: "", drivingSide: .left, @@ -300,8 +296,8 @@ class RouteStepTests: XCTestCase { let filePath = URL(fileURLWithPath: path!) let data = try! Data(contentsOf: filePath) let options = RouteOptions(coordinates: [ - CLLocationCoordinate2D(latitude: 37.78, longitude: -122.42), - CLLocationCoordinate2D(latitude: 38.91, longitude: -77.03), + LocationCoordinate2D(latitude: 37.78, longitude: -122.42), + LocationCoordinate2D(latitude: 38.91, longitude: -77.03), ]) let decoder = JSONDecoder() diff --git a/Tests/MapboxDirectionsTests/RouteTests.swift b/Tests/MapboxDirectionsTests/RouteTests.swift index 94aede0aa..12d54754d 100644 --- a/Tests/MapboxDirectionsTests/RouteTests.swift +++ b/Tests/MapboxDirectionsTests/RouteTests.swift @@ -1,10 +1,6 @@ import XCTest import Foundation -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class RouteTests: XCTestCase { @@ -30,8 +26,8 @@ class RouteTests: XCTestCase { let routeData = try! JSONSerialization.data(withJSONObject: routeJSON, options: []) let options = RouteOptions(coordinates: [ - CLLocationCoordinate2D(latitude: 39.73843005470756, longitude: -105.08198579860195), - CLLocationCoordinate2D(latitude: 39.662569, longitude: -104.954255), + LocationCoordinate2D(latitude: 39.73843005470756, longitude: -105.08198579860195), + LocationCoordinate2D(latitude: 39.662569, longitude: -104.954255), ], profileIdentifier: .automobileAvoidingTraffic) options.routeShapeResolution = .none @@ -111,8 +107,8 @@ class RouteTests: XCTestCase { ] let options = RouteOptions(coordinates: [ - CLLocationCoordinate2D(latitude: 39.73843, longitude: -105.081986), - CLLocationCoordinate2D(latitude: 39.662569, longitude: -104.954255), + LocationCoordinate2D(latitude: 39.73843, longitude: -105.081986), + LocationCoordinate2D(latitude: 39.662569, longitude: -104.954255), ]) options.locale = Locale(identifier: "he") diff --git a/Tests/MapboxDirectionsTests/SpokenInstructionTests.swift b/Tests/MapboxDirectionsTests/SpokenInstructionTests.swift index 195ce0f20..652f63b52 100644 --- a/Tests/MapboxDirectionsTests/SpokenInstructionTests.swift +++ b/Tests/MapboxDirectionsTests/SpokenInstructionTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class SpokenInstructionTests: XCTestCase { @@ -18,12 +14,12 @@ class SpokenInstructionTests: XCTestCase { XCTAssertNoThrow(instruction = try JSONDecoder().decode(SpokenInstruction.self, from: instructionData)) XCTAssertNotNil(instruction) if let instruction = instruction { - XCTAssertEqual(instruction.distanceAlongStep, instructionJSON["distanceAlongGeometry"] as! CLLocationDistance) + XCTAssertEqual(instruction.distanceAlongStep, instructionJSON["distanceAlongGeometry"] as! LocationDistance) XCTAssertEqual(instruction.text, instructionJSON["announcement"] as! String) XCTAssertEqual(instruction.ssmlText, instructionJSON["ssmlAnnouncement"] as! String) } - instruction = SpokenInstruction(distanceAlongStep: instructionJSON["distanceAlongGeometry"] as! CLLocationDistance, + instruction = SpokenInstruction(distanceAlongStep: instructionJSON["distanceAlongGeometry"] as! LocationDistance, text: instructionJSON["announcement"] as! String, ssmlText: instructionJSON["ssmlAnnouncement"] as! String) let encoder = JSONEncoder() diff --git a/Tests/MapboxDirectionsTests/WalkingOptionsTests.swift b/Tests/MapboxDirectionsTests/WalkingOptionsTests.swift index eb0bd22cb..f9b431266 100644 --- a/Tests/MapboxDirectionsTests/WalkingOptionsTests.swift +++ b/Tests/MapboxDirectionsTests/WalkingOptionsTests.swift @@ -1,17 +1,13 @@ import XCTest import MapboxDirections -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class WalkingOptionsTests: XCTestCase { func testURLQueryParams() { let waypoints = [ - Waypoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 1)), - Waypoint(coordinate: CLLocationCoordinate2D(latitude: 2, longitude: 3)) + Waypoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 1)), + Waypoint(coordinate: LocationCoordinate2D(latitude: 2, longitude: 3)) ] let options = RouteOptions(waypoints: waypoints, profileIdentifier: DirectionsProfileIdentifier.walking) diff --git a/Tests/MapboxDirectionsTests/WaypointTests.swift b/Tests/MapboxDirectionsTests/WaypointTests.swift index b2fbdef27..c6fef077c 100644 --- a/Tests/MapboxDirectionsTests/WaypointTests.swift +++ b/Tests/MapboxDirectionsTests/WaypointTests.swift @@ -1,9 +1,5 @@ import XCTest -#if canImport(CoreLocation) -import CoreLocation -#else import Turf -#endif @testable import MapboxDirections class WaypointTests: XCTestCase { @@ -29,8 +25,8 @@ class WaypointTests: XCTestCase { XCTAssertTrue(waypoint.separatesLegs) } - waypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), coordinateAccuracy: 5, name: "White House") - waypoint?.targetCoordinate = CLLocationCoordinate2D(latitude: 38.8952261, longitude: -77.0327882) + waypoint = Waypoint(coordinate: LocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), coordinateAccuracy: 5, name: "White House") + waypoint?.targetCoordinate = LocationCoordinate2D(latitude: 38.8952261, longitude: -77.0327882) waypoint?.heading = 90 waypoint?.headingAccuracy = 10 waypoint?.allowsArrivingOnOppositeSide = false @@ -46,18 +42,18 @@ class WaypointTests: XCTestCase { XCTAssertNotNil(encodedWaypointJSON) // Verify then remove keys that wouldn’t be part of a Waypoint object in the Directions API response. - XCTAssertEqual(encodedWaypointJSON?["headingAccuracy"] as? CLLocationDirection, waypoint?.headingAccuracy) + XCTAssertEqual(encodedWaypointJSON?["headingAccuracy"] as? LocationDirection, waypoint?.headingAccuracy) encodedWaypointJSON?.removeValue(forKey: "headingAccuracy") XCTAssertEqual(encodedWaypointJSON?["coordinateAccuracy"] as? LocationAccuracy, waypoint?.coordinateAccuracy) encodedWaypointJSON?.removeValue(forKey: "coordinateAccuracy") XCTAssertEqual(encodedWaypointJSON?["allowsArrivingOnOppositeSide"] as? Bool, waypoint?.allowsArrivingOnOppositeSide) encodedWaypointJSON?.removeValue(forKey: "allowsArrivingOnOppositeSide") - XCTAssertEqual(encodedWaypointJSON?["heading"] as? CLLocationDirection, waypoint?.heading) + XCTAssertEqual(encodedWaypointJSON?["heading"] as? LocationDirection, waypoint?.heading) encodedWaypointJSON?.removeValue(forKey: "heading") XCTAssertEqual(encodedWaypointJSON?["separatesLegs"] as? Bool, waypoint?.separatesLegs) encodedWaypointJSON?.removeValue(forKey: "separatesLegs") - let targetCoordinateJSON = encodedWaypointJSON?["targetCoordinate"] as? [CLLocationDegrees] + let targetCoordinateJSON = encodedWaypointJSON?["targetCoordinate"] as? [LocationDegrees] XCTAssertNotNil(targetCoordinateJSON) XCTAssertEqual(targetCoordinateJSON?.count, 2) XCTAssertEqual(targetCoordinateJSON?[0] ?? 0, waypoint?.targetCoordinate?.longitude ?? 0, accuracy: 1e-5) @@ -69,10 +65,10 @@ class WaypointTests: XCTestCase { } func testSeparatesLegs() { - let one = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 1, longitude: 1)) - let two = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 2, longitude: 2)) - let three = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 3, longitude: 3)) - let four = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 4, longitude: 4)) + let one = Waypoint(coordinate: LocationCoordinate2D(latitude: 1, longitude: 1)) + let two = Waypoint(coordinate: LocationCoordinate2D(latitude: 2, longitude: 2)) + let three = Waypoint(coordinate: LocationCoordinate2D(latitude: 3, longitude: 3)) + let four = Waypoint(coordinate: LocationCoordinate2D(latitude: 4, longitude: 4)) let routeOptions = RouteOptions(waypoints: [one, two, three, four]) let matchOptions = MatchOptions(waypoints: [one, two, three, four], profileIdentifier: nil) @@ -92,7 +88,7 @@ class WaypointTests: XCTestCase { } func testHeading() { - let waypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: -180, longitude: -180)) + let waypoint = Waypoint(coordinate: LocationCoordinate2D(latitude: -180, longitude: -180)) XCTAssertEqual(waypoint.headingDescription, "") waypoint.heading = 0 @@ -109,40 +105,40 @@ class WaypointTests: XCTestCase { } func testEquality() { - let left = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), coordinateAccuracy: nil, name: nil) + let left = Waypoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), coordinateAccuracy: nil, name: nil) XCTAssertEqual(left, left) - var right = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 1, longitude: 1), coordinateAccuracy: nil, name: nil) + var right = Waypoint(coordinate: LocationCoordinate2D(latitude: 1, longitude: 1), coordinateAccuracy: nil, name: nil) XCTAssertNotEqual(left, right) - right = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), coordinateAccuracy: 0, name: nil) + right = Waypoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), coordinateAccuracy: 0, name: nil) XCTAssertNotEqual(left, right) - right = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), coordinateAccuracy: nil, name: "") + right = Waypoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), coordinateAccuracy: nil, name: "") XCTAssertNotEqual(left, right) } func testTracepointEquality() { - let left = Tracepoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 0, name: nil) + let left = Tracepoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 0, name: nil) XCTAssertEqual(left, left) - let right = Tracepoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 0, name: nil) + let right = Tracepoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 0, name: nil) XCTAssertEqual(left, right) // FIXME: Only Waypoint.==(_:_:) ever gets called: . This will be moot once Tracepoint becomes a struct that doesn’t inherit from Waypoint: . -// right = Tracepoint(coordinate: CLLocationCoordinate2D(latitude: 1, longitude: 1), countOfAlternatives: 0, name: nil) +// right = Tracepoint(coordinate: LocationCoordinate2D(latitude: 1, longitude: 1), countOfAlternatives: 0, name: nil) // XCTAssertNotEqual(left, right) // -// right = Tracepoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 1, name: nil) +// right = Tracepoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 1, name: nil) // XCTAssertNotEqual(left, right) // -// right = Tracepoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 0, name: "") +// right = Tracepoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0), countOfAlternatives: 0, name: "") // XCTAssertNotEqual(left, right) } func testAccuracies() { - let from = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0)) - let to = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 0, longitude: 0)) + let from = Waypoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0)) + let to = Waypoint(coordinate: LocationCoordinate2D(latitude: 0, longitude: 0)) let options = RouteOptions(waypoints: [from, to]) XCTAssertNil(options.bearings) XCTAssertNil(options.radiuses) From 93647430b7c72ca934579579531d46a44790898e Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 2 Mar 2021 17:09:35 -0800 Subject: [PATCH 11/41] Prepare Mapbox Directions v2.0.0-alpha.2. --- Directions Example/Info.plist | 2 +- MapboxDirections.podspec | 2 +- MapboxDirections.xcodeproj/project.pbxproj | 32 +++++++++++----------- README.md | 6 ++-- Sources/MapboxDirections/Info.plist | 2 +- Tests/MapboxDirectionsTests/Info.plist | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist index 1b87ee0e2..86ffa4730 100644 --- a/Directions Example/Info.plist +++ b/Directions Example/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 62 + 63 LSRequiresIPhoneOS NSLocationWhenInUseUsageDescription diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 9d32d598d..e382619c5 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # s.name = "MapboxDirections" - s.version = "2.0.0-alpha.1" + s.version = "2.0.0-alpha.2" s.summary = "Mapbox Directions API wrapper for Swift." s.description = <<-DESC diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index 8891c51bb..d5225a7e1 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -1858,11 +1858,11 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1887,10 +1887,10 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1956,11 +1956,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1985,10 +1985,10 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2056,11 +2056,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2086,10 +2086,10 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2114,12 +2114,12 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2142,11 +2142,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/README.md b/README.md index 4725c8416..61a1aef37 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Specify the following dependency in your [Carthage](https://github.com/Carthage/ # Latest stable release github "mapbox/mapbox-directions-swift" ~> 1.2 # Latest prerelease -github "mapbox/mapbox-directions-swift" "v2.0.0-alpha.1" +github "mapbox/mapbox-directions-swift" "v2.0.0-alpha.2" ``` Or in your [CocoaPods](http://cocoapods.org/) Podfile: @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections-pre', '2.0.0-alpha.1' +pod 'MapboxDirections-pre', '2.0.0-alpha.2' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: @@ -36,7 +36,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s // Latest stable release .package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") // Latest prerelease -.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-alpha.1") +.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-alpha.2") ``` Then `import MapboxDirections`. diff --git a/Sources/MapboxDirections/Info.plist b/Sources/MapboxDirections/Info.plist index 7646600cb..90b7a4b6a 100644 --- a/Sources/MapboxDirections/Info.plist +++ b/Sources/MapboxDirections/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 62 + 63 NSHumanReadableCopyright Copyright © 2014–2020 Mapbox. All rights reserved. NSPrincipalClass diff --git a/Tests/MapboxDirectionsTests/Info.plist b/Tests/MapboxDirectionsTests/Info.plist index 0d11a9b3b..91d7e453d 100644 --- a/Tests/MapboxDirectionsTests/Info.plist +++ b/Tests/MapboxDirectionsTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 62 + 63 From 800f942e570d3ca448e38964adf103392775ad45 Mon Sep 17 00:00:00 2001 From: jill-cardamon <43434254+jill-cardamon@users.noreply.github.com> Date: Fri, 2 Apr 2021 19:01:54 -0400 Subject: [PATCH 12/41] Intersections indicate preferred lane usage (#529) * add new properties to VisualInstruction.Component and Intersection; update tests --- CHANGELOG.md | 4 ++ Sources/MapboxDirections/Intersection.swift | 39 ++++++++++++++++++- Sources/MapboxDirections/Lane.swift | 26 ++++++++++++- .../VisualInstructionComponent.swift | 15 ++++--- .../IntersectionTests.swift | 10 +++++ .../RouteStepTests.swift | 19 +++++++-- .../VisualInstructionComponentTests.swift | 6 ++- .../VisualInstructionTests.swift | 6 ++- 8 files changed, 111 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 082d13b28..05e78f7fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * This library requires Turf v2.0.0-alpha.3. ([#525](https://github.com/mapbox/mapbox-directions-swift/pull/525)) * The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) +## v2.0.0 +* Added the `Intersection.preferredApproachLanes` and `Intersection.usableLaneIndication` properties that indicate preferred lane usage. `VisualInstruction.Component.lane(indications:isUsable:)` has been renamed to `VisualInstruction.Component.lane(indications:isUsable:preferredDirection:)`. ([#529](https://github.com/mapbox/mapbox-directions-swift/pull/529)) +* Comparing two `Intersection`s with `==` now considers whether the `Intersection.restStop`, `Intersection.regionCode`, and `Intersection.outletMapboxStreetsRoadClass` properties are equal. ([#529](https://github.com/mapbox/mapbox-directions-swift/pull/529)) + ## v1.2.0 ### Packaging diff --git a/Sources/MapboxDirections/Intersection.swift b/Sources/MapboxDirections/Intersection.swift index f5f8ac646..a618f3a72 100644 --- a/Sources/MapboxDirections/Intersection.swift +++ b/Sources/MapboxDirections/Intersection.swift @@ -14,6 +14,8 @@ public struct Intersection { outletIndexes: IndexSet, approachLanes: [LaneIndication]?, usableApproachLanes: IndexSet?, + preferredApproachLanes: IndexSet?, + usableLaneIndication: LaneIndication?, outletRoadClasses: RoadClasses? = nil, tollCollection: TollCollection? = nil, tunnelName: String? = nil, @@ -28,6 +30,8 @@ public struct Intersection { self.outletIndex = outletIndex self.outletIndexes = outletIndexes self.usableApproachLanes = usableApproachLanes + self.preferredApproachLanes = preferredApproachLanes + self.usableLaneIndication = usableLaneIndication self.outletRoadClasses = outletRoadClasses self.tollCollection = tollCollection self.tunnelName = tunnelName @@ -148,6 +152,20 @@ public struct Intersection { If no lane information is available for an intersection, this property’s value is `nil`. */ public let usableApproachLanes: IndexSet? + + /** + The indices of the items in the `approachLanes` array that correspond to the lanes that are preferred to execute the maneuver. + + If no lane information is available for an intersection, this property’s value is `nil`. + */ + public let preferredApproachLanes: IndexSet? + + /** + Which of the `LaneIndication`s is applicable to the current route when there is more than one. + + If no lane information is available for the intersection, this property’s value is `nil` + */ + public let usableLaneIndication: LaneIndication? } extension Intersection: Codable { @@ -243,10 +261,18 @@ extension Intersection: Codable { var lanes: [Lane]? if let approachLanes = approachLanes, - let usableApproachLanes = usableApproachLanes { + let usableApproachLanes = usableApproachLanes, + let preferredApproachLanes = preferredApproachLanes, + let usableLaneIndication = usableLaneIndication { lanes = approachLanes.map { Lane(indications: $0) } for i in usableApproachLanes { lanes![i].isValid = true + if lanes![i].indications.contains(usableLaneIndication){ + lanes![i].validIndication = usableLaneIndication + } + } + for j in preferredApproachLanes { + lanes![j].isActive = true } } try container.encodeIfPresent(lanes, forKey: .lanes) @@ -292,10 +318,16 @@ extension Intersection: Codable { if let lanes = try container.decodeIfPresent([Lane].self, forKey: .lanes) { approachLanes = lanes.map { $0.indications } usableApproachLanes = lanes.indices { $0.isValid } + preferredApproachLanes = lanes.indices { ($0.isActive ?? false) } + let usableIndications = lanes.compactMap { $0.validIndication } + usableLaneIndication = usableIndications.reduce(LaneIndication(rawValue: 0)) { $0.union($1) } } else { approachLanes = nil usableApproachLanes = nil + preferredApproachLanes = nil + usableLaneIndication = nil } + outletRoadClasses = try container.decodeIfPresent(RoadClasses.self, forKey: .outletRoadClasses) let outletsArray = try container.decode([Bool].self, forKey: .outletIndexes) @@ -325,6 +357,11 @@ extension Intersection: Equatable { lhs.outletIndex == rhs.outletIndex && lhs.approachLanes == rhs.approachLanes && lhs.usableApproachLanes == rhs.usableApproachLanes && + lhs.preferredApproachLanes == rhs.preferredApproachLanes && + lhs.usableLaneIndication == rhs.usableLaneIndication && + lhs.restStop == rhs.restStop && + lhs.regionCode == rhs.regionCode && + lhs.outletMapboxStreetsRoadClass == rhs.outletMapboxStreetsRoadClass && lhs.outletRoadClasses == rhs.outletRoadClasses && lhs.tollCollection == rhs.tollCollection && lhs.tunnelName == rhs.tunnelName && diff --git a/Sources/MapboxDirections/Lane.swift b/Sources/MapboxDirections/Lane.swift index 990e89c6e..8a5964266 100644 --- a/Sources/MapboxDirections/Lane.swift +++ b/Sources/MapboxDirections/Lane.swift @@ -9,11 +9,27 @@ struct Lane: Equatable { */ let indications: LaneIndication + /** + Whether the lane can be taken to complete the maneuver (`true`) or not (`false`) + */ var isValid: Bool - init(indications: LaneIndication, valid: Bool = false) { + /** + Whether the lane is a preferred lane (`true`) or not (`false`) + A preferred lane is a lane that is recommended if there are multiple lanes available + */ + var isActive: Bool? + + /** + Which of the `indications` is applicable to the current route, when there is more than one + */ + var validIndication: LaneIndication? + + init(indications: LaneIndication, valid: Bool = false, active: Bool? = false, preferred: LaneIndication? = nil) { self.indications = indications self.isValid = valid + self.isActive = active + self.validIndication = preferred } } @@ -21,17 +37,25 @@ extension Lane: Codable { private enum CodingKeys: String, CodingKey { case indications case valid + case active + case preferred = "valid_indication" } func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(indications, forKey: .indications) try container.encode(isValid, forKey: .valid) + try container.encodeIfPresent(isActive, forKey: .active) + try container.encodeIfPresent(validIndication?.descriptions.first, forKey: .preferred) } init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) indications = try container.decode(LaneIndication.self, forKey: .indications) isValid = try container.decode(Bool.self, forKey: .valid) + isActive = try container.decodeIfPresent(Bool.self, forKey: .active) + if let validIndicationDescription = try container.decodeIfPresent(String.self, forKey: .preferred) { + validIndication = LaneIndication(descriptions: [validIndicationDescription]) + } } } diff --git a/Sources/MapboxDirections/VisualInstructionComponent.swift b/Sources/MapboxDirections/VisualInstructionComponent.swift index 010046ec8..c66c99ffc 100644 --- a/Sources/MapboxDirections/VisualInstructionComponent.swift +++ b/Sources/MapboxDirections/VisualInstructionComponent.swift @@ -72,8 +72,9 @@ public extension VisualInstruction { - parameter indications: The direction or directions of travel that the lane is reserved for. - parameter isUsable: Whether the user can use this lane to continue along the current route. + - parameter preferredDirection: Which of the `indications` is applicable to the current route when there is more than one */ - case lane(indications: LaneIndication, isUsable: Bool) + case lane(indications: LaneIndication, isUsable: Bool, preferredDirection: LaneIndication?) } } @@ -196,6 +197,7 @@ extension VisualInstruction.Component: Codable { case imageURL case directions case isActive = "active" + case activeDirection = "active_direction" } enum Kind: String, Codable { @@ -215,7 +217,8 @@ extension VisualInstruction.Component: Codable { if kind == .lane { let indications = try container.decode(LaneIndication.self, forKey: .directions) let isUsable = try container.decode(Bool.self, forKey: .isActive) - self = .lane(indications: indications, isUsable: isUsable) + let preferredDirection = try container.decodeIfPresent(LaneIndication.self, forKey: .activeDirection) + self = .lane(indications: indications, isUsable: isUsable, preferredDirection: preferredDirection) return } @@ -273,11 +276,12 @@ extension VisualInstruction.Component: Codable { case .exitCode(let text): try container.encode(Kind.exitCode, forKey: .kind) textRepresentation = text - case .lane(let indications, let isUsable): + case .lane(let indications, let isUsable, let preferredDirection): try container.encode(Kind.lane, forKey: .kind) textRepresentation = .init(text: "", abbreviation: nil, abbreviationPriority: nil) try container.encode(indications, forKey: .directions) try container.encode(isUsable, forKey: .isActive) + try container.encodeIfPresent(preferredDirection, forKey: .activeDirection) case .guidanceView(let image, let alternativeText): try container.encode(Kind.guidanceView, forKey: .kind) textRepresentation = alternativeText @@ -308,10 +312,11 @@ extension VisualInstruction.Component: Equatable { let .guidanceView(rhsURL, rhsAlternativeText)): return lhsURL == rhsURL && lhsAlternativeText == rhsAlternativeText - case (let .lane(lhsIndications, lhsIsUsable), - let .lane(rhsIndications, rhsIsUsable)): + case (let .lane(lhsIndications, lhsIsUsable, lhsPreferredDirection), + let .lane(rhsIndications, rhsIsUsable, rhsPreferredDirection)): return lhsIndications == rhsIndications && lhsIsUsable == rhsIsUsable + && lhsPreferredDirection == rhsPreferredDirection case (.delimiter, _), (.text, _), (.image, _), diff --git a/Tests/MapboxDirectionsTests/IntersectionTests.swift b/Tests/MapboxDirectionsTests/IntersectionTests.swift index 043c146c4..81c46354c 100644 --- a/Tests/MapboxDirectionsTests/IntersectionTests.swift +++ b/Tests/MapboxDirectionsTests/IntersectionTests.swift @@ -28,10 +28,14 @@ class IntersectionTests: XCTestCase { "lanes": [ [ "valid": true, + "active": false, + "valid_indication": "straight", "indications": ["straight"], ], [ "valid": true, + "active": true, + "valid_indication": "straight", "indications": ["right", "straight"], ], ], @@ -62,6 +66,8 @@ class IntersectionTests: XCTestCase { outletIndexes: IndexSet([0]), approachLanes: nil, usableApproachLanes: nil, + preferredApproachLanes: nil, + usableLaneIndication: nil, outletRoadClasses: [.toll, .restricted], tollCollection: TollCollection(type: .booth), tunnelName: nil, @@ -75,6 +81,8 @@ class IntersectionTests: XCTestCase { outletIndexes: IndexSet([1, 2]), approachLanes: nil, usableApproachLanes: nil, + preferredApproachLanes: nil, + usableLaneIndication: nil, outletRoadClasses: nil, tollCollection: nil, tunnelName: nil, @@ -87,6 +95,8 @@ class IntersectionTests: XCTestCase { outletIndexes: IndexSet([0, 1]), approachLanes: [.straightAhead, [.straightAhead, .right]], usableApproachLanes: IndexSet([0, 1]), + preferredApproachLanes: IndexSet([1]), + usableLaneIndication: [.straightAhead], outletRoadClasses: nil, tollCollection: nil, tunnelName: nil, diff --git a/Tests/MapboxDirectionsTests/RouteStepTests.swift b/Tests/MapboxDirectionsTests/RouteStepTests.swift index fe727d93d..3a2a13c93 100644 --- a/Tests/MapboxDirectionsTests/RouteStepTests.swift +++ b/Tests/MapboxDirectionsTests/RouteStepTests.swift @@ -163,9 +163,22 @@ class RouteStepTests: XCTestCase { "entry": [false, true, true], "in": 0, "lanes": [ - ["valid": true, "indications": ["left"]], - ["valid": true, "indications": ["straight"]], - ["valid": false, "indications": ["right"]], + [ + "valid": true, + "active": true, + "valid_indication": "left", + "indications": ["left"] + ], + [ + "valid": false, + "active": false, + "indications": ["straight"] + ], + [ + "valid": false, + "active": false, + "indications": ["right"] + ], ], ], ], diff --git a/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift b/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift index f91f900c7..7d6a7e74d 100644 --- a/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift +++ b/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift @@ -69,21 +69,23 @@ class VisualInstructionComponentTests: XCTestCase { "type": "lane", "active": true, "directions": ["right", "straight"], + "active_direction": ["right"], ] let componentData = try! JSONSerialization.data(withJSONObject: componentJSON, options: []) var component: VisualInstruction.Component? XCTAssertNoThrow(component = try JSONDecoder().decode(VisualInstruction.Component.self, from: componentData)) XCTAssertNotNil(component) if let component = component { - if case let .lane(indications, isUsable) = component { + if case let .lane(indications, isUsable, preferredDirection) = component { XCTAssertEqual(indications, [.straightAhead, .right]) XCTAssertTrue(isUsable) + XCTAssertEqual(preferredDirection, .right) } else { XCTFail("Lane component should not be decoded as any other kind of component.") } } - component = .lane(indications: [.straightAhead, .right], isUsable: true) + component = .lane(indications: [.straightAhead, .right], isUsable: true, preferredDirection: .right) let encoder = JSONEncoder() var encodedData: Data? XCTAssertNoThrow(encodedData = try encoder.encode(component)) diff --git a/Tests/MapboxDirectionsTests/VisualInstructionTests.swift b/Tests/MapboxDirectionsTests/VisualInstructionTests.swift index e61cc440a..41e89c52e 100644 --- a/Tests/MapboxDirectionsTests/VisualInstructionTests.swift +++ b/Tests/MapboxDirectionsTests/VisualInstructionTests.swift @@ -259,13 +259,15 @@ class VisualInstructionsTests: XCTestCase { XCTAssertEqual(laneIndicationComponents?.count, 2) if let laneIndicationComponents = laneIndicationComponents, laneIndicationComponents.count > 1 { - if case let VisualInstruction.Component.lane(indications, isUsable) = laneIndicationComponents[0] { + if case let VisualInstruction.Component.lane(indications, isUsable, preferredDirection) = laneIndicationComponents[0] { XCTAssertEqual(indications, .straightAhead) XCTAssertFalse(isUsable) + XCTAssertEqual(preferredDirection, nil) } - if case let VisualInstruction.Component.lane(indications, isUsable) = laneIndicationComponents[1] { + if case let VisualInstruction.Component.lane(indications, isUsable, preferredDirection) = laneIndicationComponents[1] { XCTAssertEqual(indications, .right) XCTAssertTrue(isUsable) + XCTAssertEqual(preferredDirection, nil) } } } From c6ea95e8e0a95045c9d3fa62e3caa45e04259cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 2 Apr 2021 16:15:40 -0700 Subject: [PATCH 13/41] Consolidated v2.0.0 section in changelog --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e78f7fb..320faabea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,10 @@ # Changes to Mapbox Directions for Swift -## main +## v2.0.0 * To gain access to the Mapbox Directions and Map Matching APIs, set `MBXAccessToken` in your Info.plist. `MGLMapboxAccessToken` is still supported but is now deprecated. ([#522](https://github.com/mapbox/mapbox-directions-swift/pull/522)) * This library requires Turf v2.0.0-alpha.3. ([#525](https://github.com/mapbox/mapbox-directions-swift/pull/525)) * The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) - -## v2.0.0 * Added the `Intersection.preferredApproachLanes` and `Intersection.usableLaneIndication` properties that indicate preferred lane usage. `VisualInstruction.Component.lane(indications:isUsable:)` has been renamed to `VisualInstruction.Component.lane(indications:isUsable:preferredDirection:)`. ([#529](https://github.com/mapbox/mapbox-directions-swift/pull/529)) * Comparing two `Intersection`s with `==` now considers whether the `Intersection.restStop`, `Intersection.regionCode`, and `Intersection.outletMapboxStreetsRoadClass` properties are equal. ([#529](https://github.com/mapbox/mapbox-directions-swift/pull/529)) From f41f32a63c55853d7a9970309ae8fa9e330116fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 2 Apr 2021 16:16:04 -0700 Subject: [PATCH 14/41] v2.0.0-beta.1 --- Directions Example/Info.plist | 2 +- MapboxDirections.podspec | 2 +- MapboxDirections.xcodeproj/project.pbxproj | 32 +++++++++++----------- README.md | 8 +++--- Sources/MapboxDirections/Info.plist | 2 +- Tests/MapboxDirectionsTests/Info.plist | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist index 86ffa4730..f14890012 100644 --- a/Directions Example/Info.plist +++ b/Directions Example/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 63 + 64 LSRequiresIPhoneOS NSLocationWhenInUseUsageDescription diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index e382619c5..e9d5f4ebc 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # s.name = "MapboxDirections" - s.version = "2.0.0-alpha.2" + s.version = "2.0.0-beta.1" s.summary = "Mapbox Directions API wrapper for Swift." s.description = <<-DESC diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index d5225a7e1..d429ea613 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -1858,11 +1858,11 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1887,10 +1887,10 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1956,11 +1956,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1985,10 +1985,10 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2056,11 +2056,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2086,10 +2086,10 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2114,12 +2114,12 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2142,11 +2142,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 64; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 63; + DYLIB_CURRENT_VERSION = 64; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/README.md b/README.md index a27c86cc4..2f6ba228a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Specify the following dependency in your [Carthage](https://github.com/Carthage/ # Latest stable release github "mapbox/mapbox-directions-swift" ~> 1.2 # Latest prerelease -github "mapbox/mapbox-directions-swift" "v2.0.0-alpha.2" +github "mapbox/mapbox-directions-swift" "v2.0.0-beta.1" ``` Or in your [CocoaPods](http://cocoapods.org/) Podfile: @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections-pre', '2.0.0-alpha.2' +pod 'MapboxDirections-pre', '2.0.0-beta.1' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: @@ -36,7 +36,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s // Latest stable release .package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") // Latest prerelease -.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-alpha.2") +.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.1") ``` Then `import MapboxDirections`. @@ -223,4 +223,4 @@ To build `MapboxDirectionsCLI` using SPM: ## Pricing -API calls made to the Directions API are individually billed by request. Review the [pricing information](https://docs.mapbox.com/api/navigation/directions/#directions-api-pricing) and the [pricing page](https://www.mapbox.com/pricing/#directions) for current rates. \ No newline at end of file +API calls made to the Directions API are individually billed by request. Review the [pricing information](https://docs.mapbox.com/api/navigation/directions/#directions-api-pricing) and the [pricing page](https://www.mapbox.com/pricing/#directions) for current rates. diff --git a/Sources/MapboxDirections/Info.plist b/Sources/MapboxDirections/Info.plist index 90b7a4b6a..73896f57f 100644 --- a/Sources/MapboxDirections/Info.plist +++ b/Sources/MapboxDirections/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 63 + 64 NSHumanReadableCopyright Copyright © 2014–2020 Mapbox. All rights reserved. NSPrincipalClass diff --git a/Tests/MapboxDirectionsTests/Info.plist b/Tests/MapboxDirectionsTests/Info.plist index 91d7e453d..2e4974ee8 100644 --- a/Tests/MapboxDirectionsTests/Info.plist +++ b/Tests/MapboxDirectionsTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 63 + 64 From c9411cd51c8025646187a3461c5a9cc21c98c22e Mon Sep 17 00:00:00 2001 From: jill-cardamon <43434254+jill-cardamon@users.noreply.github.com> Date: Wed, 7 Apr 2021 10:17:43 -0400 Subject: [PATCH 15/41] Fix VisualInstruction.component.lane type mismatch (#532) * add string conversion to VisualInstruction.component.lane preferredDirection property, update relevant tests --- Sources/MapboxDirections/VisualInstructionComponent.swift | 7 +++++-- .../VisualInstructionComponentTests.swift | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/MapboxDirections/VisualInstructionComponent.swift b/Sources/MapboxDirections/VisualInstructionComponent.swift index c66c99ffc..d7e75ac09 100644 --- a/Sources/MapboxDirections/VisualInstructionComponent.swift +++ b/Sources/MapboxDirections/VisualInstructionComponent.swift @@ -217,7 +217,10 @@ extension VisualInstruction.Component: Codable { if kind == .lane { let indications = try container.decode(LaneIndication.self, forKey: .directions) let isUsable = try container.decode(Bool.self, forKey: .isActive) - let preferredDirection = try container.decodeIfPresent(LaneIndication.self, forKey: .activeDirection) + var preferredDirection: LaneIndication? = nil + if let preferredDirectionDescription = try container.decodeIfPresent(String.self, forKey: .activeDirection) { + preferredDirection = LaneIndication(descriptions: [preferredDirectionDescription]) + } self = .lane(indications: indications, isUsable: isUsable, preferredDirection: preferredDirection) return } @@ -281,7 +284,7 @@ extension VisualInstruction.Component: Codable { textRepresentation = .init(text: "", abbreviation: nil, abbreviationPriority: nil) try container.encode(indications, forKey: .directions) try container.encode(isUsable, forKey: .isActive) - try container.encodeIfPresent(preferredDirection, forKey: .activeDirection) + try container.encodeIfPresent(preferredDirection?.descriptions.first, forKey: .activeDirection) case .guidanceView(let image, let alternativeText): try container.encode(Kind.guidanceView, forKey: .kind) textRepresentation = alternativeText diff --git a/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift b/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift index 7d6a7e74d..9ab7167dd 100644 --- a/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift +++ b/Tests/MapboxDirectionsTests/VisualInstructionComponentTests.swift @@ -69,7 +69,7 @@ class VisualInstructionComponentTests: XCTestCase { "type": "lane", "active": true, "directions": ["right", "straight"], - "active_direction": ["right"], + "active_direction": "right", ] let componentData = try! JSONSerialization.data(withJSONObject: componentJSON, options: []) var component: VisualInstruction.Component? From 399d28ca1c7306a0188d4368bf4b86af2ab9e8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 9 Apr 2021 15:58:54 -0700 Subject: [PATCH 16/41] v2.0.0-beta.2 --- Directions Example/Info.plist | 2 +- MapboxDirections.podspec | 2 +- MapboxDirections.xcodeproj/project.pbxproj | 32 +++++++++++----------- README.md | 6 ++-- Sources/MapboxDirections/Info.plist | 2 +- Tests/MapboxDirectionsTests/Info.plist | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist index f14890012..6b56b39f4 100644 --- a/Directions Example/Info.plist +++ b/Directions Example/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 64 + 65 LSRequiresIPhoneOS NSLocationWhenInUseUsageDescription diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index e9d5f4ebc..5dba4a557 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # s.name = "MapboxDirections" - s.version = "2.0.0-beta.1" + s.version = "2.0.0-beta.2" s.summary = "Mapbox Directions API wrapper for Swift." s.description = <<-DESC diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index d429ea613..bed8a8c14 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -1858,11 +1858,11 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1887,10 +1887,10 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1956,11 +1956,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1985,10 +1985,10 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2056,11 +2056,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2086,10 +2086,10 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2114,12 +2114,12 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2142,11 +2142,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 64; + CURRENT_PROJECT_VERSION = 65; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 64; + DYLIB_CURRENT_VERSION = 65; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/README.md b/README.md index 2f6ba228a..73725064e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Specify the following dependency in your [Carthage](https://github.com/Carthage/ # Latest stable release github "mapbox/mapbox-directions-swift" ~> 1.2 # Latest prerelease -github "mapbox/mapbox-directions-swift" "v2.0.0-beta.1" +github "mapbox/mapbox-directions-swift" "v2.0.0-beta.2" ``` Or in your [CocoaPods](http://cocoapods.org/) Podfile: @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections-pre', '2.0.0-beta.1' +pod 'MapboxDirections-pre', '2.0.0-beta.2' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: @@ -36,7 +36,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s // Latest stable release .package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") // Latest prerelease -.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.1") +.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.2") ``` Then `import MapboxDirections`. diff --git a/Sources/MapboxDirections/Info.plist b/Sources/MapboxDirections/Info.plist index 73896f57f..379849fca 100644 --- a/Sources/MapboxDirections/Info.plist +++ b/Sources/MapboxDirections/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 64 + 65 NSHumanReadableCopyright Copyright © 2014–2020 Mapbox. All rights reserved. NSPrincipalClass diff --git a/Tests/MapboxDirectionsTests/Info.plist b/Tests/MapboxDirectionsTests/Info.plist index 2e4974ee8..f0a6bf0f0 100644 --- a/Tests/MapboxDirectionsTests/Info.plist +++ b/Tests/MapboxDirectionsTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 64 + 65 From ca5148c68ceb5330296f4353bd458aad0cf3ae6d Mon Sep 17 00:00:00 2001 From: jill-cardamon <43434254+jill-cardamon@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:16:12 -0400 Subject: [PATCH 17/41] Preferred lane direction is now a ManeuverDirection (#535) * preferred lane direction is now of type ManeuverDirection, tests updated accordingly --- Sources/MapboxDirections/Intersection.swift | 21 ++++++++++++------- Sources/MapboxDirections/Lane.swift | 10 ++++----- Sources/MapboxDirections/LaneIndication.swift | 5 +++++ .../VisualInstructionComponent.swift | 9 +++----- .../IntersectionTests.swift | 2 +- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Sources/MapboxDirections/Intersection.swift b/Sources/MapboxDirections/Intersection.swift index a618f3a72..291190e3e 100644 --- a/Sources/MapboxDirections/Intersection.swift +++ b/Sources/MapboxDirections/Intersection.swift @@ -15,7 +15,7 @@ public struct Intersection { approachLanes: [LaneIndication]?, usableApproachLanes: IndexSet?, preferredApproachLanes: IndexSet?, - usableLaneIndication: LaneIndication?, + usableLaneIndication: ManeuverDirection?, outletRoadClasses: RoadClasses? = nil, tollCollection: TollCollection? = nil, tunnelName: String? = nil, @@ -165,7 +165,7 @@ public struct Intersection { If no lane information is available for the intersection, this property’s value is `nil` */ - public let usableLaneIndication: LaneIndication? + public let usableLaneIndication: ManeuverDirection? } extension Intersection: Codable { @@ -260,15 +260,16 @@ extension Intersection: Codable { try container.encode(outletArray, forKey: .outletIndexes) var lanes: [Lane]? + print("lanes: \(String(describing: lanes))") if let approachLanes = approachLanes, let usableApproachLanes = usableApproachLanes, - let preferredApproachLanes = preferredApproachLanes, - let usableLaneIndication = usableLaneIndication { + let preferredApproachLanes = preferredApproachLanes + { lanes = approachLanes.map { Lane(indications: $0) } for i in usableApproachLanes { lanes![i].isValid = true - if lanes![i].indications.contains(usableLaneIndication){ - lanes![i].validIndication = usableLaneIndication + if usableLaneIndication != nil && lanes![i].indications.descriptions.contains(usableLaneIndication!.rawValue) { + lanes![i].validIndication = usableLaneIndication } } for j in preferredApproachLanes { @@ -319,8 +320,12 @@ extension Intersection: Codable { approachLanes = lanes.map { $0.indications } usableApproachLanes = lanes.indices { $0.isValid } preferredApproachLanes = lanes.indices { ($0.isActive ?? false) } - let usableIndications = lanes.compactMap { $0.validIndication } - usableLaneIndication = usableIndications.reduce(LaneIndication(rawValue: 0)) { $0.union($1) } + let validIndications = lanes.compactMap { $0.validIndication} + if Set(validIndications).count > 1 { + let context = EncodingError.Context(codingPath: decoder.codingPath, debugDescription: "Inconsistent valid indications.") + throw EncodingError.invalidValue(validIndications, context) + } + usableLaneIndication = validIndications.first } else { approachLanes = nil usableApproachLanes = nil diff --git a/Sources/MapboxDirections/Lane.swift b/Sources/MapboxDirections/Lane.swift index 8a5964266..8549a45cb 100644 --- a/Sources/MapboxDirections/Lane.swift +++ b/Sources/MapboxDirections/Lane.swift @@ -23,9 +23,9 @@ struct Lane: Equatable { /** Which of the `indications` is applicable to the current route, when there is more than one */ - var validIndication: LaneIndication? + var validIndication: ManeuverDirection? - init(indications: LaneIndication, valid: Bool = false, active: Bool? = false, preferred: LaneIndication? = nil) { + init(indications: LaneIndication, valid: Bool = false, active: Bool? = false, preferred: ManeuverDirection? = nil) { self.indications = indications self.isValid = valid self.isActive = active @@ -46,7 +46,7 @@ extension Lane: Codable { try container.encode(indications, forKey: .indications) try container.encode(isValid, forKey: .valid) try container.encodeIfPresent(isActive, forKey: .active) - try container.encodeIfPresent(validIndication?.descriptions.first, forKey: .preferred) + try container.encodeIfPresent(validIndication, forKey: .preferred) } init(from decoder: Decoder) throws { @@ -54,8 +54,6 @@ extension Lane: Codable { indications = try container.decode(LaneIndication.self, forKey: .indications) isValid = try container.decode(Bool.self, forKey: .valid) isActive = try container.decodeIfPresent(Bool.self, forKey: .active) - if let validIndicationDescription = try container.decodeIfPresent(String.self, forKey: .preferred) { - validIndication = LaneIndication(descriptions: [validIndicationDescription]) - } + validIndication = try container.decodeIfPresent(ManeuverDirection.self, forKey: .preferred) } } diff --git a/Sources/MapboxDirections/LaneIndication.swift b/Sources/MapboxDirections/LaneIndication.swift index fc6d216c7..57ecfb887 100644 --- a/Sources/MapboxDirections/LaneIndication.swift +++ b/Sources/MapboxDirections/LaneIndication.swift @@ -69,6 +69,11 @@ public struct LaneIndication: OptionSet, CustomStringConvertible { self.init(rawValue: laneIndication.rawValue) } + init?(from direction: ManeuverDirection) { + // Assuming that every possible raw value of ManeuverDirection matches valid raw value of LaneIndication + self.init(descriptions: [direction.rawValue]) + } + public var descriptions: [String] { if isEmpty { return [] diff --git a/Sources/MapboxDirections/VisualInstructionComponent.swift b/Sources/MapboxDirections/VisualInstructionComponent.swift index d7e75ac09..b2c446721 100644 --- a/Sources/MapboxDirections/VisualInstructionComponent.swift +++ b/Sources/MapboxDirections/VisualInstructionComponent.swift @@ -74,7 +74,7 @@ public extension VisualInstruction { - parameter isUsable: Whether the user can use this lane to continue along the current route. - parameter preferredDirection: Which of the `indications` is applicable to the current route when there is more than one */ - case lane(indications: LaneIndication, isUsable: Bool, preferredDirection: LaneIndication?) + case lane(indications: LaneIndication, isUsable: Bool, preferredDirection: ManeuverDirection?) } } @@ -217,10 +217,7 @@ extension VisualInstruction.Component: Codable { if kind == .lane { let indications = try container.decode(LaneIndication.self, forKey: .directions) let isUsable = try container.decode(Bool.self, forKey: .isActive) - var preferredDirection: LaneIndication? = nil - if let preferredDirectionDescription = try container.decodeIfPresent(String.self, forKey: .activeDirection) { - preferredDirection = LaneIndication(descriptions: [preferredDirectionDescription]) - } + let preferredDirection = try container.decodeIfPresent(ManeuverDirection.self, forKey: .activeDirection) self = .lane(indications: indications, isUsable: isUsable, preferredDirection: preferredDirection) return } @@ -284,7 +281,7 @@ extension VisualInstruction.Component: Codable { textRepresentation = .init(text: "", abbreviation: nil, abbreviationPriority: nil) try container.encode(indications, forKey: .directions) try container.encode(isUsable, forKey: .isActive) - try container.encodeIfPresent(preferredDirection?.descriptions.first, forKey: .activeDirection) + try container.encodeIfPresent(preferredDirection, forKey: .activeDirection) case .guidanceView(let image, let alternativeText): try container.encode(Kind.guidanceView, forKey: .kind) textRepresentation = alternativeText diff --git a/Tests/MapboxDirectionsTests/IntersectionTests.swift b/Tests/MapboxDirectionsTests/IntersectionTests.swift index 81c46354c..baa095daa 100644 --- a/Tests/MapboxDirectionsTests/IntersectionTests.swift +++ b/Tests/MapboxDirectionsTests/IntersectionTests.swift @@ -96,7 +96,7 @@ class IntersectionTests: XCTestCase { approachLanes: [.straightAhead, [.straightAhead, .right]], usableApproachLanes: IndexSet([0, 1]), preferredApproachLanes: IndexSet([1]), - usableLaneIndication: [.straightAhead], + usableLaneIndication: .straightAhead, outletRoadClasses: nil, tollCollection: nil, tunnelName: nil, From c2bfe34699721f1fbdb2a31fb62f00b036ffb248 Mon Sep 17 00:00:00 2001 From: jill-cardamon <43434254+jill-cardamon@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:48:27 -0400 Subject: [PATCH 18/41] v2.0.0-beta.3 (#536) --- Directions Example/Info.plist | 2 +- MapboxDirections.podspec | 2 +- MapboxDirections.xcodeproj/project.pbxproj | 32 +++++++++++----------- README.md | 6 ++-- Sources/MapboxDirections/Info.plist | 2 +- Tests/MapboxDirectionsTests/Info.plist | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist index 6b56b39f4..963dacfb7 100644 --- a/Directions Example/Info.plist +++ b/Directions Example/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 65 + 66 LSRequiresIPhoneOS NSLocationWhenInUseUsageDescription diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 5dba4a557..2d4888cd2 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # s.name = "MapboxDirections" - s.version = "2.0.0-beta.2" + s.version = "2.0.0-beta.3" s.summary = "Mapbox Directions API wrapper for Swift." s.description = <<-DESC diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index bed8a8c14..9e2b15179 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -1858,11 +1858,11 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1887,10 +1887,10 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1956,11 +1956,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1985,10 +1985,10 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2056,11 +2056,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2086,10 +2086,10 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2114,12 +2114,12 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2142,11 +2142,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 65; + DYLIB_CURRENT_VERSION = 66; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/README.md b/README.md index 73725064e..fdc1ae454 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Specify the following dependency in your [Carthage](https://github.com/Carthage/ # Latest stable release github "mapbox/mapbox-directions-swift" ~> 1.2 # Latest prerelease -github "mapbox/mapbox-directions-swift" "v2.0.0-beta.2" +github "mapbox/mapbox-directions-swift" "v2.0.0-beta.3" ``` Or in your [CocoaPods](http://cocoapods.org/) Podfile: @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections-pre', '2.0.0-beta.2' +pod 'MapboxDirections-pre', '2.0.0-beta.3' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: @@ -36,7 +36,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s // Latest stable release .package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") // Latest prerelease -.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.2") +.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.3") ``` Then `import MapboxDirections`. diff --git a/Sources/MapboxDirections/Info.plist b/Sources/MapboxDirections/Info.plist index 379849fca..7abe403bb 100644 --- a/Sources/MapboxDirections/Info.plist +++ b/Sources/MapboxDirections/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 65 + 66 NSHumanReadableCopyright Copyright © 2014–2020 Mapbox. All rights reserved. NSPrincipalClass diff --git a/Tests/MapboxDirectionsTests/Info.plist b/Tests/MapboxDirectionsTests/Info.plist index f0a6bf0f0..0f3ca22e8 100644 --- a/Tests/MapboxDirectionsTests/Info.plist +++ b/Tests/MapboxDirectionsTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 65 + 66 From 25fd495147916c3beaafaff621638e5061dd14c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 16 Apr 2021 09:46:51 -0700 Subject: [PATCH 19/41] Disabled codecov Cherry-picked from 2ffc5f0cf9cc5a912d6d2187de854931ed79ab7e. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c5a681dd..b3d554dc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -137,7 +137,7 @@ workflows: iOS: "13.1" tvOS: "13.0" watchOS: "6.0" - codecoverage: true + codecoverage: false - spm-job: name: "SPM_build" xcode: "12.0.0" From 5e3d3e2915f9ccc561da6dbebca6f33155f06f66 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 20 Apr 2021 15:57:44 -0700 Subject: [PATCH 20/41] Remove excessive logging from `Intersection` encoder. --- Cartfile.resolved | 2 +- Sources/MapboxDirections/Intersection.swift | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 83330e8c6..8af9a9f5c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,6 +1,6 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.9.0" github "AliSoftware/OHHTTPStubs" "9.1.0" github "Udumft/SwiftCLI" "da19d2a16cd5aa838d8fb7256e28c171bc67dd82" -github "mapbox/mapbox-events-ios" "v0.10.7" +github "mapbox/mapbox-events-ios" "v0.10.8" github "mapbox/turf-swift" "v2.0.0-alpha.3" github "raphaelmor/Polyline" "v5.0.2" diff --git a/Sources/MapboxDirections/Intersection.swift b/Sources/MapboxDirections/Intersection.swift index 291190e3e..371a4af94 100644 --- a/Sources/MapboxDirections/Intersection.swift +++ b/Sources/MapboxDirections/Intersection.swift @@ -260,20 +260,22 @@ extension Intersection: Codable { try container.encode(outletArray, forKey: .outletIndexes) var lanes: [Lane]? - print("lanes: \(String(describing: lanes))") if let approachLanes = approachLanes, let usableApproachLanes = usableApproachLanes, let preferredApproachLanes = preferredApproachLanes { lanes = approachLanes.map { Lane(indications: $0) } for i in usableApproachLanes { - lanes![i].isValid = true - if usableLaneIndication != nil && lanes![i].indications.descriptions.contains(usableLaneIndication!.rawValue) { - lanes![i].validIndication = usableLaneIndication + lanes?[i].isValid = true + if let usableLaneIndication = usableLaneIndication, + let validLanes = lanes, + validLanes[i].indications.descriptions.contains(usableLaneIndication.rawValue) { + lanes?[i].validIndication = usableLaneIndication } } + for j in preferredApproachLanes { - lanes![j].isActive = true + lanes?[j].isActive = true } } try container.encodeIfPresent(lanes, forKey: .lanes) From db8646a54eac3393a84c2ab6bcaa581ee9ee78e5 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 17 May 2021 17:42:06 +0300 Subject: [PATCH 21/41] Fix typo in Waypoint documentation --- Sources/MapboxDirections/Waypoint.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MapboxDirections/Waypoint.swift b/Sources/MapboxDirections/Waypoint.swift index 1833f2d80..5183808ce 100644 --- a/Sources/MapboxDirections/Waypoint.swift +++ b/Sources/MapboxDirections/Waypoint.swift @@ -83,7 +83,7 @@ public class Waypoint: Codable { /** Initializes a new waypoint object with the given `CLLocation` object and an optional heading value and name. - - note: This initializer is intended for `CLLocation` objects created using the `CLLocation(latitude:longitude:)` initializer. If you intend to use a `CLLocation` object obtained from a `CLLocationManager` object, consider increasing the `horizontalAccuracy` or set it to a negative value to avoid overfitting, since the `Waypoint` class’s `coordinateAccuracy` property represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway of inside a building. + - note: This initializer is intended for `CLLocation` objects created using the `CLLocation(latitude:longitude:)` initializer. If you intend to use a `CLLocation` object obtained from a `CLLocationManager` object, consider increasing the `horizontalAccuracy` or set it to a negative value to avoid overfitting, since the `Waypoint` class’s `coordinateAccuracy` property represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway or inside a building. - parameter location: A `CLLocation` object representing the waypoint’s location. This initializer respects the `CLLocation` class’s `coordinate` and `horizontalAccuracy` properties, converting them into the `coordinate` and `coordinateAccuracy` properties, respectively. - parameter heading: A `LocationDirection` value representing the direction from which the route must approach the waypoint in order to be considered viable. This value is stored in the `headingAccuracy` property. From 9d6097107ca8041ad6c40fbad73a45a0be8fb3ac Mon Sep 17 00:00:00 2001 From: Alexander Pristavko Date: Fri, 28 May 2021 12:14:07 +0300 Subject: [PATCH 22/41] v2.0.0-beta.4 --- Directions Example/Info.plist | 2 +- MapboxDirections.podspec | 2 +- MapboxDirections.xcodeproj/project.pbxproj | 32 +++++++++++----------- README.md | 6 ++-- Sources/MapboxDirections/Info.plist | 2 +- Tests/MapboxDirectionsTests/Info.plist | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist index 963dacfb7..02e2843f7 100644 --- a/Directions Example/Info.plist +++ b/Directions Example/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 66 + 67 LSRequiresIPhoneOS NSLocationWhenInUseUsageDescription diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 2d4888cd2..1ae666ad7 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # s.name = "MapboxDirections" - s.version = "2.0.0-beta.3" + s.version = "2.0.0-beta.4" s.summary = "Mapbox Directions API wrapper for Swift." s.description = <<-DESC diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index 9e2b15179..30d39bee5 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -1858,11 +1858,11 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1887,10 +1887,10 @@ CLANG_ANALYZER_NONNULL = YES; CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1956,11 +1956,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1985,10 +1985,10 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2056,11 +2056,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2086,10 +2086,10 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2114,12 +2114,12 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2142,11 +2142,11 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 66; + DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/README.md b/README.md index fdc1ae454..50724aa4e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Specify the following dependency in your [Carthage](https://github.com/Carthage/ # Latest stable release github "mapbox/mapbox-directions-swift" ~> 1.2 # Latest prerelease -github "mapbox/mapbox-directions-swift" "v2.0.0-beta.3" +github "mapbox/mapbox-directions-swift" "v2.0.0-beta.4" ``` Or in your [CocoaPods](http://cocoapods.org/) Podfile: @@ -27,7 +27,7 @@ Or in your [CocoaPods](http://cocoapods.org/) Podfile: # Latest stable release pod 'MapboxDirections', '~> 1.2' # Latest prerelease -pod 'MapboxDirections-pre', '2.0.0-beta.3' +pod 'MapboxDirections-pre', '2.0.0-beta.4' ``` Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.swift: @@ -36,7 +36,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s // Latest stable release .package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0") // Latest prerelease -.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.3") +.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.0.0-beta.4") ``` Then `import MapboxDirections`. diff --git a/Sources/MapboxDirections/Info.plist b/Sources/MapboxDirections/Info.plist index 7abe403bb..584568cc2 100644 --- a/Sources/MapboxDirections/Info.plist +++ b/Sources/MapboxDirections/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 66 + 67 NSHumanReadableCopyright Copyright © 2014–2020 Mapbox. All rights reserved. NSPrincipalClass diff --git a/Tests/MapboxDirectionsTests/Info.plist b/Tests/MapboxDirectionsTests/Info.plist index 0f3ca22e8..0d7ce776e 100644 --- a/Tests/MapboxDirectionsTests/Info.plist +++ b/Tests/MapboxDirectionsTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 66 + 67 From 852e80f1929988997a711be2ac065c70abcc746e Mon Sep 17 00:00:00 2001 From: Alexander Pristavko Date: Fri, 28 May 2021 12:16:24 +0300 Subject: [PATCH 23/41] Update Turf version --- Cartfile | 2 +- Cartfile.resolved | 2 +- MapboxDirections.podspec | 2 +- Package.resolved | 4 ++-- Package.swift | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cartfile b/Cartfile index a0efe614d..bac231d9c 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "raphaelmor/Polyline" ~> 5.0 -github "mapbox/turf-swift" "v2.0.0-alpha.3" +github "mapbox/turf-swift" "v2.0.0-beta.1" github "Udumft/SwiftCLI" "carthage-fix" diff --git a/Cartfile.resolved b/Cartfile.resolved index 8af9a9f5c..18cc60592 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -2,5 +2,5 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.9.0" github "AliSoftware/OHHTTPStubs" "9.1.0" github "Udumft/SwiftCLI" "da19d2a16cd5aa838d8fb7256e28c171bc67dd82" github "mapbox/mapbox-events-ios" "v0.10.8" -github "mapbox/turf-swift" "v2.0.0-alpha.3" +github "mapbox/turf-swift" "v2.0.0-beta.1" github "raphaelmor/Polyline" "v5.0.2" diff --git a/MapboxDirections.podspec b/MapboxDirections.podspec index 1ae666ad7..a31d5f903 100644 --- a/MapboxDirections.podspec +++ b/MapboxDirections.podspec @@ -46,6 +46,6 @@ Pod::Spec.new do |s| s.swift_version = "5.0" s.dependency "Polyline", "~> 5.0" - s.dependency "Turf", "~> 2.0.0-alpha.3" + s.dependency "Turf", "~> 2.0.0-beta.1" end diff --git a/Package.resolved b/Package.resolved index e482bca64..ed92122fd 100644 --- a/Package.resolved +++ b/Package.resolved @@ -33,8 +33,8 @@ "repositoryURL": "https://github.com/mapbox/turf-swift.git", "state": { "branch": null, - "revision": "23e72d4174eacd76cc6414f063b427d2dac81cfb", - "version": "2.0.0-alpha.3" + "revision": "e460a117d2ac6b7a79a68c83ed75cb9a8acaeb6c", + "version": "2.0.0-beta.1" } } ] diff --git a/Package.swift b/Package.swift index 72377310b..077f909b9 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/raphaelmor/Polyline.git", from: "5.0.2"), - .package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "2.0.0-alpha.3"), + .package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "2.0.0-beta.1"), .package(url: "https://github.com/jakeheis/SwiftCLI", from: "6.0.0"), .package(url: "https://github.com/AliSoftware/OHHTTPStubs", from: "9.1.0") ], From d569016fca7b6f2d509e12533a3e6429aab402de Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 13:09:14 +0300 Subject: [PATCH 24/41] Upgrade SPM version to 5.4 for Linux builds Fixes #539. SPM 5.4 has automatic test discovery support, so that we can remove manually generated files for running Linux tests. --- .circleci/config.yml | 2 +- Tests/LinuxMain.swift | 8 - .../XCTestManifests.swift | 241 ------------------ 3 files changed, 1 insertion(+), 250 deletions(-) delete mode 100644 Tests/LinuxMain.swift delete mode 100644 Tests/MapboxDirectionsTests/XCTestManifests.swift diff --git a/.circleci/config.yml b/.circleci/config.yml index b3d554dc5..a99429bc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,7 @@ commands: jobs: spm-linux-job: docker: - - image: swift:5.3 + - image: swift:5.4 steps: - checkout # Limiting number of parallel jobs to avoid build crash bug. diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index fc1094527..000000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,8 +0,0 @@ -import XCTest - -import MapboxDirectionsTests - -var tests = [XCTestCaseEntry]() -tests += MapboxDirectionsTests.__allTests() - -XCTMain(tests) diff --git a/Tests/MapboxDirectionsTests/XCTestManifests.swift b/Tests/MapboxDirectionsTests/XCTestManifests.swift deleted file mode 100644 index 2cdfdf6a2..000000000 --- a/Tests/MapboxDirectionsTests/XCTestManifests.swift +++ /dev/null @@ -1,241 +0,0 @@ -#if !canImport(ObjectiveC) -import XCTest - -extension CredentialsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__CredentialsTests = [ - ("testCredentialsCreation", testCredentialsCreation), - ] -} - -extension DirectionsCredentialsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__DirectionsCredentialsTests = [ - ("testCustomConfiguration", testCustomConfiguration), - ("testDefaultConfiguration", testDefaultConfiguration), - ] -} - -extension DirectionsErrorTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__DirectionsErrorTests = [ - ("testEquality", testEquality), - ("testFailureReasons", testFailureReasons), - ("testRecoverySuggestions", testRecoverySuggestions), - ] -} - -extension GeoJSONTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__GeoJSONTests = [ - ("testInitialization", testInitialization), - ("testZeroLengthWorkaround", testZeroLengthWorkaround), - ] -} - -extension IntersectionTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__IntersectionTests = [ - ("testCoding", testCoding), - ] -} - -extension MatchOptionsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MatchOptionsTests = [ - ("testCoding", testCoding), - ("testRouteOptionsConvertedFromMatchOptions", testRouteOptionsConvertedFromMatchOptions), - ("testWaypointSerialization", testWaypointSerialization), - ] -} - -extension MatchTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MatchTests = [ - ("testCoding", testCoding), - ] -} - -extension QuickLookTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__QuickLookTests = [ - ("testQuickLookURL", testQuickLookURL), - ] -} - -extension RoadTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RoadTests = [ - ("testDestinations", testDestinations), - ("testEmpty", testEmpty), - ("testExitCodes", testExitCodes), - ("testNamesCodes", testNamesCodes), - ("testRotaryNames", testRotaryNames), - ] -} - -extension RouteLegTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RouteLegTests = [ - ("testSegmentRanges", testSegmentRanges), - ] -} - -extension RouteOptionsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RouteOptionsTests = [ - ("testApproachesURLQueryParams", testApproachesURLQueryParams), - ("testCoding", testCoding), - ("testDecimalPrecision", testDecimalPrecision), - ("testMissingApproaches", testMissingApproaches), - ("testResponseWithDestinationName", testResponseWithDestinationName), - ("testResponseWithManuallySetDestinationName", testResponseWithManuallySetDestinationName), - ("testResponseWithoutDestinationName", testResponseWithoutDestinationName), - ("testWaypointSerialization", testWaypointSerialization), - ] -} - -extension RouteRefreshTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RouteRefreshTests = [ - ("testDecoding", testDecoding), - ("testEncoding", testEncoding), - ] -} - -extension RouteResponseTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RouteResponseTests = [ - ("testRouteResponseEncodingAndDecoding", testRouteResponseEncodingAndDecoding), - ] -} - -extension RouteStepTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RouteStepTests = [ - ("testCoding", testCoding), - ("testDecoding", testDecoding), - ("testEncodingPronunciations", testEncodingPronunciations), - ("testIncidentsCoding", testIncidentsCoding), - ("testRouteStepTypicalTravelTime", testRouteStepTypicalTravelTime), - ] -} - -extension RouteTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RouteTests = [ - ("testCoding", testCoding), - ("testNullVoiceLocaleRoundtrip", testNullVoiceLocaleRoundtrip), - ("testRouteTypicalTravelTime", testRouteTypicalTravelTime), - ] -} - -extension SpokenInstructionTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SpokenInstructionTests = [ - ("testCoding", testCoding), - ("testEquality", testEquality), - ] -} - -extension TransportTypeTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__TransportTypeTests = [ - ("testDecoding", testDecoding), - ] -} - -extension VisualInstructionComponentTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__VisualInstructionComponentTests = [ - ("testImageComponent", testImageComponent), - ("testLaneComponent", testLaneComponent), - ("testTextComponent", testTextComponent), - ("testUnrecognizedComponent", testUnrecognizedComponent), - ] -} - -extension WalkingOptionsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__WalkingOptionsTests = [ - ("testURLQueryParams", testURLQueryParams), - ] -} - -extension WaypointTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__WaypointTests = [ - ("testAccuracies", testAccuracies), - ("testCoding", testCoding), - ("testEquality", testEquality), - ("testHeading", testHeading), - ("testSeparatesLegs", testSeparatesLegs), - ("testTracepointEquality", testTracepointEquality), - ] -} - -public func __allTests() -> [XCTestCaseEntry] { - return [ - testCase(CredentialsTests.__allTests__CredentialsTests), - testCase(DirectionsCredentialsTests.__allTests__DirectionsCredentialsTests), - testCase(DirectionsErrorTests.__allTests__DirectionsErrorTests), - testCase(GeoJSONTests.__allTests__GeoJSONTests), - testCase(IntersectionTests.__allTests__IntersectionTests), - testCase(MatchOptionsTests.__allTests__MatchOptionsTests), - testCase(MatchTests.__allTests__MatchTests), - testCase(QuickLookTests.__allTests__QuickLookTests), - testCase(RoadTests.__allTests__RoadTests), - testCase(RouteLegTests.__allTests__RouteLegTests), - testCase(RouteOptionsTests.__allTests__RouteOptionsTests), - testCase(RouteRefreshTests.__allTests__RouteRefreshTests), - testCase(RouteResponseTests.__allTests__RouteResponseTests), - testCase(RouteStepTests.__allTests__RouteStepTests), - testCase(RouteTests.__allTests__RouteTests), - testCase(SpokenInstructionTests.__allTests__SpokenInstructionTests), - testCase(TransportTypeTests.__allTests__TransportTypeTests), - testCase(VisualInstructionComponentTests.__allTests__VisualInstructionComponentTests), - testCase(WalkingOptionsTests.__allTests__WalkingOptionsTests), - testCase(WaypointTests.__allTests__WaypointTests), - ] -} -#endif From 0a4e054392830165eaf3888e232f9b6f00fb1f8c Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 15:34:26 +0300 Subject: [PATCH 25/41] Update CONTRIBUTING.md removing unneeded step --- CONTRIBUTING.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fd62decd..d545ef067 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,12 +54,10 @@ To add any type, constant, or member to the package’s public interface: 1. Add a file to Tests/MapboxDirectionsTests/ 1. Add a file reference to the MapboxDirectionsTests group in MapboxDirections.xcodeproj. -1. Rerun `swift test --generate-linuxmain`, which updates [XCTestManifests.swift](./Tests/MapboxDirectionsTests/XCTestManifests.swift) for builds that use Swift Package Manager. ### Adding a test case 1. Add a `test*` method to one of the classes in one of the files in [Tests/MapboxDirectionsTests/](./Tests/MapboxDirectionsTests/). -1. Rerun `swift test --generate-linuxmain`, which updates [XCTestManifests.swift](./Tests/MapboxDirectionsTests/XCTestManifests.swift) for builds that use Swift Package Manager. ### Adding a test fixture From d9f5e9c27ccc39f3788d89afef7fb155b5c2dffe Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 16:18:52 +0300 Subject: [PATCH 26/41] Migrate to xcframeworks for Carthage based project In order to support M1 based development and remove the need for Carthage workaround we must migrate to XCFrameworks. --- MapboxDirections.xcodeproj/project.pbxproj | 316 +++++++++++---------- 1 file changed, 165 insertions(+), 151 deletions(-) diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index 30d39bee5..5c333f4fa 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -3,12 +3,10 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ - 2B1BB29D2541B4FA00A18CF1 /* MapboxDirections.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */; }; - 2B1BB29E2541B4FA00A18CF1 /* MapboxDirections.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 2B4383022549C22700A3E38B /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B4383002549C22700A3E38B /* main.swift */; }; 2B4383032549C22700A3E38B /* ProcessCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B4383012549C22700A3E38B /* ProcessCommand.swift */; }; 2B5407ED2451B17E006C820B /* RouteRefreshResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B5407EC2451B17E006C820B /* RouteRefreshResponse.swift */; }; @@ -35,12 +33,6 @@ 2B540809245B23BE006C820B /* incorrectRouteRefreshResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 2B540808245B23BE006C820B /* incorrectRouteRefreshResponse.json */; }; 2B54080A245B23BE006C820B /* incorrectRouteRefreshResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 2B540808245B23BE006C820B /* incorrectRouteRefreshResponse.json */; }; 2B54080B245B23BE006C820B /* incorrectRouteRefreshResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 2B540808245B23BE006C820B /* incorrectRouteRefreshResponse.json */; }; - 2B674D4A2541A9F10026CE4B /* SwiftCLI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BFD4D962540604000D0E14D /* SwiftCLI.framework */; }; - 2B674D4B2541A9F10026CE4B /* SwiftCLI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2BFD4D962540604000D0E14D /* SwiftCLI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 2B674DC12541AF2E0026CE4B /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83A1DDCC6EB000BC343 /* Polyline.framework */; }; - 2B674DC22541AF2E0026CE4B /* Polyline.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83A1DDCC6EB000BC343 /* Polyline.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 2B674DCB2541AF410026CE4B /* Turf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B674DCA2541AF410026CE4B /* Turf.framework */; }; - 2B674DCC2541AF410026CE4B /* Turf.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2B674DCA2541AF410026CE4B /* Turf.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 2BA2E746257A667500D7AFC6 /* incidents.json in Resources */ = {isa = PBXBuildFile; fileRef = 2BA2E745257A667500D7AFC6 /* incidents.json */; }; 2BA2E747257A667500D7AFC6 /* incidents.json in Resources */ = {isa = PBXBuildFile; fileRef = 2BA2E745257A667500D7AFC6 /* incidents.json */; }; 2BA2E748257A667500D7AFC6 /* incidents.json in Resources */ = {isa = PBXBuildFile; fileRef = 2BA2E745257A667500D7AFC6 /* incidents.json */; }; @@ -130,7 +122,6 @@ 43F89F952350F952007B591E /* MapMatchingResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F89F922350F952007B591E /* MapMatchingResponse.swift */; }; 43F89F962350F952007B591E /* MapMatchingResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F89F922350F952007B591E /* MapMatchingResponse.swift */; }; 8A3B4C9B24EB55F60085DA64 /* RouteResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3B4C9A24EB55F60085DA64 /* RouteResponseTests.swift */; }; - 8AF87EA5249AF671004AC2AB /* MapboxMobileEvents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8AF87EA4249AF671004AC2AB /* MapboxMobileEvents.framework */; }; 8D381B611FD9F5B1008D5A58 /* noDestinationName.json in Resources */ = {isa = PBXBuildFile; fileRef = 8D381B601FD9F5B1008D5A58 /* noDestinationName.json */; }; 8D381B631FDB01D1008D5A58 /* apiDestinationName.json in Resources */ = {isa = PBXBuildFile; fileRef = 8D381B621FDB01D1008D5A58 /* apiDestinationName.json */; }; 8D381B641FDB0898008D5A58 /* noDestinationName.json in Resources */ = {isa = PBXBuildFile; fileRef = 8D381B601FD9F5B1008D5A58 /* noDestinationName.json */; }; @@ -283,7 +274,6 @@ DA8F3A7223B56D3B00B56786 /* RouteLegTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F3A7123B56D3B00B56786 /* RouteLegTests.swift */; }; DA8F3A7323B56D3B00B56786 /* RouteLegTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F3A7123B56D3B00B56786 /* RouteLegTests.swift */; }; DA8F3A7423B56D3B00B56786 /* RouteLegTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F3A7123B56D3B00B56786 /* RouteLegTests.swift */; }; - DA9E1B131E5A675F0081EDC7 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA9E1B121E5A675F0081EDC7 /* Polyline.framework */; }; DAA76D681DD127CB0015EC78 /* LaneIndication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAA76D671DD127CB0015EC78 /* LaneIndication.swift */; }; DAA76D691DD127CB0015EC78 /* LaneIndication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAA76D671DD127CB0015EC78 /* LaneIndication.swift */; }; DAA76D6A1DD127CB0015EC78 /* LaneIndication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAA76D671DD127CB0015EC78 /* LaneIndication.swift */; }; @@ -337,14 +327,27 @@ DAE9E0F61EB7DE2E001E8E8B /* RouteOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE9E0F31EB7DE2E001E8E8B /* RouteOptionsTests.swift */; }; DAF08AAB25C0E96E00ABA8F3 /* MapboxDirections.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA6C9D881CAE442B00094FBC /* MapboxDirections.framework */; }; DAF08AAC25C0E96E00ABA8F3 /* MapboxDirections.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA6C9D881CAE442B00094FBC /* MapboxDirections.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - F448F8311DDCC65C000BC343 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F82A1DDCC5B6000BC343 /* Polyline.framework */; }; - F448F8341DDCC6C1000BC343 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F82A1DDCC5B6000BC343 /* Polyline.framework */; }; - F448F83D1DDCC6FA000BC343 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83A1DDCC6EB000BC343 /* Polyline.framework */; }; - F448F83E1DDCC6FF000BC343 /* OHHTTPStubs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F8391DDCC6EB000BC343 /* OHHTTPStubs.framework */; }; - F448F83F1DDCC701000BC343 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83A1DDCC6EB000BC343 /* Polyline.framework */; }; - F448F8401DDCC709000BC343 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83C1DDCC6F3000BC343 /* Polyline.framework */; }; - F448F8411DDCC70C000BC343 /* OHHTTPStubs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83B1DDCC6F3000BC343 /* OHHTTPStubs.framework */; }; - F448F8421DDCC70D000BC343 /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F448F83C1DDCC6F3000BC343 /* Polyline.framework */; }; + E232F8A8266513E90038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8A9266513EE0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8AA266513F10038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8AC266513FF0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8AD266513FF0038CAF3 /* Polyline.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + E232F8B2266516640038CAF3 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8AE2665141F0038CAF3 /* Turf.xcframework */; }; + E232F8B32665166D0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8B4266516950038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8B5266516950038CAF3 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8AE2665141F0038CAF3 /* Turf.xcframework */; }; + E232F8B6266516990038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8B7266516990038CAF3 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8AE2665141F0038CAF3 /* Turf.xcframework */; }; + E232F8B82665169C0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; + E232F8B92665169C0038CAF3 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8AE2665141F0038CAF3 /* Turf.xcframework */; }; + E232F8BB266516D70038CAF3 /* OHHTTPStubs.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8BA266516D70038CAF3 /* OHHTTPStubs.xcframework */; }; + E232F8BC266516EB0038CAF3 /* OHHTTPStubs.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8BA266516D70038CAF3 /* OHHTTPStubs.xcframework */; }; + E232F8BD266516EF0038CAF3 /* OHHTTPStubs.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8BA266516D70038CAF3 /* OHHTTPStubs.xcframework */; }; + E232F8C1266517140038CAF3 /* SwiftCLI.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8BF266517010038CAF3 /* SwiftCLI.xcframework */; }; + E232F8C3266517160038CAF3 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8AE2665141F0038CAF3 /* Turf.xcframework */; }; + E232F8C52665173C0038CAF3 /* MapboxDirections.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */; }; + E232F8C62665173C0038CAF3 /* MapboxDirections.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + E232F8C9266518480038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; F457FA7A252B9E29007DAEB1 /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = F457FA79252B9E29007DAEB1 /* Incident.swift */; }; F457FA7B252B9E29007DAEB1 /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = F457FA79252B9E29007DAEB1 /* Incident.swift */; }; F457FA7C252B9E29007DAEB1 /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = F457FA79252B9E29007DAEB1 /* Incident.swift */; }; @@ -374,13 +377,6 @@ remoteGlobalIDString = DA6C9D871CAE442B00094FBC; remoteInfo = MapboxDirections; }; - 2B1BB29F2541B4FA00A18CF1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = DD6254461AE70C1700017857 /* Project object */; - proxyType = 1; - remoteGlobalIDString = DA1A10AE1D00F8FF009F82FA; - remoteInfo = MapboxDirectionsMac; - }; DA1A10BA1D00F8FF009F82FA /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DD6254461AE70C1700017857 /* Project object */; @@ -409,6 +405,13 @@ remoteGlobalIDString = DA6C9D871CAE442B00094FBC; remoteInfo = MapboxDirections; }; + E232F8C72665173C0038CAF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DD6254461AE70C1700017857 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DA1A10AE1D00F8FF009F82FA; + remoteInfo = MapboxDirectionsMac; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -418,10 +421,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 2B674DC22541AF2E0026CE4B /* Polyline.framework in Embed Frameworks */, - 2B1BB29E2541B4FA00A18CF1 /* MapboxDirections.framework in Embed Frameworks */, - 2B674D4B2541A9F10026CE4B /* SwiftCLI.framework in Embed Frameworks */, - 2B674DCC2541AF410026CE4B /* Turf.framework in Embed Frameworks */, + E232F8C62665173C0038CAF3 /* MapboxDirections.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -442,6 +442,7 @@ dstSubfolderSpec = 10; files = ( DAF08AAC25C0E96E00ABA8F3 /* MapboxDirections.framework in Embed Frameworks */, + E232F8AD266513FF0038CAF3 /* Polyline.xcframework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -458,12 +459,10 @@ 2B5407FF245B097D006C820B /* routeRefreshResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = routeRefreshResponse.json; sourceTree = ""; }; 2B540804245B09E1006C820B /* routeRefreshRoute.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = routeRefreshRoute.json; sourceTree = ""; }; 2B540808245B23BE006C820B /* incorrectRouteRefreshResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = incorrectRouteRefreshResponse.json; sourceTree = ""; }; - 2B674DCA2541AF410026CE4B /* Turf.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Turf.framework; path = Carthage/Build/Mac/Turf.framework; sourceTree = ""; }; 2BA2E745257A667500D7AFC6 /* incidents.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = incidents.json; sourceTree = ""; }; 2BA98970253F007600B643F6 /* mapbox-directions-swift */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "mapbox-directions-swift"; sourceTree = BUILT_PRODUCTS_DIR; }; 2BBBD05D257E61ED004EB3D6 /* MapboxStreetsRoadClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxStreetsRoadClass.swift; sourceTree = ""; }; 2BBBD08C257FA1CD004EB3D6 /* BlockedLanes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedLanes.swift; sourceTree = ""; }; - 2BFD4D962540604000D0E14D /* SwiftCLI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftCLI.framework; path = Carthage/Build/Mac/SwiftCLI.framework; sourceTree = ""; }; 3556CE9922649CF2009397B5 /* MapboxDirectionsTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "MapboxDirectionsTests-Bridging-Header.h"; path = "../objc/MapboxDirectionsTests-Bridging-Header.h"; sourceTree = ""; }; 35828C9D217A003F00ED546E /* OfflineDirections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineDirections.swift; sourceTree = ""; }; 35CC310A2285739700EA1966 /* WalkingOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalkingOptionsTests.swift; sourceTree = ""; }; @@ -489,7 +488,6 @@ 43F89F922350F952007B591E /* MapMatchingResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapMatchingResponse.swift; sourceTree = ""; }; 8A3B4C9A24EB55F60085DA64 /* RouteResponseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouteResponseTests.swift; sourceTree = ""; }; 8A41B0FC24F5C2390021FFDC /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; - 8AF87EA4249AF671004AC2AB /* MapboxMobileEvents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapboxMobileEvents.framework; path = Carthage/Build/iOS/MapboxMobileEvents.framework; sourceTree = ""; }; 8D381B601FD9F5B1008D5A58 /* noDestinationName.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = noDestinationName.json; sourceTree = ""; }; 8D381B621FDB01D1008D5A58 /* apiDestinationName.json */ = {isa = PBXFileReference; explicitFileType = text.json; path = apiDestinationName.json; sourceTree = ""; }; 8D381B691FDB101F008D5A58 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; @@ -566,6 +564,10 @@ DAE7EA93230B5FD10003B211 /* Measurement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Measurement.swift; sourceTree = ""; }; DAE9E0F31EB7DE2E001E8E8B /* RouteOptionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RouteOptionsTests.swift; path = Tests/MapboxDirectionsTests/RouteOptionsTests.swift; sourceTree = SOURCE_ROOT; }; DD6254731AE70CB700017857 /* Directions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Directions.swift; sourceTree = ""; }; + E232F899266513C20038CAF3 /* Polyline.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Polyline.xcframework; path = Carthage/Build/Polyline.xcframework; sourceTree = ""; }; + E232F8AE2665141F0038CAF3 /* Turf.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Turf.xcframework; path = Carthage/Build/Turf.xcframework; sourceTree = ""; }; + E232F8BA266516D70038CAF3 /* OHHTTPStubs.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OHHTTPStubs.xcframework; path = Carthage/Build/OHHTTPStubs.xcframework; sourceTree = ""; }; + E232F8BF266517010038CAF3 /* SwiftCLI.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = SwiftCLI.xcframework; path = Carthage/Build/SwiftCLI.xcframework; sourceTree = ""; }; F448F82A1DDCC5B6000BC343 /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/iOS/Polyline.framework; sourceTree = ""; }; F448F8381DDCC6D7000BC343 /* OHHTTPStubs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OHHTTPStubs.framework; path = Carthage/Build/iOS/OHHTTPStubs.framework; sourceTree = ""; }; F448F8391DDCC6EB000BC343 /* OHHTTPStubs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OHHTTPStubs.framework; path = Carthage/Build/Mac/OHHTTPStubs.framework; sourceTree = ""; }; @@ -584,10 +586,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2B674DC12541AF2E0026CE4B /* Polyline.framework in Frameworks */, - 2B1BB29D2541B4FA00A18CF1 /* MapboxDirections.framework in Frameworks */, - 2B674D4A2541A9F10026CE4B /* SwiftCLI.framework in Frameworks */, - 2B674DCB2541AF410026CE4B /* Turf.framework in Frameworks */, + E232F8C3266517160038CAF3 /* Turf.xcframework in Frameworks */, + E232F8C52665173C0038CAF3 /* MapboxDirections.framework in Frameworks */, + E232F8C1266517140038CAF3 /* SwiftCLI.xcframework in Frameworks */, + E232F8C9266518480038CAF3 /* Polyline.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -595,8 +597,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F448F83E1DDCC6FF000BC343 /* OHHTTPStubs.framework in Frameworks */, - F448F83F1DDCC701000BC343 /* Polyline.framework in Frameworks */, + E232F8A9266513EE0038CAF3 /* Polyline.xcframework in Frameworks */, + E232F8BC266516EB0038CAF3 /* OHHTTPStubs.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -604,7 +606,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F448F8311DDCC65C000BC343 /* Polyline.framework in Frameworks */, + E232F8AA266513F10038CAF3 /* Polyline.xcframework in Frameworks */, + E232F8BB266516D70038CAF3 /* OHHTTPStubs.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -612,7 +615,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F448F83D1DDCC6FA000BC343 /* Polyline.framework in Frameworks */, + E232F8B2266516640038CAF3 /* Turf.xcframework in Frameworks */, + E232F8B32665166D0038CAF3 /* Polyline.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -620,7 +624,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F448F8341DDCC6C1000BC343 /* Polyline.framework in Frameworks */, + E232F8B4266516950038CAF3 /* Polyline.xcframework in Frameworks */, + E232F8B5266516950038CAF3 /* Turf.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -628,7 +633,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F448F8401DDCC709000BC343 /* Polyline.framework in Frameworks */, + E232F8B6266516990038CAF3 /* Polyline.xcframework in Frameworks */, + E232F8B7266516990038CAF3 /* Turf.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -636,8 +642,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F448F8411DDCC70C000BC343 /* OHHTTPStubs.framework in Frameworks */, - F448F8421DDCC70D000BC343 /* Polyline.framework in Frameworks */, + E232F8A8266513E90038CAF3 /* Polyline.xcframework in Frameworks */, + E232F8BD266516EF0038CAF3 /* OHHTTPStubs.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -646,8 +652,8 @@ buildActionMask = 2147483647; files = ( DAF08AAB25C0E96E00ABA8F3 /* MapboxDirections.framework in Frameworks */, - 8AF87EA5249AF671004AC2AB /* MapboxMobileEvents.framework in Frameworks */, DADD27F31E5ABD4300D31FAD /* Mapbox.framework in Frameworks */, + E232F8AC266513FF0038CAF3 /* Polyline.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -655,7 +661,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DA9E1B131E5A675F0081EDC7 /* Polyline.framework in Frameworks */, + E232F8B82665169C0038CAF3 /* Polyline.xcframework in Frameworks */, + E232F8B92665169C0038CAF3 /* Turf.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -746,9 +753,10 @@ C5AD8656202E24F400BF47D5 /* Frameworks */ = { isa = PBXGroup; children = ( - 2B674DCA2541AF410026CE4B /* Turf.framework */, - 2BFD4D962540604000D0E14D /* SwiftCLI.framework */, - 8AF87EA4249AF671004AC2AB /* MapboxMobileEvents.framework */, + E232F8BF266517010038CAF3 /* SwiftCLI.xcframework */, + E232F8BA266516D70038CAF3 /* OHHTTPStubs.xcframework */, + E232F8AE2665141F0038CAF3 /* Turf.xcframework */, + E232F899266513C20038CAF3 /* Polyline.xcframework */, ); name = Frameworks; sourceTree = ""; @@ -1026,7 +1034,7 @@ ); dependencies = ( 2B1BB2952541B4C200A18CF1 /* PBXTargetDependency */, - 2B1BB2A02541B4FA00A18CF1 /* PBXTargetDependency */, + E232F8C82665173C0038CAF3 /* PBXTargetDependency */, ); name = MapboxDirectionsCLI; productName = MapboxDirectionsCLI; @@ -1166,7 +1174,6 @@ DADD27B11E5AAAD800D31FAD /* Sources */, DADD27B21E5AAAD800D31FAD /* Frameworks */, DADD27B31E5AAAD800D31FAD /* Resources */, - DADD27F51E5ABD6600D31FAD /* Copy Frameworks */, DA3DFB08236973E9003AE57F /* Apply Mapbox Access Token */, DAF08AAD25C0E96E00ABA8F3 /* Embed Frameworks */, ); @@ -1232,7 +1239,7 @@ }; }; buildConfigurationList = DD6254491AE70C1700017857 /* Build configuration list for PBXProject "MapboxDirections" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 11.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -1392,24 +1399,6 @@ shellPath = /bin/sh; shellScript = "# Look for a global file named 'mapbox' or '.mapbox' within the home directory\ntoken_file=~/.mapbox\ntoken_file2=~/mapbox\ntoken=\"$(cat $token_file 2>/dev/null || cat $token_file2 2>/dev/null)\"\nif [ \"$token\" ]; then\n plutil -replace MGLMapboxAccessToken -string $token \"$TARGET_BUILD_DIR/$INFOPLIST_PATH\"\nelse\n echo 'warning: Missing Mapbox access token'\n open 'https://account.mapbox.com/access-tokens/'\n echo \"warning: Get an access token from , then create a new file at $token_file or $token_file2 that contains the access token.\"\nfi\n"; }; - DADD27F51E5ABD6600D31FAD /* Copy Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/Carthage/Build/iOS/Mapbox.framework", - "$(SRCROOT)/Carthage/Build/iOS/Polyline.framework", - "$(SRCROOT)/Carthage/Build/iOS/Turf.framework", - "$(SRCROOT)/Carthage/Build/iOS/MapboxMobileEvents.framework", - ); - name = "Copy Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/local/bin/carthage copy-frameworks\n"; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -1760,11 +1749,6 @@ target = DA6C9D871CAE442B00094FBC /* MapboxDirections */; targetProxy = 2B1BB2942541B4C200A18CF1 /* PBXContainerItemProxy */; }; - 2B1BB2A02541B4FA00A18CF1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = DA1A10AE1D00F8FF009F82FA /* MapboxDirectionsMac */; - targetProxy = 2B1BB29F2541B4FA00A18CF1 /* PBXContainerItemProxy */; - }; DA1A10BB1D00F8FF009F82FA /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = DA1A10AE1D00F8FF009F82FA /* MapboxDirectionsMac */; @@ -1785,6 +1769,11 @@ target = DA6C9D871CAE442B00094FBC /* MapboxDirections */; targetProxy = DADD27F91E5AC8E900D31FAD /* PBXContainerItemProxy */; }; + E232F8C82665173C0038CAF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DA1A10AE1D00F8FF009F82FA /* MapboxDirectionsMac */; + targetProxy = E232F8C72665173C0038CAF3 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -1805,12 +1794,13 @@ DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = NO; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + GCC_C_LANGUAGE_STANDARD = gnu11; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/Mac", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", ); - GCC_C_LANGUAGE_STANDARD = gnu11; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -1838,12 +1828,13 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = NO; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + GCC_C_LANGUAGE_STANDARD = gnu11; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/Mac", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", ); - GCC_C_LANGUAGE_STANDARD = gnu11; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_FAST_MATH = YES; PRODUCT_NAME = "mapbox-directions-swift"; @@ -1864,14 +1855,15 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/Mac", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = MapboxDirections; SDKROOT = macosx; @@ -1892,14 +1884,15 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/Mac", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = MapboxDirections; SDKROOT = macosx; @@ -1917,12 +1910,14 @@ CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = dwarf; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", "$(PROJECT_DIR)/Carthage/Build/Mac", ); - INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/Carthage/Build/Mac"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirectionsTests; PRODUCT_NAME = MapboxDirectionsTests; SDKROOT = macosx; @@ -1938,12 +1933,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", "$(PROJECT_DIR)/Carthage/Build/Mac", ); - INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/Carthage/Build/Mac"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirectionsTests; PRODUCT_NAME = MapboxDirectionsTests; SDKROOT = macosx; @@ -1962,13 +1959,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/tvOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = MapboxDirections; SDKROOT = appletvos; @@ -1990,13 +1988,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/tvOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = MapboxDirections; SDKROOT = appletvos; @@ -2014,12 +2013,14 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ENABLE_MODULES = YES; DEBUG_INFORMATION_FORMAT = dwarf; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); - INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Carthage/Build/tvOS"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirectionsTests; PRODUCT_NAME = MapboxDirectionsTests; SDKROOT = appletvos; @@ -2035,12 +2036,14 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ENABLE_MODULES = YES; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); - INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Carthage/Build/tvOS"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirectionsTests; PRODUCT_NAME = MapboxDirectionsTests; SDKROOT = appletvos; @@ -2062,13 +2065,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/watchOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = MapboxDirections; SDKROOT = watchos; @@ -2091,13 +2095,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/watchOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = MapboxDirections; SDKROOT = watchos; @@ -2121,13 +2126,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2148,13 +2154,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 67; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = Sources/MapboxDirections/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirections; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2170,12 +2177,14 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ENABLE_MODULES = YES; DEBUG_INFORMATION_FORMAT = dwarf; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", + "@executable_path/Frameworks", + "@loader_path/Frameworks", ); - INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(PROJECT_DIR)/Carthage/Build/iOS @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirectionsTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/objc/MapboxDirectionsTests-Bridging-Header.h"; @@ -2188,12 +2197,14 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ENABLE_MODULES = YES; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", + "@executable_path/Frameworks", + "@loader_path/Frameworks", ); - INFOPLIST_FILE = Tests/MapboxDirectionsTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(PROJECT_DIR)/Carthage/Build/iOS @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxDirectionsTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/objc/MapboxDirectionsTests-Bridging-Header.h"; @@ -2208,12 +2219,12 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = "Directions Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", + "@executable_path/Frameworks", ); - INFOPLIST_FILE = "Directions Example/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Directions; PRODUCT_MODULE_NAME = DirectionsExampleSwift; PRODUCT_NAME = Example; @@ -2229,12 +2240,12 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = "Directions Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", + "@executable_path/Frameworks", ); - INFOPLIST_FILE = "Directions Example/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Directions; PRODUCT_MODULE_NAME = DirectionsExampleSwift; PRODUCT_NAME = Example; @@ -2275,6 +2286,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -2336,6 +2348,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -2348,7 +2361,8 @@ MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 10.0; From 01950f2c66426774912f640a33c0b75a57c128e7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 16:23:27 +0300 Subject: [PATCH 27/41] Update CircleCI config to use XCFrameworks --- .circleci/config.yml | 7 ++----- README.md | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b3d554dc5..f04867d57 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ commands: - run: name: Install Carthage command: | - curl -OL "https://github.com/Carthage/Carthage/releases/download/0.34.0/Carthage.pkg" + curl -OL "https://github.com/Carthage/Carthage/releases/download/0.38.0/Carthage.pkg" sudo installer -pkg Carthage.pkg -target / publish-codecov: @@ -96,10 +96,7 @@ jobs: - run: name: Dependencies command: | - ./scripts/wcarthage.sh bootstrap --platform ios --cache-builds --configuration Debug --no-use-binaries - ./scripts/wcarthage.sh bootstrap --platform tvos --cache-builds --configuration Debug --no-use-binaries - ./scripts/wcarthage.sh bootstrap --platform macos --cache-builds --configuration Debug --no-use-binaries - ./scripts/wcarthage.sh bootstrap --platform watchos --cache-builds --configuration Debug --no-use-binaries + carthage bootstrap --platform all --cache-builds --configuration Debug --use-xcframeworks - run: name: iOS command: xcodebuild -sdk iphonesimulator -project MapboxDirections.xcodeproj -scheme 'MapboxDirections iOS' -destination 'platform=iOS Simulator,OS=<< parameters.iOS >>,name=<< parameters.device >>' clean build <<# parameters.test >>test<><<# parameters.codecoverage >> -enableCodeCoverage "YES"<> diff --git a/README.md b/README.md index 50724aa4e..bd6083e09 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ This repository contains an example application that demonstrates how to use the * One of the following package managers: * CocoaPods (CocoaPods 1.10 or above if using Xcode 12) - * Carthage 0.19 or above (run [this script](https://github.com/mapbox/mapbox-directions-swift/blob/main/scripts/wcarthage.sh) instead of `carthage` if using Xcode 12) + * Carthage 0.38 or above * Swift Package Manager 5.3 or above * Xcode 11 or above (Xcode 12 or above if using Swift Package Manager) * One of the following operating systems: From 7968ed0c5c4b783369d3ef291c70682621338a11 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 17:50:51 +0300 Subject: [PATCH 28/41] Add Carthage integration job It runs Carthage from the library user point of view and verifies that it can be built successfully. --- .circleci/config.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f04867d57..d542050ac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,6 +57,26 @@ jobs: steps: - checkout - run: swift build + + carthage-integration-test: + parameters: + xcode: + type: string + macos: + xcode: << parameters.xcode >> + environment: + HOMEBREW_NO_AUTO_UPDATE: 1 + steps: + - install-mapbox-token + - install-carthage + - run: + name: "Create integration Cartfile" + command: | + echo 'github "mapbox/mapbox-directions-swift"' \"$CIRCLE_SHA1\" > Cartfile + - run: + name: "Build" + command: | + carthage bootstrap --platform all --use-netrc --use-xcframeworks build-job: parameters: @@ -135,6 +155,12 @@ workflows: tvOS: "13.0" watchOS: "6.0" codecoverage: false + - carthage-integration-test: + name: "Carthage Integration Test 12.0" + xcode: "12.0.0" + - carthage-integration-test: + name: "Carthage Integration Test 12.4" + xcode: "12.4.0" - spm-job: name: "SPM_build" xcode: "12.0.0" From 6560fe3271ebd60962558e1b1e9be17135dc5cf2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 17:52:00 +0300 Subject: [PATCH 29/41] Remove Xcode 11 build job Xcode 11 no longer supported with the previous changes because you need Xcode 12 so that Carthage can build the project. --- .circleci/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d542050ac..f9a33f55c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -148,13 +148,6 @@ workflows: iOS: "14.0" tvOS: "14.0" watchOS: "7.0" - - build-job: - name: "Xcode_11.1" - xcode: "11.1.0" - iOS: "13.1" - tvOS: "13.0" - watchOS: "6.0" - codecoverage: false - carthage-integration-test: name: "Carthage Integration Test 12.0" xcode: "12.0.0" From 8e1aebacb1b63941c44074d180d3214c980d8870 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 17:52:27 +0300 Subject: [PATCH 30/41] Update build job names for better readability --- .circleci/config.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f9a33f55c..697e449a6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -143,7 +143,7 @@ workflows: workflow: jobs: - build-job: - name: "Xcode_12.1" + name: "Dev Build: Xcode 12.0" xcode: "12.0.0" iOS: "14.0" tvOS: "14.0" @@ -155,7 +155,10 @@ workflows: name: "Carthage Integration Test 12.4" xcode: "12.4.0" - spm-job: - name: "SPM_build" + name: "SPM build 12.0.0" xcode: "12.0.0" + - spm-job: + name: "SPM build 12.4.0" + xcode: "12.4.0" - spm-linux-job: - name: "SPM_Ubuntu_build" + name: "SPM Ubuntu build" From 2e8a79a9449da0bd8f20b3c67ecd557dcb066c93 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 17:58:56 +0300 Subject: [PATCH 31/41] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 320faabea..51ac62290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ * The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) * Added the `Intersection.preferredApproachLanes` and `Intersection.usableLaneIndication` properties that indicate preferred lane usage. `VisualInstruction.Component.lane(indications:isUsable:)` has been renamed to `VisualInstruction.Component.lane(indications:isUsable:preferredDirection:)`. ([#529](https://github.com/mapbox/mapbox-directions-swift/pull/529)) * Comparing two `Intersection`s with `==` now considers whether the `Intersection.restStop`, `Intersection.regionCode`, and `Intersection.outletMapboxStreetsRoadClass` properties are equal. ([#529](https://github.com/mapbox/mapbox-directions-swift/pull/529)) +* Bump Carthage requirement to >= 0.38. +* Bump Xcode requirement to >= 12.0. +* Add full support for Apple Silicon builds. ## v1.2.0 From bf3b3d33b4af07fa6dd9ccd5c6eeea42cad35a1e Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 17:59:05 +0300 Subject: [PATCH 32/41] Update contributing guide --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fd62decd..7f541bfc6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,9 +24,9 @@ To contribute code changes to this project, use either Carthage or Swift Package ### Using Carthage -1. Install Xcode 12 and [Carthage](https://github.com/Carthage/Carthage/) v0.35 or above. -1. Run `./scripts/wcarthage.sh bootstrap --cache-builds`. (wcarthage.sh is a temporary workaround for [a linker error in Xcode 12](https://github.com/Carthage/Carthage/issues/3019).) -1. Once the Carthage build finishes, open MapboxDirections.xcodeproj in Xcode and build the MapboxDirections Mac scheme. Switch to the Example scheme to see the Mapbox Directions API in action on iOS. +1. Install Xcode 12 and [Carthage](https://github.com/Carthage/Carthage/) v0.38 or above. +1. Run `carthage bootstrap --platform all --use-xcframeworks`. +1. Once the Carthage build finishes, open MapboxDirections.xcodeproj in Xcode and build the MapboxDirections Mac scheme. ### Using Swift Package Manager From 2e4f6be00d828b34868fd7a9f7f8c277cabc254d Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Mon, 31 May 2021 17:59:11 +0300 Subject: [PATCH 33/41] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd6083e09..62d735b3e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ This repository contains an example application that demonstrates how to use the * CocoaPods (CocoaPods 1.10 or above if using Xcode 12) * Carthage 0.38 or above * Swift Package Manager 5.3 or above -* Xcode 11 or above (Xcode 12 or above if using Swift Package Manager) +* Xcode 12 or above * One of the following operating systems: * iOS 10.0 or above * macOS 10.12.0 or above From d110c0250fbc8b87d81ba9d6b7ac83607a338273 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Tue, 1 Jun 2021 09:28:15 +0300 Subject: [PATCH 34/41] Update readme Carthage installation instruction --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62d735b3e..2f69cddc9 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ The [Mapbox Navigation SDK for iOS](https://github.com/mapbox/mapbox-navigation- To build `MapboxDirectionsCLI` using Carthage pipeline: -1. `carthage build --platform macos` +1. `carthage bootstrap --platform macos --use-xcframeworks` 1. `open MapboxDirections.xcodeproj` 1. Select `MapboxDirectionsCLI` target. From 4b02546fadffc3f8f54d0b8746af7b8d6746b7e8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bialiauski Date: Tue, 1 Jun 2021 15:19:42 +0300 Subject: [PATCH 35/41] Update Example app to show text representation of the route --- Directions Example/AppDelegate.swift | 18 +- Directions Example/ContentView.swift | 135 +++++++++++++++ Directions Example/Launch Screen.storyboard | 16 +- Directions Example/MBDrawingView.swift | 95 ----------- Directions Example/ViewController.swift | 179 -------------------- MapboxDirections.xcodeproj/project.pbxproj | 66 +------- 6 files changed, 154 insertions(+), 355 deletions(-) create mode 100644 Directions Example/ContentView.swift delete mode 100644 Directions Example/MBDrawingView.swift delete mode 100644 Directions Example/ViewController.swift diff --git a/Directions Example/AppDelegate.swift b/Directions Example/AppDelegate.swift index 9c2ab060f..f358f5e3e 100644 --- a/Directions Example/AppDelegate.swift +++ b/Directions Example/AppDelegate.swift @@ -1,14 +1,10 @@ -import UIKit +import SwiftUI -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - window = UIWindow(frame: UIScreen.main.bounds) - window!.rootViewController = ViewController(nibName: nil, bundle: nil) - window!.makeKeyAndVisible() - - return true +@main +struct TestApp: App { + var body: some Scene { + WindowGroup { + ContentView(vm: DirectionsViewModel()) + } } } diff --git a/Directions Example/ContentView.swift b/Directions Example/ContentView.swift new file mode 100644 index 000000000..5c06d3504 --- /dev/null +++ b/Directions Example/ContentView.swift @@ -0,0 +1,135 @@ +import Foundation +import SwiftUI +import Combine +import MapboxDirections + +final class DirectionsViewModel: ObservableObject { + private let distanceFormatter: LengthFormatter = .init() + private let travelTimeFormatter: DateComponentsFormatter = .init() + + @Published + var routes: [Route] = [] + + init() { + travelTimeFormatter.unitsStyle = .short + } + + func loadRoutes() { + let startPoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.9131752, longitude: -77.0324047), + name: "Mapbox") + let stopPoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.89065720, longitude: -77.0090701), + name: "Capitol") + let endPoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), + name: "White House") + let options = RouteOptions(waypoints: [startPoint, stopPoint, endPoint]) + options.includesSteps = true + options.routeShapeResolution = .full + options.attributeOptions = [.congestionLevel, .maximumSpeedLimit] + + Directions.shared.calculate(options) { (session, result) in + switch result { + case let .failure(error): + print("Error calculating directions: \(error)") + case let .success(response): + self.routes = response.routes ?? [] + } + } + } + + func formattedDistance(for route: Route) -> String { + return distanceFormatter.string(fromMeters: route.distance) + } + + func formattedTravelTime(for route: Route) -> String { + return travelTimeFormatter.string(from: route.expectedTravelTime)! + } + + func formattedTypicalTravelTime(for route: Route) -> String { + if let typicalTravelTime = route.typicalTravelTime, + let formattedTypicalTravelTime = travelTimeFormatter.string(from: typicalTravelTime) { + return formattedTypicalTravelTime + } + else { + return "Not available" + } + } + + func stepDescriptions(for step: RouteStep) -> String { + var description: String = "" + let direction = step.maneuverDirection?.rawValue ?? "none" + description.append("\(step.instructions) [\(step.maneuverType) \(direction)]") + if step.distance > 0 { + let formattedDistance = distanceFormatter.string(fromMeters: step.distance) + description.append(" (\(step.transportType) for \(formattedDistance))") + } + return description + } +} + +struct ContentView: View { + @ObservedObject + var vm: DirectionsViewModel + + var body: some View { + ScrollView { + LazyVStack(spacing: 10, content: { + ForEach(vm.routes, id: \.routeIdentifier) { route in + VStack(alignment: .leading, spacing: 3) { + headerView(for: route) + ForEach(0.. some View { + VStack(alignment: .leading, spacing: 10) { + HStack { + Text("Route: ").fontWeight(.bold) + Text(route.description) + .fixedSize(horizontal: false, vertical: true) + } + HStack { + Text("Distance: ").fontWeight(.bold) + Text(vm.formattedDistance(for:route)) + } + HStack { + Text("ETA: ").fontWeight(.bold) + Text(vm.formattedTravelTime(for: route)) + } + HStack { + Text("Typical travel time: ").fontWeight(.bold) + Text(vm.formattedTypicalTravelTime(for: route)) + } + Divider() + } + } + + @ViewBuilder + private func stepsView(for leg: RouteLeg) -> some View { + LazyVStack(alignment: .leading, spacing: 5, content: { + ForEach(0.. - - - - + + + - - - + @@ -22,8 +18,8 @@ -