Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
condition: << parameters.lint >>
steps:
- run: find . -path '*.podspec' -exec perl -pi -e 's/.+\.social_media_url.+//' {} \;
- run: pod lib lint MapboxCoreNavigation.podspec
- run: pod lib lint MapboxCoreNavigation.podspec --skip-import-validation
- *save-cache-podmaster
- *save-cache-cocoapods

Expand Down
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
binary "https://www.mapbox.com/ios-sdk/MapboxAccounts.json" ~> 2.3
binary "https://www.mapbox.com/ios-sdk/MapboxAccounts.json" ~> 2.3.0
binary "https://mapbox-gl-native-ios.s3.amazonaws.com/public/internal/Mapbox-iOS-SDK.json" == 5.9.1000
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" ~> 9.2.1
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" ~> 12.0.3
github "mapbox/mapbox-directions-swift" ~> 0.32
github "mapbox/turf-swift" ~> 0.5
github "mapbox/mapbox-events-ios" ~> 0.10
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
binary "https://mapbox-gl-native-ios.s3.amazonaws.com/public/internal/Mapbox-iOS-SDK.json" "5.9.1000"
binary "https://www.mapbox.com/ios-sdk/MapboxAccounts.json" "2.3.0"
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" "9.2.1"
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" "12.0.3"
github "CedarBDD/Cedar" "v1.0"
github "Quick/Nimble" "v8.1.1"
github "Quick/Quick" "v2.2.1"
Expand Down
7 changes: 6 additions & 1 deletion MapboxCoreNavigation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxCoreNavigation"

s.dependency "MapboxNavigationNative", "~> 9.2.1"
s.dependency "MapboxNavigationNative", "~> 12.0.3"
s.dependency "MapboxAccounts", "~> 2.3.0"
s.dependency "MapboxDirections", "~> 0.32.0"
s.dependency "MapboxMobileEvents", "~> 0.10.2" # Always pin to a patch release if pre-1.0
s.dependency "Turf", "~> 0.5.0" # Always pin to a patch release if pre-1.0

s.swift_version = "5.0"

# MapboxNavigationNative is built for arm64 and x86_64 architectures (i386 and armv7 are not present), so only 64-bit architecture is checked.
s.pod_target_xcconfig = {
'ARCHS[sdk=iphonesimulator*]' => '$(ARCHS_STANDARD_64_BIT)'
}
Comment on lines +51 to +54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2422 implements a similar workaround for Carthage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this bit be in #2422 then?


end
14 changes: 11 additions & 3 deletions MapboxCoreNavigation/OfflineDirections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ public class NavigationDirections: Directions {

let tilePath = filePathURL.path
let outputPath = outputDirectoryURL.path

let numberOfTiles = Navigator().unpackTiles(forPackedTilesPath: tilePath, outputDirectory: outputPath)

let navigator: Navigator = {
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
return Navigator(profile: settingsProfile, customConfig: "")
}()

let numberOfTiles = navigator.unpackTiles(forPackedTilesPath: tilePath, outputDirectory: outputPath)

// Report 100% progress
progressHandler?(totalPackedBytes, totalPackedBytes)
Expand Down Expand Up @@ -235,7 +241,9 @@ public class NavigationDirections: Directions {
"The offline navigator must be accessed from the dedicated serial queue")

if _navigator == nil {
self._navigator = Navigator()
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
self._navigator = Navigator(profile: settingsProfile, customConfig: "")
}

return _navigator
Expand Down
10 changes: 7 additions & 3 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ open class RouteController: NSObject {
public static let shouldPreventReroutesWhenArrivingAtWaypoint: Bool = true
public static let shouldDisableBatteryMonitoring: Bool = true
}

let navigator = Navigator()

lazy var navigator: Navigator = {
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
return Navigator(profile: settingsProfile, customConfig: "")
}()

public var route: Route {
get {
Expand Down Expand Up @@ -316,7 +320,7 @@ open class RouteController: NSObject {
NotificationUserInfoKey.routeProgressKey: progress,
NotificationUserInfoKey.locationKey: location, //guaranteed value
NotificationUserInfoKey.rawLocationKey: rawLocation, //raw
])
])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
"${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework",
"${PODS_ROOT}/MapboxNavigationNative/MapboxNavigationNative.framework",
"${PODS_ROOT}/MapboxNavigationNative/MapboxNavigationNative.framework.dSYM",
"${PODS_ROOT}/MapboxNavigationNative/9E1DC337-5279-3C31-9D5D-D8BA2ECDEB2C.bcsymbolmap",
"${PODS_ROOT}/MapboxNavigationNative/6F62B195-8538-3DD3-BDCB-E7AAD8FD1595.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework",
"${BUILT_PRODUCTS_DIR}/Polyline/Polyline.framework",
"${BUILT_PRODUCTS_DIR}/Solar/Solar.framework",
Expand All @@ -265,7 +265,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigationNative.framework",
"${DWARF_DSYM_FOLDER_PATH}/MapboxNavigationNative.framework.dSYM",
"${BUILT_PRODUCTS_DIR}/9E1DC337-5279-3C31-9D5D-D8BA2ECDEB2C.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/6F62B195-8538-3DD3-BDCB-E7AAD8FD1595.bcsymbolmap",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Polyline.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Solar.framework",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PODS:
- MapboxAccounts (~> 2.3.0)
- MapboxDirections (~> 0.32.0)
- MapboxMobileEvents (~> 0.10.2)
- MapboxNavigationNative (= 9.2.1)
- MapboxNavigationNative (~> 12.0.3)
- Turf (~> 0.5.0)
- MapboxDirections (0.32.0):
- Polyline (~> 4.2)
Expand All @@ -18,7 +18,7 @@ PODS:
- MapboxMobileEvents (~> 0.10.2)
- MapboxSpeech (~> 0.3.0)
- Solar (~> 2.1)
- MapboxNavigationNative (9.2.1)
- MapboxNavigationNative (12.0.3)
- MapboxSpeech (0.3.0)
- Polyline (4.2.1)
- Solar (2.1.0)
Expand Down Expand Up @@ -49,11 +49,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Mapbox-iOS-SDK: a5915700ec84bc1a7f8b3e746d474789e35b7956
MapboxAccounts: 84abfdde95d9dc483f604c1b0fe1861edf691ce7
MapboxCoreNavigation: 3aab7ff9c1d56f0da6c2f8656162e90e918ba281
MapboxCoreNavigation: 677802d7786c5795b960269618756e27f07d4217
MapboxDirections: 7f36b3e9ef6a53fc997c114a341ab4da721756bd
MapboxMobileEvents: 2bc0ca2eedb627b73cf403258dce2b2fa98074a6
MapboxNavigation: 42bae50b0381dce317c85884ba0de38fc68a4814
MapboxNavigationNative: 97104806edeb30c77f96f81a255999a4d52f5451
MapboxNavigationNative: b09849eda5d4bc842ba677f75d50a7f913ce9e1b
MapboxSpeech: 403415e932e084cf290b9d55c49ab7ea210b9595
Polyline: 0e9890790292741c8186201a536b6bb6a78d02dd
Solar: 2dc6e7cc39186cb0c8228fa08df76fb50c7d8f24
Expand Down
96 changes: 66 additions & 30 deletions MapboxCoreNavigationTests/MapboxCoreNavigationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import Turf
import TestHelper
@testable import MapboxCoreNavigation

let jsonFileName = "routeWithInstructions"
let routeInstructionsJSONFileName = "routeWithInstructions"
var routeOptions: NavigationRouteOptions {
let from = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.795042, longitude: -122.413165))
let to = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.7727, longitude: -122.433378))
return NavigationRouteOptions(waypoints: [from, to])
}
let response = Fixture.routeResponse(from: jsonFileName, options: routeOptions)
let response = Fixture.routeResponse(from: routeInstructionsJSONFileName, options: routeOptions)
let directions = DirectionsSpy()
let route: Route = {
return Fixture.route(from: jsonFileName, options: routeOptions)
return Fixture.route(from: routeInstructionsJSONFileName, options: routeOptions)
}()

let waitForInterval: TimeInterval = 5
Expand All @@ -22,20 +22,25 @@ class MapboxCoreNavigationTests: XCTestCase {
var navigation: MapboxNavigationService!

func testNavigationNotificationsInfoDict() {
navigation = MapboxNavigationService(route: route, routeOptions: routeOptions, directions: directions, simulating: .never)
// Given
navigation = MapboxNavigationService(route: route,
routeOptions: routeOptions,
directions: directions,
simulating: .never)
let now = Date()
let steps = route.legs.first!.steps
let coordinates = steps[2].shape!.coordinates + steps[3].shape!.coordinates
let routeSteps = route.legs.first!.steps
let coordinates = routeSteps[2].shape!.coordinates + routeSteps[3].shape!.coordinates

let locations = coordinates.enumerated().map { CLLocation(coordinate: $0.element,
altitude: -1, horizontalAccuracy: 10,
verticalAccuracy: -1, course: -1, speed: 10,
timestamp: now + $0.offset) }

let spokenTest = expectation(forNotification: .routeControllerDidPassSpokenInstructionPoint, object: navigation.router) { (note) -> Bool in
let didPassSpokenTestExpectation = expectation(forNotification: .routeControllerDidPassSpokenInstructionPoint,
object: navigation.router) { (note) -> Bool in
return note.userInfo!.count == 2
}
spokenTest.expectationDescription = "Spoken Instruction notification expected to have user info dictionary with two values"
didPassSpokenTestExpectation.expectationDescription = "Spoken Instruction notification expected to have user info dictionary with two values"

navigation.start()

Expand All @@ -47,7 +52,7 @@ class MapboxCoreNavigationTests: XCTestCase {

navigation.locationManager(navigation.locationManager, didUpdateLocations: [location])

wait(for: [spokenTest], timeout: waitForInterval)
wait(for: [didPassSpokenTestExpectation], timeout: waitForInterval)
}

func testDepart() {
Expand Down Expand Up @@ -127,39 +132,70 @@ class MapboxCoreNavigationTests: XCTestCase {
}

func testShouldReroute() {
let coordinates = route.legs[0].steps[1].shape!.coordinates
// Given
let now = Date()
let locations = coordinates.enumerated().map { CLLocation(coordinate: $0.element,
altitude: -1, horizontalAccuracy: 10, verticalAccuracy: -1, course: -1, speed: 10, timestamp: now + $0.offset) }

let offRouteCoordinates = [[-122.41765, 37.79095],[-122.41830,37.79087],[-122.41907,37.79079],[-122.41960,37.79073]]
.map { CLLocationCoordinate2D(latitude: $0[1], longitude: $0[0]) }

let coordinates = route.legs[0].steps[1].shape!.coordinates
let locations = coordinates.enumerated().map {
CLLocation(coordinate: $0.element,
altitude: -1,
horizontalAccuracy: 10,
verticalAccuracy: -1,
course: -1,
speed: 10,
timestamp: now + $0.offset)
}

let offRouteCoordinates = [
[-122.41765, 37.79095],
[-122.41830,37.79087],
[-122.41907,37.79079],
[-122.41960,37.79073],
].map { CLLocationCoordinate2D(latitude: $0[1], longitude: $0[0]) }

let offRouteLocations = offRouteCoordinates.enumerated().map {
CLLocation(coordinate: $0.element, altitude: -1, horizontalAccuracy: 10,
verticalAccuracy: -1, course: -1, speed: 10,
CLLocation(coordinate: $0.element,
altitude: -1,
horizontalAccuracy: 10,
verticalAccuracy: -1,
course: -1,
speed: 10,
timestamp: now + locations.count + $0.offset)
}

let locationManager = ReplayLocationManager(locations: locations + offRouteLocations)
navigation = MapboxNavigationService(route: route, routeOptions: routeOptions, directions: directions, locationSource: locationManager, simulating: .never)
expectation(forNotification: .routeControllerWillReroute, object: navigation.router) { (notification) -> Bool in

let allLocations = locations + offRouteLocations

let locationManager = ReplayLocationManager(locations: allLocations)
navigation = MapboxNavigationService(route: route,
routeOptions: routeOptions,
directions: directions,
locationSource: locationManager,
simulating: .never)

let _ = expectation(forNotification: .routeControllerWillReroute,
object: navigation.router) { (notification) -> Bool in
XCTAssertEqual(notification.userInfo?.count, 1)

let location = notification.userInfo![RouteController.NotificationUserInfoKey.locationKey] as? CLLocation
return location?.coordinate == offRouteLocations[1].coordinate

let locationKey = RouteController.NotificationUserInfoKey.locationKey
let locationFromNotification = notification.userInfo![locationKey] as? CLLocation
XCTAssertEqual(locationFromNotification?.coordinate,
offRouteLocations[2].coordinate)

return true
}


// When
navigation.start()

(locations + offRouteLocations).forEach {
navigation.router!.locationManager!(navigation.locationManager, didUpdateLocations: [$0])
allLocations.forEach {
navigation.router!.locationManager!(navigation.locationManager,
didUpdateLocations: [$0])
}


// Then
waitForExpectations(timeout: waitForInterval) { (error) in
XCTAssertNil(error)
}
}


func testArrive() {
let now = Date()
Expand Down
Loading