From d1087c596f85b69356262d69238fe6f22b08ff46 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 27 Jul 2021 14:57:48 -0700 Subject: [PATCH 01/16] Update. --- CarPlayExample/AppDelegate.swift | 85 ++++++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 +++++++ CarPlayExample/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ CarPlayExample/Base.lproj/Main.storyboard | 24 ++ CarPlayExample/Entitlements.plist | 8 + CarPlayExample/Info.plist | 83 ++++++ CarPlayExample/SceneDelegate.swift | 6 + CarPlayExample/ViewController.swift | 8 + Navigation-Examples.xcodeproj/project.pbxproj | 245 +++++++++++++++++- Podfile | 7 +- Podfile.lock | 93 ++++--- 13 files changed, 657 insertions(+), 42 deletions(-) create mode 100644 CarPlayExample/AppDelegate.swift create mode 100644 CarPlayExample/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 CarPlayExample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 CarPlayExample/Assets.xcassets/Contents.json create mode 100644 CarPlayExample/Base.lproj/LaunchScreen.storyboard create mode 100644 CarPlayExample/Base.lproj/Main.storyboard create mode 100644 CarPlayExample/Entitlements.plist create mode 100644 CarPlayExample/Info.plist create mode 100644 CarPlayExample/SceneDelegate.swift create mode 100644 CarPlayExample/ViewController.swift diff --git a/CarPlayExample/AppDelegate.swift b/CarPlayExample/AppDelegate.swift new file mode 100644 index 00000000..3867178a --- /dev/null +++ b/CarPlayExample/AppDelegate.swift @@ -0,0 +1,85 @@ +import UIKit +import CarPlay + +import MapboxCoreNavigation +import MapboxNavigation +import MapboxDirections + +@main +class AppDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + @available(iOS 12.0, *) + lazy var carPlayManager: CarPlayManager = CarPlayManager() +} + +// MARK: - UIApplicationDelegate methods + +extension AppDelegate: UIApplicationDelegate { + + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + return true + } + + @available(iOS 13.0, *) + func application(_ application: UIApplication, + configurationForConnecting connectingSceneSession: UISceneSession, + options: UIScene.ConnectionOptions) -> UISceneConfiguration { + if connectingSceneSession.role == .carTemplateApplication { + return UISceneConfiguration(name: "CarPlay Configuration", + sessionRole: connectingSceneSession.role) + } + + return UISceneConfiguration(name: "Default Configuration", + sessionRole: connectingSceneSession.role) + } +} + +// MARK: - CPTemplateApplicationSceneDelegate methods + +extension AppDelegate: CPTemplateApplicationSceneDelegate { + + func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, + didConnect interfaceController: CPInterfaceController, + to window: CPWindow) { + carPlayManager.delegate = self + carPlayManager.templateApplicationScene(templateApplicationScene, + didConnectCarInterfaceController: interfaceController, + to: window) + + carPlayManager.application(UIApplication.shared, + didConnectCarInterfaceController: interfaceController, + to: window) + } + + func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, + didDisconnect interfaceController: CPInterfaceController, + from window: CPWindow) { + carPlayManager.delegate = nil + carPlayManager.application(UIApplication.shared, + didDisconnectCarInterfaceController: interfaceController, + from: window) + + carPlayManager.templateApplicationScene(templateApplicationScene, + didDisconnectCarInterfaceController: interfaceController, + from: window) + } +} + +// MARK: - CarPlayManagerDelegate methods + +extension AppDelegate: CarPlayManagerDelegate { + + func carPlayManager(_ carPlayManager: CarPlayManager, + navigationServiceAlong route: Route, + routeIndex: Int, + routeOptions: RouteOptions, + desiredSimulationMode: SimulationMode) -> NavigationService { + return MapboxNavigationService(route: route, + routeIndex: routeIndex, + routeOptions: routeOptions, + simulating: desiredSimulationMode) + } +} diff --git a/CarPlayExample/Assets.xcassets/AccentColor.colorset/Contents.json b/CarPlayExample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/CarPlayExample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CarPlayExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/CarPlayExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/CarPlayExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CarPlayExample/Assets.xcassets/Contents.json b/CarPlayExample/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/CarPlayExample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CarPlayExample/Base.lproj/LaunchScreen.storyboard b/CarPlayExample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/CarPlayExample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CarPlayExample/Base.lproj/Main.storyboard b/CarPlayExample/Base.lproj/Main.storyboard new file mode 100644 index 00000000..25a76385 --- /dev/null +++ b/CarPlayExample/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CarPlayExample/Entitlements.plist b/CarPlayExample/Entitlements.plist new file mode 100644 index 00000000..d74cc083 --- /dev/null +++ b/CarPlayExample/Entitlements.plist @@ -0,0 +1,8 @@ + + + + + com.apple.developer.carplay-maps + + + diff --git a/CarPlayExample/Info.plist b/CarPlayExample/Info.plist new file mode 100644 index 00000000..7c37380c --- /dev/null +++ b/CarPlayExample/Info.plist @@ -0,0 +1,83 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + CPSupportsDashboardNavigationScene + + LSRequiresIPhoneOS + + MBXAccessToken + PASTE MAPBOX ACCESS TOKEN HERE + NSLocationWhenInUseUsageDescription + Get the user location for navigation purposes. + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + CPTemplateApplicationSceneSessionRoleApplication + + + UISceneClassName + CPTemplateApplicationScene + UISceneConfigurationName + CarPlay Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).AppDelegate + + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CarPlayExample/SceneDelegate.swift b/CarPlayExample/SceneDelegate.swift new file mode 100644 index 00000000..e68a968a --- /dev/null +++ b/CarPlayExample/SceneDelegate.swift @@ -0,0 +1,6 @@ +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? +} diff --git a/CarPlayExample/ViewController.swift b/CarPlayExample/ViewController.swift new file mode 100644 index 00000000..d6684ebf --- /dev/null +++ b/CarPlayExample/ViewController.swift @@ -0,0 +1,8 @@ +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + } +} diff --git a/Navigation-Examples.xcodeproj/project.pbxproj b/Navigation-Examples.xcodeproj/project.pbxproj index c87fd042..21fb8a3b 100644 --- a/Navigation-Examples.xcodeproj/project.pbxproj +++ b/Navigation-Examples.xcodeproj/project.pbxproj @@ -19,6 +19,12 @@ 8A2DFA6C261651600034A87E /* Custom-Navigation-Camera.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A2DFA6B261651600034A87E /* Custom-Navigation-Camera.swift */; }; 8A31388726402DF400763714 /* Navigation-From-Segue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A31388626402DF400763714 /* Navigation-From-Segue.swift */; }; 8A33629624E4844E0086C647 /* Building-Extrusion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A33629524E4844E0086C647 /* Building-Extrusion.swift */; }; + 8A3F6B1E26B09C48009EE612 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3F6B1D26B09C48009EE612 /* AppDelegate.swift */; }; + 8A3F6B2026B09C48009EE612 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3F6B1F26B09C48009EE612 /* SceneDelegate.swift */; }; + 8A3F6B2226B09C48009EE612 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3F6B2126B09C48009EE612 /* ViewController.swift */; }; + 8A3F6B2526B09C48009EE612 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A3F6B2326B09C48009EE612 /* Main.storyboard */; }; + 8A3F6B2726B09C4A009EE612 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8A3F6B2626B09C4A009EE612 /* Assets.xcassets */; }; + 8A3F6B2A26B09C4A009EE612 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A3F6B2826B09C4A009EE612 /* LaunchScreen.storyboard */; }; 8A96379C2492B366008DEF2A /* Route-Deserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */; }; 8A96379D2492B366008DEF2A /* route.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A96379B2492B366008DEF2A /* route.json */; }; 8AC9129D2494106100B6941E /* Route-Initialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC9129C2494106100B6941E /* Route-Initialization.swift */; }; @@ -52,22 +58,34 @@ C5C0D63820589422003A3B1D /* Custom-Server.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5C0D63720589422003A3B1D /* Custom-Server.swift */; }; C5F130A01FE9B44600463E86 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F1309F1FE9B44600463E86 /* Constants.swift */; }; C5F130A61FEB2D7800463E86 /* Advanced.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F130A51FEB2D7800463E86 /* Advanced.swift */; }; + D1B95EB8E655F6466A9518CC /* Pods_CarPlayExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFC17203A5AA0333106A668 /* Pods_CarPlayExample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 020D595E7751FB434720AACD /* Pods_Navigation_Examples.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Navigation_Examples.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 11B6E81626176F3600872E4D /* Upcoming-Intersection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Upcoming-Intersection.swift"; sourceTree = ""; }; 11DC36F126161DAF0042CD4A /* Location-Snapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Location-Snapping.swift"; sourceTree = ""; }; + 1CFC17203A5AA0333106A668 /* Pods_CarPlayExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CarPlayExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2B521D4D24090A3A00984CF8 /* CustomBarsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBarsViewController.swift; sourceTree = ""; }; 2B521D4F2409240E00984CF8 /* CustomBottomBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomBannerView.swift; sourceTree = ""; }; 2B521D512409242A00984CF8 /* CustomBottomBannerView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CustomBottomBannerView.xib; sourceTree = ""; }; 4EF74F60792B221A1A61A3CE /* Pods-Navigation-Examples.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Navigation-Examples.debug.xcconfig"; path = "Target Support Files/Pods-Navigation-Examples/Pods-Navigation-Examples.debug.xcconfig"; sourceTree = ""; }; + 5F805B58F5491201CD2D2D5F /* Pods-CarPlayExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CarPlayExample.debug.xcconfig"; path = "Target Support Files/Pods-CarPlayExample/Pods-CarPlayExample.debug.xcconfig"; sourceTree = ""; }; 8A0B182226553482005107DE /* CustomSegue.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CustomSegue.storyboard; sourceTree = ""; }; 8A2DFA55261650A60034A87E /* CustomCameraStateTransition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCameraStateTransition.swift; sourceTree = ""; }; 8A2DFA56261650A60034A87E /* CustomViewportDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomViewportDataSource.swift; sourceTree = ""; }; 8A2DFA6B261651600034A87E /* Custom-Navigation-Camera.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Custom-Navigation-Camera.swift"; sourceTree = ""; }; 8A31388626402DF400763714 /* Navigation-From-Segue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Navigation-From-Segue.swift"; sourceTree = ""; }; 8A33629524E4844E0086C647 /* Building-Extrusion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Building-Extrusion.swift"; sourceTree = ""; }; + 8A3F6B1B26B09C48009EE612 /* CarPlayExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CarPlayExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8A3F6B1D26B09C48009EE612 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 8A3F6B1F26B09C48009EE612 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 8A3F6B2126B09C48009EE612 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 8A3F6B2426B09C48009EE612 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 8A3F6B2626B09C4A009EE612 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 8A3F6B2926B09C4A009EE612 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 8A3F6B2B26B09C4A009EE612 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8A3F6B3326B0B253009EE612 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = ""; }; 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Deserialization.swift"; sourceTree = ""; }; 8A96379B2492B366008DEF2A /* route.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = route.json; sourceTree = ""; }; 8AC9129C2494106100B6941E /* Route-Initialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Route-Initialization.swift"; sourceTree = ""; }; @@ -110,10 +128,19 @@ C5C0D63720589422003A3B1D /* Custom-Server.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Custom-Server.swift"; sourceTree = ""; }; C5F1309F1FE9B44600463E86 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; C5F130A51FEB2D7800463E86 /* Advanced.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Advanced.swift; sourceTree = ""; }; + EBDF518BF4786E6F4DB25952 /* Pods-CarPlayExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CarPlayExample.release.xcconfig"; path = "Target Support Files/Pods-CarPlayExample/Pods-CarPlayExample.release.xcconfig"; sourceTree = ""; }; FAC970C66A93305A51421FFF /* Pods-DocsCode.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DocsCode.release.xcconfig"; path = "Target Support Files/Pods-DocsCode/Pods-DocsCode.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 8A3F6B1826B09C48009EE612 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D1B95EB8E655F6466A9518CC /* Pods_CarPlayExample.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 961FC4FB22E0265300C72877 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -154,6 +181,21 @@ path = NavigationCamera; sourceTree = ""; }; + 8A3F6B1C26B09C48009EE612 /* CarPlayExample */ = { + isa = PBXGroup; + children = ( + 8A3F6B1D26B09C48009EE612 /* AppDelegate.swift */, + 8A3F6B1F26B09C48009EE612 /* SceneDelegate.swift */, + 8A3F6B2126B09C48009EE612 /* ViewController.swift */, + 8A3F6B2326B09C48009EE612 /* Main.storyboard */, + 8A3F6B2626B09C4A009EE612 /* Assets.xcassets */, + 8A3F6B2826B09C4A009EE612 /* LaunchScreen.storyboard */, + 8A3F6B2B26B09C4A009EE612 /* Info.plist */, + 8A3F6B3326B0B253009EE612 /* Entitlements.plist */, + ); + path = CarPlayExample; + sourceTree = ""; + }; 8A5BBF6A2489B0A000FA4960 /* Scripts */ = { isa = PBXGroup; children = ( @@ -205,6 +247,7 @@ C58FB84D1FE899B800C4B491 = { isa = PBXGroup; children = ( + 8A3F6B1C26B09C48009EE612 /* CarPlayExample */, C58FB8581FE899B800C4B491 /* Navigation-Examples */, 961FC4E622E0260A00C72877 /* DocsCode */, 8A5BBF6A2489B0A000FA4960 /* Scripts */, @@ -219,6 +262,7 @@ children = ( C58FB8561FE899B800C4B491 /* Navigation-Examples.app */, 961FC4FE22E0265300C72877 /* DocsCode.app */, + 8A3F6B1B26B09C48009EE612 /* CarPlayExample.app */, ); name = Products; sourceTree = ""; @@ -278,8 +322,9 @@ FAC970C66A93305A51421FFF /* Pods-DocsCode.release.xcconfig */, 4EF74F60792B221A1A61A3CE /* Pods-Navigation-Examples.debug.xcconfig */, A8BC0BE26AF9683D3B034741 /* Pods-Navigation-Examples.release.xcconfig */, + 5F805B58F5491201CD2D2D5F /* Pods-CarPlayExample.debug.xcconfig */, + EBDF518BF4786E6F4DB25952 /* Pods-CarPlayExample.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -289,6 +334,7 @@ 8DF510761FEB0CA00049DB9C /* MapboxNavigation.framework */, 020D595E7751FB434720AACD /* Pods_Navigation_Examples.framework */, 9B796D93B6E7934BFD326FA8 /* Pods_DocsCode.framework */, + 1CFC17203A5AA0333106A668 /* Pods_CarPlayExample.framework */, ); name = Frameworks; sourceTree = ""; @@ -296,6 +342,26 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 8A3F6B1A26B09C48009EE612 /* CarPlayExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8A3F6B2E26B09C4A009EE612 /* Build configuration list for PBXNativeTarget "CarPlayExample" */; + buildPhases = ( + 5159D55EA629EFFB8E5F1015 /* [CP] Check Pods Manifest.lock */, + 8A3F6B1726B09C48009EE612 /* Sources */, + 8A3F6B1826B09C48009EE612 /* Frameworks */, + 8A3F6B1926B09C48009EE612 /* Resources */, + 89DFE9A4155B596CE41A9EA3 /* [CP] Embed Pods Frameworks */, + 8A3F6B2F26B09D8F009EE612 /* Apply Mapbox Access Token */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CarPlayExample; + productName = CarPlayExample; + productReference = 8A3F6B1B26B09C48009EE612 /* CarPlayExample.app */; + productType = "com.apple.product-type.application"; + }; 961FC4FD22E0265300C72877 /* DocsCode */ = { isa = PBXNativeTarget; buildConfigurationList = 961FC51122E0265400C72877 /* Build configuration list for PBXNativeTarget "DocsCode" */; @@ -344,10 +410,14 @@ C58FB84E1FE899B800C4B491 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0920; + LastSwiftUpdateCheck = 1250; LastUpgradeCheck = 1220; ORGANIZATIONNAME = Mapbox; TargetAttributes = { + 8A3F6B1A26B09C48009EE612 = { + CreatedOnToolsVersion = 12.5.1; + ProvisioningStyle = Manual; + }; 961FC4FD22E0265300C72877 = { CreatedOnToolsVersion = 10.2.1; LastSwiftMigration = 1110; @@ -375,11 +445,22 @@ targets = ( C58FB8551FE899B800C4B491 /* Navigation-Examples */, 961FC4FD22E0265300C72877 /* DocsCode */, + 8A3F6B1A26B09C48009EE612 /* CarPlayExample */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 8A3F6B1926B09C48009EE612 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8A3F6B2A26B09C4A009EE612 /* LaunchScreen.storyboard in Resources */, + 8A3F6B2726B09C4A009EE612 /* Assets.xcassets in Resources */, + 8A3F6B2526B09C48009EE612 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 961FC4FC22E0265300C72877 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -505,6 +586,86 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 5159D55EA629EFFB8E5F1015 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-CarPlayExample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 89DFE9A4155B596CE41A9EA3 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-CarPlayExample/Pods-CarPlayExample-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework", + "${BUILT_PRODUCTS_DIR}/MapboxDirections-pre/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", + "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", + "${BUILT_PRODUCTS_DIR}/MapboxSpeech-pre/MapboxSpeech.framework", + "${BUILT_PRODUCTS_DIR}/Polyline/Polyline.framework", + "${BUILT_PRODUCTS_DIR}/Solar-dev/Solar.framework", + "${BUILT_PRODUCTS_DIR}/Turf/Turf.framework", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCommon/MapboxCommon.framework/MapboxCommon", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCoreMaps/MapboxCoreMaps.framework/MapboxCoreMaps", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework/MapboxMobileEvents", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxNavigationNative/MapboxNavigationNative.framework/MapboxNavigationNative", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Polyline.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Solar.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Turf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCommon.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreMaps.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigationNative.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CarPlayExample/Pods-CarPlayExample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 8A3F6B2F26B09D8F009EE612 /* Apply Mapbox Access Token */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Apply Mapbox Access Token"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "$SRCROOT/Scripts/apply-mapbox-access-token.sh\n"; + }; 8AAD08F22486DA4700664446 /* Apply Mapbox Access Token */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -600,6 +761,16 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 8A3F6B1726B09C48009EE612 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8A3F6B2226B09C48009EE612 /* ViewController.swift in Sources */, + 8A3F6B1E26B09C48009EE612 /* AppDelegate.swift in Sources */, + 8A3F6B2026B09C48009EE612 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 961FC4FA22E0265300C72877 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -649,6 +820,22 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ + 8A3F6B2326B09C48009EE612 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 8A3F6B2426B09C48009EE612 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 8A3F6B2826B09C4A009EE612 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 8A3F6B2926B09C4A009EE612 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; C58FB85D1FE899B800C4B491 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -668,6 +855,51 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 8A3F6B2C26B09C4A009EE612 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5F805B58F5491201CD2D2D5F /* Pods-CarPlayExample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_ENTITLEMENTS = "${SRCROOT}/CarPlayExample/Entitlements.plist"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = GJZR2MEM28; + INFOPLIST_FILE = CarPlayExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.Mapbox.CarPlay-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "CarPlay Provisioning Profile"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 8A3F6B2D26B09C4A009EE612 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = EBDF518BF4786E6F4DB25952 /* Pods-CarPlayExample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_ENTITLEMENTS = "${SRCROOT}/CarPlayExample/Entitlements.plist"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = GJZR2MEM28; + INFOPLIST_FILE = CarPlayExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.Mapbox.CarPlay-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "CarPlay Provisioning Profile"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 961FC51222E0265400C72877 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 9223D8DB7C82389A1E85E3E5 /* Pods-DocsCode.debug.xcconfig */; @@ -853,6 +1085,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 8A3F6B2E26B09C4A009EE612 /* Build configuration list for PBXNativeTarget "CarPlayExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8A3F6B2C26B09C4A009EE612 /* Debug */, + 8A3F6B2D26B09C4A009EE612 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 961FC51122E0265400C72877 /* Build configuration list for PBXNativeTarget "DocsCode" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Podfile b/Podfile index 7811a67f..0d25d7bc 100644 --- a/Podfile +++ b/Podfile @@ -3,11 +3,14 @@ install! 'cocoapods', :warn_for_unused_master_specs_repo => false platform :ios, '11.0' use_frameworks! -pod 'MapboxCoreNavigation', '~> 2.0' -pod 'MapboxNavigation', '~> 2.0' +pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'main' +pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'main' target 'Navigation-Examples' do end target 'DocsCode' do end + +target 'CarPlayExample' do +end diff --git a/Podfile.lock b/Podfile.lock index 4dbb107d..234e7b37 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,36 +1,37 @@ PODS: - - MapboxCommon (20.1.0) - - MapboxCoreMaps (10.1.0): - - MapboxCommon (~> 20.1) - - MapboxCoreNavigation (2.0.1): - - MapboxDirections (~> 2.0) - - MapboxMobileEvents (~> 1.0) - - MapboxNavigationNative (~> 69.0) - - MapboxDirections (2.0.0): + - MapboxCommon (16.0.0) + - MapboxCoreMaps (10.0.0-rc.5): + - MapboxCommon (~> 16.0.0) + - MapboxCoreNavigation (2.0.0-beta.21): + - MapboxDirections-pre (= 2.0.0-beta.7) + - MapboxMobileEvents (~> 1.0.0) + - MapboxNavigationNative (~> 60.0) + - Turf (= 2.0.0-beta.1) + - MapboxDirections-pre (2.0.0-beta.7): - Polyline (~> 5.0) - - Turf (~> 2.0) - - MapboxMaps (10.1.0): - - MapboxCommon (= 20.1.0) - - MapboxCoreMaps (= 10.1.0) - - MapboxMobileEvents (= 1.0.6) - - Turf (~> 2.0) - - MapboxMobileEvents (1.0.6) - - MapboxNavigation (2.0.1): - - MapboxCoreNavigation (= 2.0.1) - - MapboxMaps (~> 10.0) - - MapboxMobileEvents (~> 1.0) - - MapboxSpeech (~> 2.0) + - Turf (~> 2.0.0-beta.1) + - MapboxMaps (10.0.0-rc.5): + - MapboxCommon (= 16.0.0) + - MapboxCoreMaps (= 10.0.0-rc.5) + - MapboxMobileEvents (= 1.0.2) + - Turf (= 2.0.0-beta.1) + - MapboxMobileEvents (1.0.2) + - MapboxNavigation (2.0.0-beta.21): + - MapboxCoreNavigation (= 2.0.0-beta.21) + - MapboxMaps (= 10.0.0-rc.5) + - MapboxMobileEvents (~> 1.0.0) + - MapboxSpeech-pre (= 2.0.0-alpha.1) - Solar-dev (~> 3.0) - - MapboxNavigationNative (69.0.3): - - MapboxCommon (~> 20.0) - - MapboxSpeech (2.0.0) + - MapboxNavigationNative (60.0.0): + - MapboxCommon (~> 16.0) + - MapboxSpeech-pre (2.0.0-alpha.1) - Polyline (5.0.2) - Solar-dev (3.0.1) - - Turf (2.1.0) + - Turf (2.0.0-beta.1) DEPENDENCIES: - - MapboxCoreNavigation (~> 2.0) - - MapboxNavigation (~> 2.0) + - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) + - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) SPEC REPOS: trunk: @@ -47,20 +48,36 @@ SPEC REPOS: - Solar-dev - Turf +EXTERNAL SOURCES: + MapboxCoreNavigation: + :branch: main + :git: https://github.com/mapbox/mapbox-navigation-ios.git + MapboxNavigation: + :branch: main + :git: https://github.com/mapbox/mapbox-navigation-ios.git + +CHECKOUT OPTIONS: + MapboxCoreNavigation: + :commit: 3ae3cf3960703dd34a59d0b5d6adef6830f7e373 + :git: https://github.com/mapbox/mapbox-navigation-ios.git + MapboxNavigation: + :commit: 3ae3cf3960703dd34a59d0b5d6adef6830f7e373 + :git: https://github.com/mapbox/mapbox-navigation-ios.git + SPEC CHECKSUMS: - MapboxCommon: 8dd878a6c444b78bc1a819af1920dd1a0bb9f732 - MapboxCoreMaps: 6ecb358c04600f6a947e52d41b78ac0c2570f930 - MapboxCoreNavigation: 6b523a368630727659422744167fd88a7b158e01 - MapboxDirections: bbb1b63cf5250a337abb1d120d9706280deb6747 - MapboxMaps: c19e24617b7135f87fac7dbad3a4baef657555ae - MapboxMobileEvents: 14d7ac3ee95b4142c4fec2205dfd48ff453e8871 - MapboxNavigation: 64530555dea0a6db0064eb4f33f9e89d3315bb07 - MapboxNavigationNative: a997b061e4eb93c1fb881992e5061e3a290f04f6 - MapboxSpeech: e4ed02984444b6373374c72c369edaf045cc490c + MapboxCommon: 44430838b703d0b1b5032f3c8501c60c7c70d3cc + MapboxCoreMaps: 0aa69120a787fce64eb66ea1068a707fbc0a3c8b + MapboxCoreNavigation: d79eb0b5d0d35c9ebaadbc7ed9bc07faff58c0e4 + MapboxDirections-pre: 929a1a63063c9c97f88b793e70143d547eaed293 + MapboxMaps: b966939712943f6af126aadf73b82b43c0535020 + MapboxMobileEvents: 9775eb995e06cc3ea10894bf6ab111683c8e73e7 + MapboxNavigation: 4cd5a5c46c9ec186f46b9509f85e5fe0c8782221 + MapboxNavigationNative: 9f49640451eca820667c657475d412e1c990d41b + MapboxSpeech-pre: aeb16de604d07ceb4195150c3359d5401bb298e6 Polyline: fce41d72e1146c41c6d081f7656827226f643dff Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 - Turf: d1220730a00b50a9fb5862c1fb6a5dd698c9e367 + Turf: 8851f941a6e6476ea200bf057d31cf21b2418467 -PODFILE CHECKSUM: ade747cd70b06f12dd4076e55177eb029b4813b0 +PODFILE CHECKSUM: 9f3bdf8f2b78c4d17175133554bc4b33a9ac4613 -COCOAPODS: 1.11.2 +COCOAPODS: 1.10.1 From ae9a50c145fb6bd072bc37fa9c11b8bb728dfc70 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Mon, 2 Aug 2021 14:22:25 -0700 Subject: [PATCH 02/16] Update. --- CarPlayExample/AppDelegate.swift | 127 +++++++++- CarPlayExample/Base.lproj/Main.storyboard | 36 ++- CarPlayExample/Info.plist | 4 + CarPlayExample/ViewController.swift | 228 +++++++++++++++++- Navigation-Examples.xcodeproj/project.pbxproj | 1 + Podfile.lock | 4 +- 6 files changed, 384 insertions(+), 16 deletions(-) diff --git a/CarPlayExample/AppDelegate.swift b/CarPlayExample/AppDelegate.swift index 3867178a..133a7a4c 100644 --- a/CarPlayExample/AppDelegate.swift +++ b/CarPlayExample/AppDelegate.swift @@ -4,6 +4,7 @@ import CarPlay import MapboxCoreNavigation import MapboxNavigation import MapboxDirections +import MapboxMaps @main class AppDelegate: UIResponder, UIWindowSceneDelegate { @@ -73,13 +74,123 @@ extension AppDelegate: CPTemplateApplicationSceneDelegate { extension AppDelegate: CarPlayManagerDelegate { func carPlayManager(_ carPlayManager: CarPlayManager, - navigationServiceAlong route: Route, - routeIndex: Int, - routeOptions: RouteOptions, - desiredSimulationMode: SimulationMode) -> NavigationService { - return MapboxNavigationService(route: route, - routeIndex: routeIndex, - routeOptions: routeOptions, - simulating: desiredSimulationMode) + leadingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, + in carPlayTemplate: CPTemplate, for activity: CarPlayActivity) -> [CPBarButton]? { + let barButton = CPBarButton(type: .text) { _ in + + } + barButton.title = "Test" + + return [barButton] + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + trailingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, + in carPlayTemplate: CPTemplate, + for activity: CarPlayActivity) -> [CPBarButton]? { + switch activity { + + case .browsing: + break + + case .panningInBrowsingMode: + break + + case .previewing: + break + + case .navigating: + break + + } + + let barButton = CPBarButton(type: .text) { _ in + + } + barButton.title = "Test" + + return [barButton] + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + mapButtonsCompatibleWith traitCollection: UITraitCollection, + in carPlayTemplate: CPTemplate, + for activity: CarPlayActivity) -> [CPMapButton] { + switch activity { + + case .browsing: + break + + case .panningInBrowsingMode: + break + + case .previewing: + break + + case .navigating: + break + + } + + let mapButton = CPMapButton { _ in + + } + mapButton.image = UIImage.checkmark + + return [mapButton] + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + didFailToFetchRouteBetween waypoints: [Waypoint]?, + options: RouteOptions, + error: DirectionsError) -> CPNavigationAlert? { + return nil + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + willPreview trip: CPTrip) -> CPTrip { + return trip + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + willPreview trip: CPTrip, + with previewTextConfiguration: CPTripPreviewTextConfiguration) -> CPTripPreviewTextConfiguration { + return previewTextConfiguration + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + selectedPreviewFor trip: CPTrip, + using routeChoice: CPRouteChoice) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + didBeginNavigationWith service: NavigationService) { + + } + + func carPlayManagerDidEndNavigation(_ carPlayManager: CarPlayManager) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + shouldPresentArrivalUIFor waypoint: Waypoint) -> Bool { + return false + } + + func carPlayManagerShouldDisableIdleTimer(_ carPlayManager: CarPlayManager) -> Bool { + return false + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + didPresent navigationViewController: CarPlayNavigationViewController) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + didAdd finalDestinationAnnotation: PointAnnotation, + to parentViewController: UIViewController, + pointAnnotationManager: PointAnnotationManager) { + } } diff --git a/CarPlayExample/Base.lproj/Main.storyboard b/CarPlayExample/Base.lproj/Main.storyboard index 25a76385..06134660 100644 --- a/CarPlayExample/Base.lproj/Main.storyboard +++ b/CarPlayExample/Base.lproj/Main.storyboard @@ -1,24 +1,50 @@ - + + - + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + diff --git a/CarPlayExample/Info.plist b/CarPlayExample/Info.plist index 7c37380c..921dc6c5 100644 --- a/CarPlayExample/Info.plist +++ b/CarPlayExample/Info.plist @@ -58,6 +58,10 @@ UIApplicationSupportsIndirectInputEvents + UIBackgroundModes + + audio + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/CarPlayExample/ViewController.swift b/CarPlayExample/ViewController.swift index d6684ebf..0b43a8e4 100644 --- a/CarPlayExample/ViewController.swift +++ b/CarPlayExample/ViewController.swift @@ -1,8 +1,234 @@ import UIKit -class ViewController: UIViewController { +import MapboxCoreNavigation +import MapboxNavigation +import MapboxDirections +class ViewController: UIViewController, NavigationMapViewDelegate, NavigationViewControllerDelegate, UIGestureRecognizerDelegate { + + typealias ActionHandler = (UIAlertAction) -> Void + + var navigationMapView: NavigationMapView! + + var navigationRouteOptions: NavigationRouteOptions! + + var currentRoute: Route? { + get { + return routes?.first + } + set { + guard let selected = newValue else { routes = nil; return } + guard let routes = routes else { self.routes = [selected]; return } + self.routes = [selected] + routes.filter { $0 != selected } + } + } + + var routes: [Route]? { + didSet { + guard let routes = routes, let currentRoute = routes.first else { + navigationMapView.removeRoutes() + navigationMapView.removeWaypoints() + waypoints.removeAll() + return + } + + navigationMapView.show(routes) + navigationMapView.showWaypoints(on: currentRoute) + } + } + + var waypoints: [Waypoint] = [] + + // MARK: - UIViewController lifecycle methods + override func viewDidLoad() { super.viewDidLoad() + + setupNavigationMapView() + setupPerformActionBarButtonItem() + setupGestureRecognizers() + } + + // MARK: - Setting-up methods + + func setupNavigationMapView() { + navigationMapView = NavigationMapView(frame: view.bounds) + navigationMapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + navigationMapView.delegate = self + navigationMapView.userLocationStyle = .puck2D() + + let navigationViewportDataSource = NavigationViewportDataSource(navigationMapView.mapView, + viewportDataSourceType: .raw) + navigationMapView.navigationCamera.viewportDataSource = navigationViewportDataSource + + view.addSubview(navigationMapView) + } + + func setupPerformActionBarButtonItem() { + let settingsBarButtonItem = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, style: .plain, target: self, action: #selector(performAction)) + settingsBarButtonItem.setTitleTextAttributes([.font: UIFont.systemFont(ofSize: 30)], for: .normal) + settingsBarButtonItem.setTitleTextAttributes([.font: UIFont.systemFont(ofSize: 30)], for: .highlighted) + navigationItem.rightBarButtonItem = settingsBarButtonItem + } + + // MARK: - UIGestureRecognizer related methods + + func setupGestureRecognizers() { + let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(_:))) + navigationMapView.addGestureRecognizer(longPressGestureRecognizer) + } + + @objc func performAction(_ sender: Any) { + let alertController = UIAlertController(title: "Perform action", + message: "Select specific action to perform it", preferredStyle: .actionSheet) + + let startNavigation: ActionHandler = { _ in self.startNavigation() } + let removeRoutes: ActionHandler = { _ in self.routes = nil } + + let actions: [(String, UIAlertAction.Style, ActionHandler?)] = [ + ("Start Navigation", .default, startNavigation), + ("Remove Routes", .default, removeRoutes), + ("Cancel", .cancel, nil) + ] + + actions + .map({ payload in UIAlertAction(title: payload.0, style: payload.1, handler: payload.2) }) + .forEach(alertController.addAction(_:)) + + if let popoverController = alertController.popoverPresentationController { + popoverController.barButtonItem = navigationItem.rightBarButtonItem + } + + present(alertController, animated: true, completion: nil) + } + + func startNavigation() { + guard let route = currentRoute, let navigationRouteOptions = navigationRouteOptions else { + presentAlert(message: "Please select at least one destination coordinate to start navigation.") + return + } + + let navigationService = MapboxNavigationService(route: route, + routeIndex: 0, + routeOptions: navigationRouteOptions, + simulating: .always) + let navigationOptions = NavigationOptions(navigationService: navigationService) + let navigationViewController = NavigationViewController(for: route, + routeIndex: 0, + routeOptions: navigationRouteOptions, + navigationOptions: navigationOptions) + navigationViewController.delegate = self + navigationViewController.modalPresentationStyle = .fullScreen + + present(navigationViewController, animated: true) { + let delegate = UIApplication.shared.delegate as? AppDelegate + + if #available(iOS 12.0, *), + let location = navigationService.router.location { + delegate?.carPlayManager.beginNavigationWithCarPlay(using: location.coordinate, + navigationService: navigationService) + } + } + } + + @objc func handleLongPress(_ gesture: UILongPressGestureRecognizer) { + guard gesture.state == .began else { return } + + createWaypoints(for: navigationMapView.mapView.mapboxMap.coordinate(for: gesture.location(in: navigationMapView.mapView))) + requestRoute() + } + + func createWaypoints(for destinationCoordinate: CLLocationCoordinate2D?) { + guard let destinationCoordinate = destinationCoordinate else { return } + guard let userCoordinate = navigationMapView.mapView.location.latestLocation?.coordinate else { + presentAlert(message: "User coordinate is not valid. Make sure to enable Location Services.") + return + } + + // In case if origin waypoint is not present in list of waypoints - add it. + let userLocationName = "User location" + let userWaypoint = Waypoint(coordinate: userCoordinate, name: userLocationName) + if waypoints.first?.name != userLocationName { + waypoints.insert(userWaypoint, at: 0) + } + + // Add destination waypoint to list of waypoints. + let waypoint = Waypoint(coordinate: destinationCoordinate) + waypoint.targetCoordinate = destinationCoordinate + waypoints.append(waypoint) + } + + func requestRoute() { + let navigationRouteOptions = NavigationRouteOptions(waypoints: waypoints) + Directions.shared.calculate(navigationRouteOptions) { [weak self] (_, result) in + switch result { + case .failure(let error): + self?.presentAlert(message: error.localizedDescription) + + // In case if direction calculation failed - remove last destination waypoint. + self?.waypoints.removeLast() + case .success(let response): + guard let routes = response.routes else { return } + self?.navigationRouteOptions = navigationRouteOptions + self?.routes = routes + self?.navigationMapView.show(routes) + if let currentRoute = self?.currentRoute { + self?.navigationMapView.showWaypoints(on: currentRoute) + } + + if let coordinates = self?.waypoints.compactMap({ $0.targetCoordinate }) { + self?.navigationMapView.highlightBuildings(at: coordinates, in3D: true) + } + } + } + } + + // MARK: - NavigationMapViewDelegate methods + + func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) { + self.currentRoute = route + } + + // MARK: - NavigationViewControllerDelegate methods + + func navigationViewController(_ navigationViewController: NavigationViewController, didArriveAt waypoint: Waypoint) -> Bool { + if navigationViewController.navigationService.router.routeProgress.isFinalLeg { + return true + } + + // In case of intermediate waypoint - proceed to next leg only after specific delay. + let delay = 5.0 + DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: { + guard let navigationService = (self.presentedViewController as? NavigationViewController)?.navigationService else { return } + let router = navigationService.router + guard router.route.legs.count > router.routeProgress.legIndex + 1 else { return } + router.routeProgress.legIndex += 1 + + navigationService.start() + }) + + return false + } + + func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) { + dismiss(animated: true, completion: nil) + } + + // MARK: - UIGestureRecognizerDelegate methods + + func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { + // Allow both route selection and building extrusion when tapping on screen. + return true + } + + // MARK: - Utility methods + + func presentAlert(_ title: String? = nil, message: String? = nil) { + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in + alertController.dismiss(animated: true, completion: nil) + })) + + present(alertController, animated: true, completion: nil) } } diff --git a/Navigation-Examples.xcodeproj/project.pbxproj b/Navigation-Examples.xcodeproj/project.pbxproj index 21fb8a3b..904395c9 100644 --- a/Navigation-Examples.xcodeproj/project.pbxproj +++ b/Navigation-Examples.xcodeproj/project.pbxproj @@ -656,6 +656,7 @@ inputFileListPaths = ( ); inputPaths = ( + "$(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)", ); name = "Apply Mapbox Access Token"; outputFileListPaths = ( diff --git a/Podfile.lock b/Podfile.lock index 234e7b37..7a74a66d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -58,10 +58,10 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 3ae3cf3960703dd34a59d0b5d6adef6830f7e373 + :commit: 5c9fc1df2cd4bdc8efee539ff854ee6d150ccabc :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 3ae3cf3960703dd34a59d0b5d6adef6830f7e373 + :commit: 5c9fc1df2cd4bdc8efee539ff854ee6d150ccabc :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: From 0eb1acf71d06b4dacd2fb07482d93a232f8972c7 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 3 Aug 2021 17:14:10 -0700 Subject: [PATCH 03/16] Update. --- CarPlayExample/AppDelegate.swift | 59 +++++++++----- .../marker.imageset/Contents.json | 12 +++ .../marker.imageset/marker.pdf | Bin 0 -> 4227 bytes CarPlayExample/ViewController.swift | 74 +++++++++++------- Podfile | 4 +- Podfile.lock | 14 ++-- 6 files changed, 109 insertions(+), 54 deletions(-) create mode 100644 CarPlayExample/Assets.xcassets/marker.imageset/Contents.json create mode 100644 CarPlayExample/Assets.xcassets/marker.imageset/marker.pdf diff --git a/CarPlayExample/AppDelegate.swift b/CarPlayExample/AppDelegate.swift index 133a7a4c..483fd6c7 100644 --- a/CarPlayExample/AppDelegate.swift +++ b/CarPlayExample/AppDelegate.swift @@ -1,6 +1,5 @@ import UIKit import CarPlay - import MapboxCoreNavigation import MapboxNavigation import MapboxDirections @@ -45,27 +44,35 @@ extension AppDelegate: CPTemplateApplicationSceneDelegate { func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController, to window: CPWindow) { - carPlayManager.delegate = self - carPlayManager.templateApplicationScene(templateApplicationScene, - didConnectCarInterfaceController: interfaceController, - to: window) + guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } + + appDelegate.carPlayManager.delegate = appDelegate + + appDelegate.carPlayManager.application(UIApplication.shared, + didConnectCarInterfaceController: interfaceController, + to: window) + + appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, + didConnectCarInterfaceController: interfaceController, + to: window) - carPlayManager.application(UIApplication.shared, - didConnectCarInterfaceController: interfaceController, - to: window) + appDelegate.carPlayManager.interfaceController?.delegate = self } func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didDisconnect interfaceController: CPInterfaceController, from window: CPWindow) { - carPlayManager.delegate = nil - carPlayManager.application(UIApplication.shared, - didDisconnectCarInterfaceController: interfaceController, - from: window) + guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } - carPlayManager.templateApplicationScene(templateApplicationScene, - didDisconnectCarInterfaceController: interfaceController, - from: window) + appDelegate.carPlayManager.delegate = nil + + appDelegate.carPlayManager.application(UIApplication.shared, + didDisconnectCarInterfaceController: interfaceController, + from: window) + + appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, + didDisconnectCarInterfaceController: interfaceController, + from: window) } } @@ -144,7 +151,16 @@ extension AppDelegate: CarPlayManagerDelegate { didFailToFetchRouteBetween waypoints: [Waypoint]?, options: RouteOptions, error: DirectionsError) -> CPNavigationAlert? { - return nil + let alertAction = CPAlertAction(title: "Dismiss", style: .default, handler: { _ in }) + + let navigationAlert = CPNavigationAlert(titleVariants: ["Failed to fetch"], + subtitleVariants: nil, + image: nil, + primaryAction: alertAction, + secondaryAction: nil, + duration: 2.5) + + return navigationAlert } func carPlayManager(_ carPlayManager: CarPlayManager, @@ -166,7 +182,7 @@ extension AppDelegate: CarPlayManagerDelegate { func carPlayManager(_ carPlayManager: CarPlayManager, didBeginNavigationWith service: NavigationService) { - + } func carPlayManagerDidEndNavigation(_ carPlayManager: CarPlayManager) { @@ -184,13 +200,20 @@ extension AppDelegate: CarPlayManagerDelegate { func carPlayManager(_ carPlayManager: CarPlayManager, didPresent navigationViewController: CarPlayNavigationViewController) { - + } func carPlayManager(_ carPlayManager: CarPlayManager, didAdd finalDestinationAnnotation: PointAnnotation, to parentViewController: UIViewController, pointAnnotationManager: PointAnnotationManager) { + var finalDestinationAnnotation = finalDestinationAnnotation + if let image = UIImage(named: "marker") { + finalDestinationAnnotation.image = PointAnnotation.Image.custom(image: image, name: "marker") + } else { + finalDestinationAnnotation.image = .default + } + pointAnnotationManager.syncAnnotations([finalDestinationAnnotation]) } } diff --git a/CarPlayExample/Assets.xcassets/marker.imageset/Contents.json b/CarPlayExample/Assets.xcassets/marker.imageset/Contents.json new file mode 100644 index 00000000..6a0d2bc4 --- /dev/null +++ b/CarPlayExample/Assets.xcassets/marker.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "marker.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CarPlayExample/Assets.xcassets/marker.imageset/marker.pdf b/CarPlayExample/Assets.xcassets/marker.imageset/marker.pdf new file mode 100644 index 0000000000000000000000000000000000000000..182f34ee0f8d0bb2f7a235fdb1c9f00297fc3672 GIT binary patch literal 4227 zcmai%c|25a`^N`U7(!*II?0kOGh@u4GTAj+kdmF5F?L2{R};$ewIy3)NkU~`ipn-* zUmug~6|$2p<%>vuGcCV*zCF+DIj{4YbDz(B-Pe83xjuiqF9`!J9XYr>0wU2k^>J!G z`_uiGjm;2600t0oPLPu)0q9wRo4uz4fTT+o0H}_mizk6Zf4X2j30ed^(Ut(9(GU+$ z5&`Q9@nt$^gmDvvb5^g*Yy`n9#Pv>Y?Ltp6v4FW?>^7Y{LA-s#Pq=$Bk3Me98^8AI z1UZf)mu*{>Wn%BE*0`o>q^Oti0UeY{Xt|h&&MIJTpAy#Ym%dP-bb(I+!28|iLebCz z#v(Mw(!e4y>gZ%DSs+?nsb$Vm_4*YMb%)oeyS7K>pp4WdYE&L(^ok4<(;) zt!`o3up&}on6IUOTx7}ErIripL!`8FZ{GKwj|R;MzaIZES<_qSL>ZfmXXSND=n`Y` z&&Y3#1Yz2h3*T_K#Zni%PN*^(N zz$iZBsfbi$OfrTFzggs>pF0778er|e{gMc7o&e&zT`mwjh+ZT-!2>{j7c_}(p7ePS zfMGGZpUx3%9kCijU%(tj7ZhOtTmfbYp*!lwHjHIIooGNJ;*AKNfH{3HEgirTfNBz5 zh$JI-ES>-`tg7h&2b8|$MWY$6{E)@vU=9tI^w!#?!@F17*!JQJ zCfzVGyf!b#%^SD@_K!RU&2@%a+Ec?(&g{#D$WJ3F+byP}Lo?3@hU}Ng1C=0yFE_yT zo+eCziWw%nOY?OW`}TJ-zY`EErlcvp8wAnrL!G=XDKN#HU{u;9q_6{SUrm%&2!$)~XRv1$h)pyWyR2nT z%T%=`Q6wibgiX7Isuk}=RT+$=NQ`AgfiolF}O#22a+78W?StxS4xdO zu$BFu>$>N0Q7MesBGl!r-Pv`R&kBv zoKhT-3kxnDOzF<@GP6os={Jb&wV^8O$sJ2u#wQ*LoC-RE;X@F#rygZLI-}Lu$;m~b z*>11%>`c5+ar{?XgY4b(7Xm9GvzH8K6WD{p9jZc32ASNJw}k`;^o<1wqNG@buBSQk zI(S)w$RR2QwEmjM5^GFH#=%?YP4LVu}zGPc?sn)%OG~) zgeX_b3!!mQ_v__?77A|2BJgwWfvBp$`G!4Xk}JN|$3}RUZ*bRne862hTmuOZ4LCR& zbEvsi>NdL>*!c$c;X8o1i}*zzVYV5z?clxjiiSZs`krE;JbsN9IO)f?2Gy%EqLSz1 zc`>2l0vE)klgolGVw}V*B~>Mk6~Pn3za!ub4H=fru+RSErs0g4aB zT0ULM`fz~W*GFHWqT2N{lmf#>(ndLonJYnTfc+a4EQO+|6-hlc7X)Tu|Ke zefqg-b0x1N9v&9f=y~Y(s=Vx6+40we*RTV+N)NVr;^&%H56x0n*$EN^^Qog#qEo_C zrR^7X*TZZ!5Eq0VM#V=}Ma6tloUWiv(B7bm9j$h%r4v6Nb31k|Q7q9ekts1I@9ZUF zA8%h;o@<_dFU(2O3F|cEwACk{A5F`q`P`$WSu5^LehGVDQW@@FzUlOL!+X{D@xm#> zHNrx|mxL*b%}AjXx0JS&sgxPTmNEx3j;CO=DYKcURc_J z2gCWQh4`FO6Z@?5rCs|ieiYEw7+-> zytau{Pp!+zh{&kL-os{%;g96S=64^D%h~AT=x}s2dVh^~O+FdAf!$`__TC)+H1J_&b6`s! ztPCz-pM^XC>wt|}(Hsiw`*wMO8|s+qs%{*DzOoj#=;deD_@e0@a*`d%Y00hU`p_l;BGBSqh&ZAQ-tBeOfc)K zKYi!*#QI~;un{FPmIzfTDzrf{3#M7w?%20b9{rhy3c&fxrQ;t%nCnNT{g!Fd9&b`yClPQyK9S7PzwQXHT+97?s z>}$NghJL9-E;(}*hV&O%ys0?vV_8=@_IJ&Ej4R-Jdgw!kPDeCBWYjHUq}TAiVM&dR zL+SE#vqpu6;TTn}%bd%l$%W5laoDc3(CH0D%&PluT*r9CxW2^OxcO02^5xINoom61 z)Q4*iw|w4tv-!Loo~!(1l8iI88hTmu&a!Z-^JC`6=T(;%YK*bwS8TW)V{Bu}6mp(W z^@^Qz`?B9ZcpoGjlQK&V}l(P1v_% z1r4eS{36JCb5h&sYtLSqMVMvuzwHly_5kI0_3YKrxxk*Z z16>E?PNnW#Ta8*vPAP4-KSPV{;=7xwlJ0Z;qegScN@Tb|*zwDr=*qImS7}8hMI#+S zlwzxu3R3PH>eiP_lzjUl70VOkG%|HDbUV8LVAZ`l)(h7i=bkRRQs>-Dx9?08-m2L} zp4qhAf{v_JlBaI%q=~RZ?%rIIuerKo^;UI`JhI)*n#*lzw~=NkK$kG_(wcGIKl!JoGN#A*hGeq(7AT;V6IGWeCD z(IFS3si}eWAlL#7fV}`%{tRKT^-m`Lh29?j1*RF4>_sPXH~>B4XzM|zX9l{{)BQ%s za0Yz;drD2LC)R~%{~hZ+e(?M+riR0RtT=iOiwE?L022TXlZPYZ5rCl=mgMOV&=LI` z?E893|2#PSXVY+0>$n08t_)L9Kqw$!a2U!A29u)SzaoD-4;}k$z3}v=^V^>Eo{v!^h^hX>*QHfs6f5a)#yP$t)2u0){aR{W! zpK+-Fuok8A+geW&*3pGP`qtSSIr`JTAH4&*KqS)r!SDe6Lt@B9-ANBp!)|{O^$OcJuJ0TjN_n5Xx{EL_$JaUkCDk Dn{YAY literal 0 HcmV?d00001 diff --git a/CarPlayExample/ViewController.swift b/CarPlayExample/ViewController.swift index 0b43a8e4..2e1873a3 100644 --- a/CarPlayExample/ViewController.swift +++ b/CarPlayExample/ViewController.swift @@ -1,10 +1,9 @@ import UIKit - import MapboxCoreNavigation import MapboxNavigation import MapboxDirections -class ViewController: UIViewController, NavigationMapViewDelegate, NavigationViewControllerDelegate, UIGestureRecognizerDelegate { +class ViewController: UIViewController { typealias ActionHandler = (UIAlertAction) -> Void @@ -65,22 +64,30 @@ class ViewController: UIViewController, NavigationMapViewDelegate, NavigationVie } func setupPerformActionBarButtonItem() { - let settingsBarButtonItem = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, style: .plain, target: self, action: #selector(performAction)) - settingsBarButtonItem.setTitleTextAttributes([.font: UIFont.systemFont(ofSize: 30)], for: .normal) - settingsBarButtonItem.setTitleTextAttributes([.font: UIFont.systemFont(ofSize: 30)], for: .highlighted) + let settingsBarButtonItem = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, + style: .plain, + target: self, + action: #selector(performAction)) + let attributes = [ + NSAttributedString.Key.font: UIFont.systemFont(ofSize: 30) + ] + settingsBarButtonItem.setTitleTextAttributes(attributes, for: .normal) + settingsBarButtonItem.setTitleTextAttributes(attributes, for: .highlighted) navigationItem.rightBarButtonItem = settingsBarButtonItem } // MARK: - UIGestureRecognizer related methods func setupGestureRecognizers() { - let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(_:))) + let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, + action: #selector(handleLongPress(_:))) navigationMapView.addGestureRecognizer(longPressGestureRecognizer) } @objc func performAction(_ sender: Any) { let alertController = UIAlertController(title: "Perform action", - message: "Select specific action to perform it", preferredStyle: .actionSheet) + message: "Select specific action to perform it", + preferredStyle: .actionSheet) let startNavigation: ActionHandler = { _ in self.startNavigation() } let removeRoutes: ActionHandler = { _ in self.routes = nil } @@ -134,7 +141,8 @@ class ViewController: UIViewController, NavigationMapViewDelegate, NavigationVie @objc func handleLongPress(_ gesture: UILongPressGestureRecognizer) { guard gesture.state == .began else { return } - createWaypoints(for: navigationMapView.mapView.mapboxMap.coordinate(for: gesture.location(in: navigationMapView.mapView))) + let mapView = navigationMapView.mapView + createWaypoints(for: mapView?.mapboxMap.coordinate(for: gesture.location(in: mapView))) requestRoute() } @@ -182,16 +190,34 @@ class ViewController: UIViewController, NavigationMapViewDelegate, NavigationVie } } } - - // MARK: - NavigationMapViewDelegate methods + + // MARK: - Utility methods + + func presentAlert(_ title: String? = nil, message: String? = nil) { + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in + alertController.dismiss(animated: true, completion: nil) + })) + + present(alertController, animated: true, completion: nil) + } +} + +// MARK: - NavigationMapViewDelegate methods + +extension ViewController: NavigationMapViewDelegate { func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) { self.currentRoute = route } +} + +// MARK: - NavigationViewControllerDelegate methods + +extension ViewController: NavigationViewControllerDelegate { - // MARK: - NavigationViewControllerDelegate methods - - func navigationViewController(_ navigationViewController: NavigationViewController, didArriveAt waypoint: Waypoint) -> Bool { + func navigationViewController(_ navigationViewController: NavigationViewController, + didArriveAt waypoint: Waypoint) -> Bool { if navigationViewController.navigationService.router.routeProgress.isFinalLeg { return true } @@ -210,25 +236,19 @@ class ViewController: UIViewController, NavigationMapViewDelegate, NavigationVie return false } - func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) { + func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, + byCanceling canceled: Bool) { dismiss(animated: true, completion: nil) } +} - // MARK: - UIGestureRecognizerDelegate methods +// MARK: - UIGestureRecognizerDelegate methods - func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { +extension ViewController: UIGestureRecognizerDelegate { + + func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, + shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { // Allow both route selection and building extrusion when tapping on screen. return true } - - // MARK: - Utility methods - - func presentAlert(_ title: String? = nil, message: String? = nil) { - let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in - alertController.dismiss(animated: true, completion: nil) - })) - - present(alertController, animated: true, completion: nil) - } } diff --git a/Podfile b/Podfile index 0d25d7bc..841ec881 100644 --- a/Podfile +++ b/Podfile @@ -3,8 +3,8 @@ install! 'cocoapods', :warn_for_unused_master_specs_repo => false platform :ios, '11.0' use_frameworks! -pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'main' -pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'main' +pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/car-play-refactoring' +pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/car-play-refactoring' target 'Navigation-Examples' do end diff --git a/Podfile.lock b/Podfile.lock index 7a74a66d..9a5aaa78 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -30,8 +30,8 @@ PODS: - Turf (2.0.0-beta.1) DEPENDENCIES: - - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) - - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) + - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) + - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) SPEC REPOS: trunk: @@ -50,18 +50,18 @@ SPEC REPOS: EXTERNAL SOURCES: MapboxCoreNavigation: - :branch: main + :branch: maxim/car-play-refactoring :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :branch: main + :branch: maxim/car-play-refactoring :git: https://github.com/mapbox/mapbox-navigation-ios.git CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 5c9fc1df2cd4bdc8efee539ff854ee6d150ccabc + :commit: 3d471096f6ecc68376169a82a36a4af0eb0218f8 :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 5c9fc1df2cd4bdc8efee539ff854ee6d150ccabc + :commit: 3d471096f6ecc68376169a82a36a4af0eb0218f8 :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: @@ -78,6 +78,6 @@ SPEC CHECKSUMS: Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 Turf: 8851f941a6e6476ea200bf057d31cf21b2418467 -PODFILE CHECKSUM: 9f3bdf8f2b78c4d17175133554bc4b33a9ac4613 +PODFILE CHECKSUM: cdba1559ae133c7fa27daf8adf70e8089ac9c090 COCOAPODS: 1.10.1 From b67dd44e699daeba8c1a5e72f51e35d5e15926d9 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Wed, 4 Aug 2021 10:51:41 -0700 Subject: [PATCH 04/16] Update. --- Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 9a5aaa78..be6ac0c4 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -58,10 +58,10 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 3d471096f6ecc68376169a82a36a4af0eb0218f8 + :commit: 947d437f6e505e9de23261e2725658d6758982ce :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 3d471096f6ecc68376169a82a36a4af0eb0218f8 + :commit: 947d437f6e505e9de23261e2725658d6758982ce :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: From c957ec08389250972f2b0eee5b71d52b0f2be419 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Wed, 4 Aug 2021 11:28:05 -0700 Subject: [PATCH 05/16] Update. --- CarPlayExample/AppDelegate.swift | 74 ++++++++++++------- CarPlayExample/CustomStyle.swift | 15 ++++ Navigation-Examples.xcodeproj/project.pbxproj | 4 + 3 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 CarPlayExample/CustomStyle.swift diff --git a/CarPlayExample/AppDelegate.swift b/CarPlayExample/AppDelegate.swift index 483fd6c7..ea295b90 100644 --- a/CarPlayExample/AppDelegate.swift +++ b/CarPlayExample/AppDelegate.swift @@ -11,7 +11,7 @@ class AppDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? @available(iOS 12.0, *) - lazy var carPlayManager: CarPlayManager = CarPlayManager() + lazy var carPlayManager: CarPlayManager = CarPlayManager(styles: [CustomStyle()]) } // MARK: - UIApplicationDelegate methods @@ -55,8 +55,6 @@ extension AppDelegate: CPTemplateApplicationSceneDelegate { appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, didConnectCarInterfaceController: interfaceController, to: window) - - appDelegate.carPlayManager.interfaceController?.delegate = self } func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, @@ -82,13 +80,24 @@ extension AppDelegate: CarPlayManagerDelegate { func carPlayManager(_ carPlayManager: CarPlayManager, leadingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, - in carPlayTemplate: CPTemplate, for activity: CarPlayActivity) -> [CPBarButton]? { - let barButton = CPBarButton(type: .text) { _ in + in carPlayTemplate: CPTemplate, + for activity: CarPlayActivity) -> [CPBarButton]? { + switch activity { + + case .browsing: + break + case .panningInBrowsingMode: + break + + case .previewing: + break + + case .navigating: + break } - barButton.title = "Test" - return [barButton] + return [] } func carPlayManager(_ carPlayManager: CarPlayManager, @@ -107,22 +116,16 @@ extension AppDelegate: CarPlayManagerDelegate { break case .navigating: - break - + return [carPlayManager.exitButton] } - let barButton = CPBarButton(type: .text) { _ in - - } - barButton.title = "Test" - - return [barButton] + return [] } func carPlayManager(_ carPlayManager: CarPlayManager, mapButtonsCompatibleWith traitCollection: UITraitCollection, in carPlayTemplate: CPTemplate, - for activity: CarPlayActivity) -> [CPMapButton] { + for activity: CarPlayActivity) -> [CPMapButton]? { switch activity { case .browsing: @@ -136,15 +139,9 @@ extension AppDelegate: CarPlayManagerDelegate { case .navigating: break - } - let mapButton = CPMapButton { _ in - - } - mapButton.image = UIImage.checkmark - - return [mapButton] + return [] } func carPlayManager(_ carPlayManager: CarPlayManager, @@ -185,24 +182,51 @@ extension AppDelegate: CarPlayManagerDelegate { } + // Delegate method, which is called after ending active-guidance navigation session and dismissing + // `CarPlayNavigationViewController`. func carPlayManagerDidEndNavigation(_ carPlayManager: CarPlayManager) { + let alertAction = CPAlertAction(title: "OK", + style: .default, + handler: { [weak self] _ in + self?.carPlayManager.interfaceController?.dismissTemplate(animated: true) + }) + + let alertTemplate = CPAlertTemplate(titleVariants: ["Did end active-guidance navigation."], + actions: [alertAction]) + carPlayManager.interfaceController?.presentTemplate(alertTemplate, animated: true) } + // Delegate method, which allows to show `CPActionSheetTemplate` or `CPAlertTemplate` + // after arriving to the specific `Waypoint`. func carPlayManager(_ carPlayManager: CarPlayManager, shouldPresentArrivalUIFor waypoint: Waypoint) -> Bool { - return false + return true } + // Delegate method, which provides the ability to disable the idle timer to avert system sleep. func carPlayManagerShouldDisableIdleTimer(_ carPlayManager: CarPlayManager) -> Bool { - return false + return true } + // Delegate method, which is called right after starting active-guidance navigation and presenting + // `CarPlayNavigationViewController`. func carPlayManager(_ carPlayManager: CarPlayManager, didPresent navigationViewController: CarPlayNavigationViewController) { + let alertAction = CPAlertAction(title: "OK", + style: .default, + handler: { [weak self] _ in + self?.carPlayManager.interfaceController?.dismissTemplate(animated: true) + }) + + let alertTemplate = CPAlertTemplate(titleVariants: ["Did present CarPlayNavigationViewController."], + actions: [alertAction]) + carPlayManager.interfaceController?.presentTemplate(alertTemplate, animated: true) } + // Delegate method, which allows to modify final destination annotation whenever its added to + // `CarPlayMapViewController` or `CarPlayNavigationViewController`. func carPlayManager(_ carPlayManager: CarPlayManager, didAdd finalDestinationAnnotation: PointAnnotation, to parentViewController: UIViewController, diff --git a/CarPlayExample/CustomStyle.swift b/CarPlayExample/CustomStyle.swift new file mode 100644 index 00000000..b9966741 --- /dev/null +++ b/CarPlayExample/CustomStyle.swift @@ -0,0 +1,15 @@ +import MapboxNavigation +import MapboxMaps + +class CustomStyle: NightStyle { + + required init() { + super.init() + + mapStyleURL = URL(string: StyleURI.dark.rawValue)! + } + + override func apply() { + super.apply() + } +} diff --git a/Navigation-Examples.xcodeproj/project.pbxproj b/Navigation-Examples.xcodeproj/project.pbxproj index 904395c9..cb5d7c12 100644 --- a/Navigation-Examples.xcodeproj/project.pbxproj +++ b/Navigation-Examples.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 8A3F6B2A26B09C4A009EE612 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A3F6B2826B09C4A009EE612 /* LaunchScreen.storyboard */; }; 8A96379C2492B366008DEF2A /* Route-Deserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */; }; 8A96379D2492B366008DEF2A /* route.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A96379B2492B366008DEF2A /* route.json */; }; + 8AB316AD26BB0BAF00C3AC76 /* CustomStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AB316AC26BB0BAE00C3AC76 /* CustomStyle.swift */; }; 8AC9129D2494106100B6941E /* Route-Initialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC9129C2494106100B6941E /* Route-Initialization.swift */; }; 8AE033222628EDFF000E7145 /* Route-Lines-Styling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE033212628EDFF000E7145 /* Route-Lines-Styling.swift */; }; 8DF510741FEB08F70049DB9C /* Embedded-Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DF510731FEB08F70049DB9C /* Embedded-Navigation.swift */; }; @@ -88,6 +89,7 @@ 8A3F6B3326B0B253009EE612 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = ""; }; 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Deserialization.swift"; sourceTree = ""; }; 8A96379B2492B366008DEF2A /* route.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = route.json; sourceTree = ""; }; + 8AB316AC26BB0BAE00C3AC76 /* CustomStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStyle.swift; sourceTree = ""; }; 8AC9129C2494106100B6941E /* Route-Initialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Route-Initialization.swift"; sourceTree = ""; }; 8AD2F2132489B5C800F81353 /* apply-mapbox-access-token.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "apply-mapbox-access-token.sh"; sourceTree = ""; }; 8AE033212628EDFF000E7145 /* Route-Lines-Styling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Lines-Styling.swift"; sourceTree = ""; }; @@ -184,6 +186,7 @@ 8A3F6B1C26B09C48009EE612 /* CarPlayExample */ = { isa = PBXGroup; children = ( + 8AB316AC26BB0BAE00C3AC76 /* CustomStyle.swift */, 8A3F6B1D26B09C48009EE612 /* AppDelegate.swift */, 8A3F6B1F26B09C48009EE612 /* SceneDelegate.swift */, 8A3F6B2126B09C48009EE612 /* ViewController.swift */, @@ -766,6 +769,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8AB316AD26BB0BAF00C3AC76 /* CustomStyle.swift in Sources */, 8A3F6B2226B09C48009EE612 /* ViewController.swift in Sources */, 8A3F6B1E26B09C48009EE612 /* AppDelegate.swift in Sources */, 8A3F6B2026B09C48009EE612 /* SceneDelegate.swift in Sources */, From 7c183027cf663d69a30f86885a3f9646e7802a26 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Wed, 4 Aug 2021 15:05:22 -0700 Subject: [PATCH 06/16] Update. --- Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index be6ac0c4..84c3bb9e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -58,10 +58,10 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 947d437f6e505e9de23261e2725658d6758982ce + :commit: 693f3ecc16835494566e0cd7625c24c6a3af931c :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 947d437f6e505e9de23261e2725658d6758982ce + :commit: 693f3ecc16835494566e0cd7625c24c6a3af931c :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: From 87ab9a7de8fb5678d54dc3bd9f223fcf129fe775 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Wed, 4 Aug 2021 16:39:35 -0700 Subject: [PATCH 07/16] Update. --- CarPlayExample/ViewController.swift | 58 ++++++++++------------------- Podfile.lock | 4 +- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/CarPlayExample/ViewController.swift b/CarPlayExample/ViewController.swift index 2e1873a3..702730e2 100644 --- a/CarPlayExample/ViewController.swift +++ b/CarPlayExample/ViewController.swift @@ -11,26 +11,15 @@ class ViewController: UIViewController { var navigationRouteOptions: NavigationRouteOptions! - var currentRoute: Route? { - get { - return routes?.first - } - set { - guard let selected = newValue else { routes = nil; return } - guard let routes = routes else { self.routes = [selected]; return } - self.routes = [selected] + routes.filter { $0 != selected } - } - } - - var routes: [Route]? { + var routeResponse: RouteResponse? { didSet { - guard let routes = routes, let currentRoute = routes.first else { + guard let routes = routeResponse?.routes, let currentRoute = routes.first else { navigationMapView.removeRoutes() navigationMapView.removeWaypoints() waypoints.removeAll() return } - + navigationMapView.show(routes) navigationMapView.showWaypoints(on: currentRoute) } @@ -90,7 +79,7 @@ class ViewController: UIViewController { preferredStyle: .actionSheet) let startNavigation: ActionHandler = { _ in self.startNavigation() } - let removeRoutes: ActionHandler = { _ in self.routes = nil } + let removeRoutes: ActionHandler = { _ in self.routeResponse = nil } let actions: [(String, UIAlertAction.Style, ActionHandler?)] = [ ("Start Navigation", .default, startNavigation), @@ -110,20 +99,17 @@ class ViewController: UIViewController { } func startNavigation() { - guard let route = currentRoute, let navigationRouteOptions = navigationRouteOptions else { + guard let routeResponse = routeResponse, + let navigationRouteOptions = navigationRouteOptions else { presentAlert(message: "Please select at least one destination coordinate to start navigation.") return } - - let navigationService = MapboxNavigationService(route: route, + + let navigationService = MapboxNavigationService(routeResponse: routeResponse, routeIndex: 0, routeOptions: navigationRouteOptions, simulating: .always) - let navigationOptions = NavigationOptions(navigationService: navigationService) - let navigationViewController = NavigationViewController(for: route, - routeIndex: 0, - routeOptions: navigationRouteOptions, - navigationOptions: navigationOptions) + let navigationViewController = NavigationViewController(navigationService: navigationService) navigationViewController.delegate = self navigationViewController.modalPresentationStyle = .fullScreen @@ -169,24 +155,17 @@ class ViewController: UIViewController { func requestRoute() { let navigationRouteOptions = NavigationRouteOptions(waypoints: waypoints) Directions.shared.calculate(navigationRouteOptions) { [weak self] (_, result) in + guard let self = self else { return } + switch result { case .failure(let error): - self?.presentAlert(message: error.localizedDescription) - + self.presentAlert(message: error.localizedDescription) + // In case if direction calculation failed - remove last destination waypoint. - self?.waypoints.removeLast() + self.waypoints.removeLast() case .success(let response): - guard let routes = response.routes else { return } - self?.navigationRouteOptions = navigationRouteOptions - self?.routes = routes - self?.navigationMapView.show(routes) - if let currentRoute = self?.currentRoute { - self?.navigationMapView.showWaypoints(on: currentRoute) - } - - if let coordinates = self?.waypoints.compactMap({ $0.targetCoordinate }) { - self?.navigationMapView.highlightBuildings(at: coordinates, in3D: true) - } + self.routeResponse = response + self.navigationRouteOptions = navigationRouteOptions } } } @@ -208,7 +187,10 @@ class ViewController: UIViewController { extension ViewController: NavigationMapViewDelegate { func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) { - self.currentRoute = route + guard let routes = routeResponse?.routes, + let routeIndex = routes.firstIndex(where: { $0 === route }) else { return } + + routeResponse?.routes?.swapAt(routeIndex, 0) } } diff --git a/Podfile.lock b/Podfile.lock index 84c3bb9e..197d6ca0 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -58,10 +58,10 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 693f3ecc16835494566e0cd7625c24c6a3af931c + :commit: 884f7282b64a655f8fba2e2abec339d795024b19 :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 693f3ecc16835494566e0cd7625c24c6a3af931c + :commit: 884f7282b64a655f8fba2e2abec339d795024b19 :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: From 206cf98d7fd10dc142b92af4e7f5de964de0dbc1 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Wed, 4 Aug 2021 16:47:55 -0700 Subject: [PATCH 08/16] Update. --- CarPlayExample/ViewController.swift | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CarPlayExample/ViewController.swift b/CarPlayExample/ViewController.swift index 702730e2..712e7dd3 100644 --- a/CarPlayExample/ViewController.swift +++ b/CarPlayExample/ViewController.swift @@ -223,14 +223,3 @@ extension ViewController: NavigationViewControllerDelegate { dismiss(animated: true, completion: nil) } } - -// MARK: - UIGestureRecognizerDelegate methods - -extension ViewController: UIGestureRecognizerDelegate { - - func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, - shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { - // Allow both route selection and building extrusion when tapping on screen. - return true - } -} From 86de0f7ff0517d8ae20ed7ed4cba62df646be3d5 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 10 Aug 2021 15:08:40 -0700 Subject: [PATCH 09/16] Update. --- ...e+CPTemplateApplicationSceneDelegate.swift | 38 ++++ .../AppDelegate+CarPlayManagerDelegate.swift | 209 +++++++++++++++++ ...gate+CarPlaySearchControllerDelegate.swift | 126 ++++++++++ CarPlayExample/AppDelegate.swift | 215 +----------------- Navigation-Examples.xcodeproj/project.pbxproj | 22 +- Podfile | 1 + Podfile.lock | 9 +- 7 files changed, 409 insertions(+), 211 deletions(-) create mode 100644 CarPlayExample/AppDelegate+CPTemplateApplicationSceneDelegate.swift create mode 100644 CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift create mode 100644 CarPlayExample/AppDelegate+CarPlaySearchControllerDelegate.swift diff --git a/CarPlayExample/AppDelegate+CPTemplateApplicationSceneDelegate.swift b/CarPlayExample/AppDelegate+CPTemplateApplicationSceneDelegate.swift new file mode 100644 index 00000000..885bc686 --- /dev/null +++ b/CarPlayExample/AppDelegate+CPTemplateApplicationSceneDelegate.swift @@ -0,0 +1,38 @@ +import CarPlay + +// MARK: - CPTemplateApplicationSceneDelegate methods + +extension AppDelegate: CPTemplateApplicationSceneDelegate { + + func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, + didConnect interfaceController: CPInterfaceController, + to window: CPWindow) { + guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } + + appDelegate.carPlayManager.delegate = appDelegate + + appDelegate.carPlayManager.application(UIApplication.shared, + didConnectCarInterfaceController: interfaceController, + to: window) + + appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, + didConnectCarInterfaceController: interfaceController, + to: window) + } + + func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, + didDisconnect interfaceController: CPInterfaceController, + from window: CPWindow) { + guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } + + appDelegate.carPlayManager.delegate = nil + + appDelegate.carPlayManager.application(UIApplication.shared, + didDisconnectCarInterfaceController: interfaceController, + from: window) + + appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, + didDisconnectCarInterfaceController: interfaceController, + from: window) + } +} diff --git a/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift b/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift new file mode 100644 index 00000000..e077f07d --- /dev/null +++ b/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift @@ -0,0 +1,209 @@ +import CarPlay +import MapboxCoreNavigation +import MapboxNavigation +import MapboxDirections +import MapboxMaps + +// MARK: - CarPlayManagerDelegate methods + +extension AppDelegate: CarPlayManagerDelegate { + + // Delegate method, which allows to provide list of leading `CPBarButton`s for specific `CarPlayActivity`. + // It's possible to provide up to two leading `CPBarButton`s. + func carPlayManager(_ carPlayManager: CarPlayManager, + leadingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, + in carPlayTemplate: CPTemplate, + for activity: CarPlayActivity) -> [CPBarButton]? { + guard let interfaceController = self.carPlayManager.interfaceController else { return nil } + + switch activity { + + case .browsing: + let searchTemplate = CPSearchTemplate() + searchTemplate.delegate = carPlaySearchController + let searchButton = carPlaySearchController.searchTemplateButton(searchTemplate: searchTemplate, + interfaceController: interfaceController, + traitCollection: traitCollection) + return [searchButton] + case .panningInBrowsingMode: + break + + case .previewing: + break + + case .navigating: + break + } + + return [] + } + + // Delegate method, which allows to provide list of trailing `CPBarButton`s for specific `CarPlayActivity`. + // It's possible to provide up to two trailing `CPBarButton`s. + func carPlayManager(_ carPlayManager: CarPlayManager, + trailingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, + in carPlayTemplate: CPTemplate, + for activity: CarPlayActivity) -> [CPBarButton]? { + switch activity { + + case .browsing: + break + + case .panningInBrowsingMode: + break + + case .previewing: + break + + case .navigating: + return [carPlayManager.exitButton] + } + + return [] + } + + // Delegate method, which allows to provide a list of `CPMapButton`, which are shown on a map. + // It's possible to provide up to four `CPMapButton`s. + func carPlayManager(_ carPlayManager: CarPlayManager, + mapButtonsCompatibleWith traitCollection: UITraitCollection, + in carPlayTemplate: CPTemplate, + for activity: CarPlayActivity) -> [CPMapButton]? { + switch activity { + + case .browsing: + break + + case .panningInBrowsingMode: + break + + case .previewing: + break + + case .navigating: + break + } + + return [] + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + didFailToFetchRouteBetween waypoints: [Waypoint]?, + options: RouteOptions, + error: DirectionsError) -> CPNavigationAlert? { + let alertAction = CPAlertAction(title: "Dismiss", style: .default, handler: { _ in }) + + let navigationAlert = CPNavigationAlert(titleVariants: ["Failed to fetch"], + subtitleVariants: nil, + image: nil, + primaryAction: alertAction, + secondaryAction: nil, + duration: 2.5) + + return navigationAlert + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + willPreview trip: CPTrip) -> CPTrip { + return trip + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + willPreview trip: CPTrip, + with previewTextConfiguration: CPTripPreviewTextConfiguration) -> CPTripPreviewTextConfiguration { + return previewTextConfiguration + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + selectedPreviewFor trip: CPTrip, + using routeChoice: CPRouteChoice) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + didBeginNavigationWith service: NavigationService) { + + } + + // Delegate method, which is called after ending active-guidance navigation session and dismissing + // `CarPlayNavigationViewController`. + func carPlayManagerDidEndNavigation(_ carPlayManager: CarPlayManager) { + let alertAction = CPAlertAction(title: "OK", + style: .default, + handler: { [weak self] _ in + self?.carPlayManager.interfaceController?.dismissTemplate(animated: true) + }) + + let alertTemplate = CPAlertTemplate(titleVariants: ["Did end active-guidance navigation."], + actions: [alertAction]) + + carPlayManager.interfaceController?.presentTemplate(alertTemplate, animated: true) + } + + // Delegate method, which allows to show `CPActionSheetTemplate` or `CPAlertTemplate` + // after arriving to the specific `Waypoint`. + func carPlayManager(_ carPlayManager: CarPlayManager, + shouldPresentArrivalUIFor waypoint: Waypoint) -> Bool { + return true + } + + // Delegate method, which provides the ability to disable the idle timer to avert system sleep. + func carPlayManagerShouldDisableIdleTimer(_ carPlayManager: CarPlayManager) -> Bool { + return true + } + + // Delegate method, which is called right after starting active-guidance navigation and presenting + // `CarPlayNavigationViewController`. + func carPlayManager(_ carPlayManager: CarPlayManager, + didPresent navigationViewController: CarPlayNavigationViewController) { + let alertAction = CPAlertAction(title: "OK", + style: .default, + handler: { [weak self] _ in + self?.carPlayManager.interfaceController?.dismissTemplate(animated: true) + }) + + let alertTemplate = CPAlertTemplate(titleVariants: ["Did present CarPlayNavigationViewController."], + actions: [alertAction]) + + carPlayManager.interfaceController?.presentTemplate(alertTemplate, animated: true) + } + + // Delegate method, which allows to modify final destination annotation whenever its added to + // `CarPlayMapViewController` or `CarPlayNavigationViewController`. + func carPlayManager(_ carPlayManager: CarPlayManager, + didAdd finalDestinationAnnotation: PointAnnotation, + to parentViewController: UIViewController, + pointAnnotationManager: PointAnnotationManager) { + var finalDestinationAnnotation = finalDestinationAnnotation + if let image = UIImage(named: "marker") { + finalDestinationAnnotation.image = PointAnnotation.Image.custom(image: image, name: "marker") + } else { + finalDestinationAnnotation.image = .default + } + + pointAnnotationManager.syncAnnotations([finalDestinationAnnotation]) + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + templateWillAppear template: CPTemplate, + animated: Bool) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + templateDidAppear template: CPTemplate, + animated: Bool) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + templateWillDisappear template: CPTemplate, + animated: Bool) { + + } + + func carPlayManager(_ carPlayManager: CarPlayManager, + templateDidDisappear template: CPTemplate, + animated: Bool) { + + } +} diff --git a/CarPlayExample/AppDelegate+CarPlaySearchControllerDelegate.swift b/CarPlayExample/AppDelegate+CarPlaySearchControllerDelegate.swift new file mode 100644 index 00000000..dd0bd1cd --- /dev/null +++ b/CarPlayExample/AppDelegate+CarPlaySearchControllerDelegate.swift @@ -0,0 +1,126 @@ +import CarPlay +import MapboxNavigation +import MapboxDirections +import MapboxGeocoder + +// MARK: - CarPlaySearchControllerDelegate methods + +extension AppDelegate: CarPlaySearchControllerDelegate { + + func previewRoutes(to waypoint: Waypoint, completionHandler: @escaping () -> Void) { + carPlayManager.previewRoutes(to: waypoint, completionHandler: completionHandler) + } + + func resetPanButtons(_ mapTemplate: CPMapTemplate) { + carPlayManager.resetPanButtons(mapTemplate) + } + + func pushTemplate(_ template: CPTemplate, animated: Bool) { + if let listTemplate = template as? CPListTemplate { + listTemplate.delegate = carPlaySearchController + } + carPlayManager.interfaceController?.pushTemplate(template, animated: animated) + } + + func popTemplate(animated: Bool) { + carPlayManager.interfaceController?.popTemplate(animated: animated) + } + + func recentSearches(with searchText: String) -> [CPListItem] { + if searchText.isEmpty { + return recentItems.map { $0.navigationGeocodedPlacemark.listItem() } + } + + return recentItems.filter { + $0.matches(searchText) + }.map { + $0.navigationGeocodedPlacemark.listItem() + } + } + + func searchResults(with items: [CPListItem], limit: UInt?) -> [CPListItem] { + recentSearchItems = items + + if items.count > 0 { + if let limit = limit { + return Array(items.prefix(Int(limit))) + } + + return items + } else { + let noResultListItem = CPListItem(text: "No results", + detailText: nil, + image: nil, + showsDisclosureIndicator: false) + + return [noResultListItem] + } + } + + func searchTemplate(_ searchTemplate: CPSearchTemplate, + updatedSearchText searchText: String, + completionHandler: @escaping ([CPListItem]) -> Void) { + recentSearchText = searchText + + var items = recentSearches(with: searchText) + let limit: UInt = 2 + + if searchText.count > 2 { + + let forwardGeocodeOptions = ForwardGeocodeOptions(query: searchText) + forwardGeocodeOptions.locale = Locale.autoupdatingCurrent.languageCode == "en" ? nil : .autoupdatingCurrent + + var allowedScopes: PlacemarkScope = .all + allowedScopes.remove(.postalCode) + + forwardGeocodeOptions.allowedScopes = allowedScopes + forwardGeocodeOptions.maximumResultCount = 10 + forwardGeocodeOptions.includesRoutableLocations = true + + Geocoder.shared.geocode(forwardGeocodeOptions, + completionHandler: { [weak self] (placemarks, attribution, error) in + guard let self = self else { + completionHandler([]) + return + } + + guard let placemarks = placemarks else { + completionHandler(self.searchResults(with: items, limit: limit)) + return + } + + let navigationGeocodedPlacemarks = placemarks.map { + NavigationGeocodedPlacemark(title: $0.formattedName, + subtitle: $0.address, + location: $0.location, + routableLocations: $0.routableLocations) + } + + let results = navigationGeocodedPlacemarks.map { $0.listItem() } + items.append(contentsOf: results) + completionHandler(self.searchResults(with: results, limit: limit)) + }) + } else { + completionHandler(self.searchResults(with: items, limit: limit)) + } + } + + func searchTemplate(_ searchTemplate: CPSearchTemplate, + selectedResult item: CPListItem, + completionHandler: @escaping () -> Void) { + guard let userInfo = item.userInfo as? [String: Any], + let placemark = userInfo[CarPlaySearchController.CarPlayGeocodedPlacemarkKey] as? NavigationGeocodedPlacemark, + let location = placemark.routableLocations?.first ?? placemark.location else { + completionHandler() + return + } + + recentItems.add(RecentItem(placemark)) + recentItems.save() + + let destinationWaypoint = Waypoint(location: location, + heading: nil, + name: placemark.title) + previewRoutes(to: destinationWaypoint, completionHandler: completionHandler) + } +} diff --git a/CarPlayExample/AppDelegate.swift b/CarPlayExample/AppDelegate.swift index ea295b90..3324f3d8 100644 --- a/CarPlayExample/AppDelegate.swift +++ b/CarPlayExample/AppDelegate.swift @@ -10,8 +10,15 @@ class AppDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - @available(iOS 12.0, *) lazy var carPlayManager: CarPlayManager = CarPlayManager(styles: [CustomStyle()]) + + lazy var carPlaySearchController: CarPlaySearchController = CarPlaySearchController() + + lazy var recentSearchItems: [CPListItem]? = [] + + var recentItems: [RecentItem] = RecentItem.loadDefaults() + + var recentSearchText: String? = "" } // MARK: - UIApplicationDelegate methods @@ -28,6 +35,7 @@ extension AppDelegate: UIApplicationDelegate { configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { if connectingSceneSession.role == .carTemplateApplication { + carPlaySearchController.delegate = self return UISceneConfiguration(name: "CarPlay Configuration", sessionRole: connectingSceneSession.role) } @@ -36,208 +44,3 @@ extension AppDelegate: UIApplicationDelegate { sessionRole: connectingSceneSession.role) } } - -// MARK: - CPTemplateApplicationSceneDelegate methods - -extension AppDelegate: CPTemplateApplicationSceneDelegate { - - func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, - didConnect interfaceController: CPInterfaceController, - to window: CPWindow) { - guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } - - appDelegate.carPlayManager.delegate = appDelegate - - appDelegate.carPlayManager.application(UIApplication.shared, - didConnectCarInterfaceController: interfaceController, - to: window) - - appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, - didConnectCarInterfaceController: interfaceController, - to: window) - } - - func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, - didDisconnect interfaceController: CPInterfaceController, - from window: CPWindow) { - guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } - - appDelegate.carPlayManager.delegate = nil - - appDelegate.carPlayManager.application(UIApplication.shared, - didDisconnectCarInterfaceController: interfaceController, - from: window) - - appDelegate.carPlayManager.templateApplicationScene(templateApplicationScene, - didDisconnectCarInterfaceController: interfaceController, - from: window) - } -} - -// MARK: - CarPlayManagerDelegate methods - -extension AppDelegate: CarPlayManagerDelegate { - - func carPlayManager(_ carPlayManager: CarPlayManager, - leadingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, - in carPlayTemplate: CPTemplate, - for activity: CarPlayActivity) -> [CPBarButton]? { - switch activity { - - case .browsing: - break - - case .panningInBrowsingMode: - break - - case .previewing: - break - - case .navigating: - break - } - - return [] - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - trailingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, - in carPlayTemplate: CPTemplate, - for activity: CarPlayActivity) -> [CPBarButton]? { - switch activity { - - case .browsing: - break - - case .panningInBrowsingMode: - break - - case .previewing: - break - - case .navigating: - return [carPlayManager.exitButton] - } - - return [] - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - mapButtonsCompatibleWith traitCollection: UITraitCollection, - in carPlayTemplate: CPTemplate, - for activity: CarPlayActivity) -> [CPMapButton]? { - switch activity { - - case .browsing: - break - - case .panningInBrowsingMode: - break - - case .previewing: - break - - case .navigating: - break - } - - return [] - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - didFailToFetchRouteBetween waypoints: [Waypoint]?, - options: RouteOptions, - error: DirectionsError) -> CPNavigationAlert? { - let alertAction = CPAlertAction(title: "Dismiss", style: .default, handler: { _ in }) - - let navigationAlert = CPNavigationAlert(titleVariants: ["Failed to fetch"], - subtitleVariants: nil, - image: nil, - primaryAction: alertAction, - secondaryAction: nil, - duration: 2.5) - - return navigationAlert - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - willPreview trip: CPTrip) -> CPTrip { - return trip - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - willPreview trip: CPTrip, - with previewTextConfiguration: CPTripPreviewTextConfiguration) -> CPTripPreviewTextConfiguration { - return previewTextConfiguration - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - selectedPreviewFor trip: CPTrip, - using routeChoice: CPRouteChoice) { - - } - - func carPlayManager(_ carPlayManager: CarPlayManager, - didBeginNavigationWith service: NavigationService) { - - } - - // Delegate method, which is called after ending active-guidance navigation session and dismissing - // `CarPlayNavigationViewController`. - func carPlayManagerDidEndNavigation(_ carPlayManager: CarPlayManager) { - let alertAction = CPAlertAction(title: "OK", - style: .default, - handler: { [weak self] _ in - self?.carPlayManager.interfaceController?.dismissTemplate(animated: true) - }) - - let alertTemplate = CPAlertTemplate(titleVariants: ["Did end active-guidance navigation."], - actions: [alertAction]) - - carPlayManager.interfaceController?.presentTemplate(alertTemplate, animated: true) - } - - // Delegate method, which allows to show `CPActionSheetTemplate` or `CPAlertTemplate` - // after arriving to the specific `Waypoint`. - func carPlayManager(_ carPlayManager: CarPlayManager, - shouldPresentArrivalUIFor waypoint: Waypoint) -> Bool { - return true - } - - // Delegate method, which provides the ability to disable the idle timer to avert system sleep. - func carPlayManagerShouldDisableIdleTimer(_ carPlayManager: CarPlayManager) -> Bool { - return true - } - - // Delegate method, which is called right after starting active-guidance navigation and presenting - // `CarPlayNavigationViewController`. - func carPlayManager(_ carPlayManager: CarPlayManager, - didPresent navigationViewController: CarPlayNavigationViewController) { - let alertAction = CPAlertAction(title: "OK", - style: .default, - handler: { [weak self] _ in - self?.carPlayManager.interfaceController?.dismissTemplate(animated: true) - }) - - let alertTemplate = CPAlertTemplate(titleVariants: ["Did present CarPlayNavigationViewController."], - actions: [alertAction]) - - carPlayManager.interfaceController?.presentTemplate(alertTemplate, animated: true) - } - - // Delegate method, which allows to modify final destination annotation whenever its added to - // `CarPlayMapViewController` or `CarPlayNavigationViewController`. - func carPlayManager(_ carPlayManager: CarPlayManager, - didAdd finalDestinationAnnotation: PointAnnotation, - to parentViewController: UIViewController, - pointAnnotationManager: PointAnnotationManager) { - var finalDestinationAnnotation = finalDestinationAnnotation - if let image = UIImage(named: "marker") { - finalDestinationAnnotation.image = PointAnnotation.Image.custom(image: image, name: "marker") - } else { - finalDestinationAnnotation.image = .default - } - - pointAnnotationManager.syncAnnotations([finalDestinationAnnotation]) - } -} diff --git a/Navigation-Examples.xcodeproj/project.pbxproj b/Navigation-Examples.xcodeproj/project.pbxproj index cb5d7c12..ef8e7048 100644 --- a/Navigation-Examples.xcodeproj/project.pbxproj +++ b/Navigation-Examples.xcodeproj/project.pbxproj @@ -28,6 +28,9 @@ 8A96379C2492B366008DEF2A /* Route-Deserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */; }; 8A96379D2492B366008DEF2A /* route.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A96379B2492B366008DEF2A /* route.json */; }; 8AB316AD26BB0BAF00C3AC76 /* CustomStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AB316AC26BB0BAE00C3AC76 /* CustomStyle.swift */; }; + 8AB316B226BC870B00C3AC76 /* AppDelegate+CarPlayManagerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AB316B126BC870B00C3AC76 /* AppDelegate+CarPlayManagerDelegate.swift */; }; + 8AB316B426BC876700C3AC76 /* AppDelegate+CarPlaySearchControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AB316B326BC876700C3AC76 /* AppDelegate+CarPlaySearchControllerDelegate.swift */; }; + 8AB316B626BC87D000C3AC76 /* AppDelegate+CPTemplateApplicationSceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AB316B526BC87D000C3AC76 /* AppDelegate+CPTemplateApplicationSceneDelegate.swift */; }; 8AC9129D2494106100B6941E /* Route-Initialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC9129C2494106100B6941E /* Route-Initialization.swift */; }; 8AE033222628EDFF000E7145 /* Route-Lines-Styling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE033212628EDFF000E7145 /* Route-Lines-Styling.swift */; }; 8DF510741FEB08F70049DB9C /* Embedded-Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DF510731FEB08F70049DB9C /* Embedded-Navigation.swift */; }; @@ -90,6 +93,9 @@ 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Deserialization.swift"; sourceTree = ""; }; 8A96379B2492B366008DEF2A /* route.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = route.json; sourceTree = ""; }; 8AB316AC26BB0BAE00C3AC76 /* CustomStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStyle.swift; sourceTree = ""; }; + 8AB316B126BC870B00C3AC76 /* AppDelegate+CarPlayManagerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+CarPlayManagerDelegate.swift"; sourceTree = ""; }; + 8AB316B326BC876700C3AC76 /* AppDelegate+CarPlaySearchControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+CarPlaySearchControllerDelegate.swift"; sourceTree = ""; }; + 8AB316B526BC87D000C3AC76 /* AppDelegate+CPTemplateApplicationSceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+CPTemplateApplicationSceneDelegate.swift"; sourceTree = ""; }; 8AC9129C2494106100B6941E /* Route-Initialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Route-Initialization.swift"; sourceTree = ""; }; 8AD2F2132489B5C800F81353 /* apply-mapbox-access-token.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "apply-mapbox-access-token.sh"; sourceTree = ""; }; 8AE033212628EDFF000E7145 /* Route-Lines-Styling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Lines-Styling.swift"; sourceTree = ""; }; @@ -188,6 +194,9 @@ children = ( 8AB316AC26BB0BAE00C3AC76 /* CustomStyle.swift */, 8A3F6B1D26B09C48009EE612 /* AppDelegate.swift */, + 8AB316B126BC870B00C3AC76 /* AppDelegate+CarPlayManagerDelegate.swift */, + 8AB316B526BC87D000C3AC76 /* AppDelegate+CPTemplateApplicationSceneDelegate.swift */, + 8AB316B326BC876700C3AC76 /* AppDelegate+CarPlaySearchControllerDelegate.swift */, 8A3F6B1F26B09C48009EE612 /* SceneDelegate.swift */, 8A3F6B2126B09C48009EE612 /* ViewController.swift */, 8A3F6B2326B09C48009EE612 /* Main.storyboard */, @@ -535,7 +544,8 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Navigation-Examples/Pods-Navigation-Examples-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework", - "${BUILT_PRODUCTS_DIR}/MapboxDirections/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxDirections-pre/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxGeocoder.swift/MapboxGeocoder.framework", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", "${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework", @@ -551,6 +561,7 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxGeocoder.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework", @@ -620,6 +631,7 @@ "${PODS_ROOT}/Target Support Files/Pods-CarPlayExample/Pods-CarPlayExample-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework", "${BUILT_PRODUCTS_DIR}/MapboxDirections-pre/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxGeocoder.swift/MapboxGeocoder.framework", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", "${BUILT_PRODUCTS_DIR}/MapboxSpeech-pre/MapboxSpeech.framework", @@ -635,6 +647,7 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxGeocoder.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework", @@ -730,7 +743,8 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-DocsCode/Pods-DocsCode-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework", - "${BUILT_PRODUCTS_DIR}/MapboxDirections/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxDirections-pre/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxGeocoder.swift/MapboxGeocoder.framework", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", "${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework", @@ -746,6 +760,7 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxGeocoder.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework", @@ -769,9 +784,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8AB316B426BC876700C3AC76 /* AppDelegate+CarPlaySearchControllerDelegate.swift in Sources */, 8AB316AD26BB0BAF00C3AC76 /* CustomStyle.swift in Sources */, 8A3F6B2226B09C48009EE612 /* ViewController.swift in Sources */, + 8AB316B226BC870B00C3AC76 /* AppDelegate+CarPlayManagerDelegate.swift in Sources */, 8A3F6B1E26B09C48009EE612 /* AppDelegate.swift in Sources */, + 8AB316B626BC87D000C3AC76 /* AppDelegate+CPTemplateApplicationSceneDelegate.swift in Sources */, 8A3F6B2026B09C48009EE612 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Podfile b/Podfile index 841ec881..2f9af9c9 100644 --- a/Podfile +++ b/Podfile @@ -5,6 +5,7 @@ use_frameworks! pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/car-play-refactoring' pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/car-play-refactoring' +pod 'MapboxGeocoder.swift', '~> 0.14' target 'Navigation-Examples' do end diff --git a/Podfile.lock b/Podfile.lock index 197d6ca0..01808f09 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -10,6 +10,7 @@ PODS: - MapboxDirections-pre (2.0.0-beta.7): - Polyline (~> 5.0) - Turf (~> 2.0.0-beta.1) + - MapboxGeocoder.swift (0.14.0) - MapboxMaps (10.0.0-rc.5): - MapboxCommon (= 16.0.0) - MapboxCoreMaps (= 10.0.0-rc.5) @@ -31,6 +32,7 @@ PODS: DEPENDENCIES: - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) + - MapboxGeocoder.swift (~> 0.14) - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) SPEC REPOS: @@ -58,10 +60,10 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 884f7282b64a655f8fba2e2abec339d795024b19 + :commit: c49aea5f827f2c989d1dde59df0b2b4f0ea80a69 :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 884f7282b64a655f8fba2e2abec339d795024b19 + :commit: c49aea5f827f2c989d1dde59df0b2b4f0ea80a69 :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: @@ -69,6 +71,7 @@ SPEC CHECKSUMS: MapboxCoreMaps: 0aa69120a787fce64eb66ea1068a707fbc0a3c8b MapboxCoreNavigation: d79eb0b5d0d35c9ebaadbc7ed9bc07faff58c0e4 MapboxDirections-pre: 929a1a63063c9c97f88b793e70143d547eaed293 + MapboxGeocoder.swift: a288e92ec13fbd65bbdfd7c54c61b0e80d19e734 MapboxMaps: b966939712943f6af126aadf73b82b43c0535020 MapboxMobileEvents: 9775eb995e06cc3ea10894bf6ab111683c8e73e7 MapboxNavigation: 4cd5a5c46c9ec186f46b9509f85e5fe0c8782221 @@ -78,6 +81,6 @@ SPEC CHECKSUMS: Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 Turf: 8851f941a6e6476ea200bf057d31cf21b2418467 -PODFILE CHECKSUM: cdba1559ae133c7fa27daf8adf70e8089ac9c090 +PODFILE CHECKSUM: a247a3ff0698b3c2e1e7ba58d8d6744eed13967c COCOAPODS: 1.10.1 From 45c830c9886b59cf8ae01bfaa8276fb0073f29ab Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Thu, 12 Aug 2021 13:17:28 -0700 Subject: [PATCH 10/16] Update. --- Podfile.lock | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 01808f09..7ed2de0e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,34 +1,34 @@ PODS: - - MapboxCommon (16.0.0) - - MapboxCoreMaps (10.0.0-rc.5): - - MapboxCommon (~> 16.0.0) - - MapboxCoreNavigation (2.0.0-beta.21): - - MapboxDirections-pre (= 2.0.0-beta.7) + - MapboxCommon (16.2.0) + - MapboxCoreMaps (10.0.0-rc.6): + - MapboxCommon (~> 16.2) + - MapboxCoreNavigation (2.0.0-beta.22): + - MapboxDirections-pre (= 2.0.0-beta.8) - MapboxMobileEvents (~> 1.0.0) - - MapboxNavigationNative (~> 60.0) - - Turf (= 2.0.0-beta.1) - - MapboxDirections-pre (2.0.0-beta.7): + - MapboxNavigationNative (~> 62.0) + - Turf (= 2.0.0-rc.1) + - MapboxDirections-pre (2.0.0-beta.8): - Polyline (~> 5.0) - - Turf (~> 2.0.0-beta.1) + - Turf (~> 2.0.0-rc.1) - MapboxGeocoder.swift (0.14.0) - - MapboxMaps (10.0.0-rc.5): - - MapboxCommon (= 16.0.0) - - MapboxCoreMaps (= 10.0.0-rc.5) + - MapboxMaps (10.0.0-rc.6): + - MapboxCommon (= 16.2.0) + - MapboxCoreMaps (= 10.0.0-rc.6) - MapboxMobileEvents (= 1.0.2) - - Turf (= 2.0.0-beta.1) + - Turf (= 2.0.0-rc.1) - MapboxMobileEvents (1.0.2) - - MapboxNavigation (2.0.0-beta.21): - - MapboxCoreNavigation (= 2.0.0-beta.21) - - MapboxMaps (= 10.0.0-rc.5) + - MapboxNavigation (2.0.0-beta.22): + - MapboxCoreNavigation (= 2.0.0-beta.22) + - MapboxMaps (= 10.0.0-rc.6) - MapboxMobileEvents (~> 1.0.0) - MapboxSpeech-pre (= 2.0.0-alpha.1) - Solar-dev (~> 3.0) - - MapboxNavigationNative (60.0.0): - - MapboxCommon (~> 16.0) + - MapboxNavigationNative (62.0.0): + - MapboxCommon (~> 16.2) - MapboxSpeech-pre (2.0.0-alpha.1) - Polyline (5.0.2) - Solar-dev (3.0.1) - - Turf (2.0.0-beta.1) + - Turf (2.0.0-rc.1) DEPENDENCIES: - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) @@ -60,26 +60,26 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: c49aea5f827f2c989d1dde59df0b2b4f0ea80a69 + :commit: 566298ed79f69ba0b6dc9ba1baa70993aa39d89d :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: c49aea5f827f2c989d1dde59df0b2b4f0ea80a69 + :commit: 566298ed79f69ba0b6dc9ba1baa70993aa39d89d :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: - MapboxCommon: 44430838b703d0b1b5032f3c8501c60c7c70d3cc - MapboxCoreMaps: 0aa69120a787fce64eb66ea1068a707fbc0a3c8b - MapboxCoreNavigation: d79eb0b5d0d35c9ebaadbc7ed9bc07faff58c0e4 - MapboxDirections-pre: 929a1a63063c9c97f88b793e70143d547eaed293 + MapboxCommon: 4fd3d1f439655efbe0108ecd45406924054071aa + MapboxCoreMaps: 045ecad9bb77931e221edc122a66848d778ea87c + MapboxCoreNavigation: 9e36092a119a6908582f5c0597af4a8e04e36411 + MapboxDirections-pre: ac837a27e6f023ea9abcc00dff53d17b080023d2 MapboxGeocoder.swift: a288e92ec13fbd65bbdfd7c54c61b0e80d19e734 - MapboxMaps: b966939712943f6af126aadf73b82b43c0535020 + MapboxMaps: de9ac5e180c0a5957619a8642b96767108d2f9b4 MapboxMobileEvents: 9775eb995e06cc3ea10894bf6ab111683c8e73e7 - MapboxNavigation: 4cd5a5c46c9ec186f46b9509f85e5fe0c8782221 - MapboxNavigationNative: 9f49640451eca820667c657475d412e1c990d41b + MapboxNavigation: 02d5942d2964a79aec17a251a7e9f688d27ee510 + MapboxNavigationNative: 1c91a4ca1a963a17299640a89d88ce1a97a77f09 MapboxSpeech-pre: aeb16de604d07ceb4195150c3359d5401bb298e6 Polyline: fce41d72e1146c41c6d081f7656827226f643dff Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 - Turf: 8851f941a6e6476ea200bf057d31cf21b2418467 + Turf: 4efd14674a1a2f9527b7c0aadde8003a7b73b1be PODFILE CHECKSUM: a247a3ff0698b3c2e1e7ba58d8d6744eed13967c From dd66bbf9680c55e9333cf2d0d54f214b2073a3c4 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Thu, 19 Aug 2021 18:04:00 -0700 Subject: [PATCH 11/16] Update. --- Podfile.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 7ed2de0e..becc3d25 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -2,10 +2,10 @@ PODS: - MapboxCommon (16.2.0) - MapboxCoreMaps (10.0.0-rc.6): - MapboxCommon (~> 16.2) - - MapboxCoreNavigation (2.0.0-beta.22): + - MapboxCoreNavigation (2.0.0-beta.23): - MapboxDirections-pre (= 2.0.0-beta.8) - MapboxMobileEvents (~> 1.0.0) - - MapboxNavigationNative (~> 62.0) + - MapboxNavigationNative (~> 63.0) - Turf (= 2.0.0-rc.1) - MapboxDirections-pre (2.0.0-beta.8): - Polyline (~> 5.0) @@ -17,13 +17,13 @@ PODS: - MapboxMobileEvents (= 1.0.2) - Turf (= 2.0.0-rc.1) - MapboxMobileEvents (1.0.2) - - MapboxNavigation (2.0.0-beta.22): - - MapboxCoreNavigation (= 2.0.0-beta.22) + - MapboxNavigation (2.0.0-beta.23): + - MapboxCoreNavigation (= 2.0.0-beta.23) - MapboxMaps (= 10.0.0-rc.6) - MapboxMobileEvents (~> 1.0.0) - MapboxSpeech-pre (= 2.0.0-alpha.1) - Solar-dev (~> 3.0) - - MapboxNavigationNative (62.0.0): + - MapboxNavigationNative (63.1.0): - MapboxCommon (~> 16.2) - MapboxSpeech-pre (2.0.0-alpha.1) - Polyline (5.0.2) @@ -60,22 +60,22 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 566298ed79f69ba0b6dc9ba1baa70993aa39d89d + :commit: 5c35d7000cd39ce116da627341732a5b1df6b74c :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 566298ed79f69ba0b6dc9ba1baa70993aa39d89d + :commit: 5c35d7000cd39ce116da627341732a5b1df6b74c :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: MapboxCommon: 4fd3d1f439655efbe0108ecd45406924054071aa MapboxCoreMaps: 045ecad9bb77931e221edc122a66848d778ea87c - MapboxCoreNavigation: 9e36092a119a6908582f5c0597af4a8e04e36411 + MapboxCoreNavigation: 4184e9283aa8654d03d900dbf1813af6c1697b6e MapboxDirections-pre: ac837a27e6f023ea9abcc00dff53d17b080023d2 MapboxGeocoder.swift: a288e92ec13fbd65bbdfd7c54c61b0e80d19e734 MapboxMaps: de9ac5e180c0a5957619a8642b96767108d2f9b4 MapboxMobileEvents: 9775eb995e06cc3ea10894bf6ab111683c8e73e7 - MapboxNavigation: 02d5942d2964a79aec17a251a7e9f688d27ee510 - MapboxNavigationNative: 1c91a4ca1a963a17299640a89d88ce1a97a77f09 + MapboxNavigation: cd28ef804d6025d23ad9d3a935ab0273f7163dec + MapboxNavigationNative: 8d81ec51c9e76da2a9b7a0106eb8b526042d7c81 MapboxSpeech-pre: aeb16de604d07ceb4195150c3359d5401bb298e6 Polyline: fce41d72e1146c41c6d081f7656827226f643dff Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 From c35e61b28e4590879ce3f6bc1adb589a28c7089a Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Thu, 19 Aug 2021 18:04:22 -0700 Subject: [PATCH 12/16] Update. --- CarPlayExample/CustomStyle.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/CarPlayExample/CustomStyle.swift b/CarPlayExample/CustomStyle.swift index b9966741..1a413652 100644 --- a/CarPlayExample/CustomStyle.swift +++ b/CarPlayExample/CustomStyle.swift @@ -7,6 +7,7 @@ class CustomStyle: NightStyle { super.init() mapStyleURL = URL(string: StyleURI.dark.rawValue)! + previewMapStyleURL = URL(string: StyleURI.dark.rawValue)! } override func apply() { From 8b41af7c739be4a995fddcc0bb4d97ead31b1f82 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 12 Oct 2021 12:18:50 -0700 Subject: [PATCH 13/16] Update. --- Podfile | 4 +-- Podfile.lock | 72 ++++++++++++++++++++++++++-------------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Podfile b/Podfile index 2f9af9c9..64f9f3e5 100644 --- a/Podfile +++ b/Podfile @@ -3,8 +3,8 @@ install! 'cocoapods', :warn_for_unused_master_specs_repo => false platform :ios, '11.0' use_frameworks! -pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/car-play-refactoring' -pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/car-play-refactoring' +pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'main' +pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'main' pod 'MapboxGeocoder.swift', '~> 0.14' target 'Navigation-Examples' do diff --git a/Podfile.lock b/Podfile.lock index becc3d25..b964a212 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,39 +1,39 @@ PODS: - - MapboxCommon (16.2.0) - - MapboxCoreMaps (10.0.0-rc.6): - - MapboxCommon (~> 16.2) - - MapboxCoreNavigation (2.0.0-beta.23): - - MapboxDirections-pre (= 2.0.0-beta.8) + - MapboxCommon (19.0.0) + - MapboxCoreMaps (10.0.0-rc.9.1): + - MapboxCommon (~> 19.0) + - MapboxCoreNavigation (2.0.0-rc.5): + - MapboxDirections-pre (= 2.0.0-rc.3) - MapboxMobileEvents (~> 1.0.0) - - MapboxNavigationNative (~> 63.0) + - MapboxNavigationNative (~> 68.0) - Turf (= 2.0.0-rc.1) - - MapboxDirections-pre (2.0.0-beta.8): + - MapboxDirections-pre (2.0.0-rc.3): - Polyline (~> 5.0) - Turf (~> 2.0.0-rc.1) - MapboxGeocoder.swift (0.14.0) - - MapboxMaps (10.0.0-rc.6): - - MapboxCommon (= 16.2.0) - - MapboxCoreMaps (= 10.0.0-rc.6) - - MapboxMobileEvents (= 1.0.2) + - MapboxMaps (10.0.0-rc.9): + - MapboxCommon (= 19.0.0) + - MapboxCoreMaps (= 10.0.0-rc.9.1) + - MapboxMobileEvents (= 1.0.4) - Turf (= 2.0.0-rc.1) - - MapboxMobileEvents (1.0.2) - - MapboxNavigation (2.0.0-beta.23): - - MapboxCoreNavigation (= 2.0.0-beta.23) - - MapboxMaps (= 10.0.0-rc.6) + - MapboxMobileEvents (1.0.4) + - MapboxNavigation (2.0.0-rc.5): + - MapboxCoreNavigation (= 2.0.0-rc.5) + - MapboxMaps (= 10.0.0-rc.9) - MapboxMobileEvents (~> 1.0.0) - - MapboxSpeech-pre (= 2.0.0-alpha.1) + - MapboxSpeech-pre (= 2.0.0-rc.1) - Solar-dev (~> 3.0) - - MapboxNavigationNative (63.1.0): - - MapboxCommon (~> 16.2) - - MapboxSpeech-pre (2.0.0-alpha.1) + - MapboxNavigationNative (68.0.0): + - MapboxCommon (~> 19.0) + - MapboxSpeech-pre (2.0.0-rc.1) - Polyline (5.0.2) - Solar-dev (3.0.1) - Turf (2.0.0-rc.1) DEPENDENCIES: - - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) + - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) - MapboxGeocoder.swift (~> 0.14) - - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/car-play-refactoring`) + - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) SPEC REPOS: trunk: @@ -52,35 +52,35 @@ SPEC REPOS: EXTERNAL SOURCES: MapboxCoreNavigation: - :branch: maxim/car-play-refactoring + :branch: main :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :branch: maxim/car-play-refactoring + :branch: main :git: https://github.com/mapbox/mapbox-navigation-ios.git CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 5c35d7000cd39ce116da627341732a5b1df6b74c + :commit: 19b97cec6f618f78fad39a14150a03f429e7f287 :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 5c35d7000cd39ce116da627341732a5b1df6b74c + :commit: 19b97cec6f618f78fad39a14150a03f429e7f287 :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: - MapboxCommon: 4fd3d1f439655efbe0108ecd45406924054071aa - MapboxCoreMaps: 045ecad9bb77931e221edc122a66848d778ea87c - MapboxCoreNavigation: 4184e9283aa8654d03d900dbf1813af6c1697b6e - MapboxDirections-pre: ac837a27e6f023ea9abcc00dff53d17b080023d2 + MapboxCommon: c87a136d3d58ed9430adae9d8eab7c00705f8dc5 + MapboxCoreMaps: 5e184ca5480b03bbd42789d1c65042af44c2bb32 + MapboxCoreNavigation: 93288356921eb3bb07c8524016d7e436c274d362 + MapboxDirections-pre: b4b3f2921a9c255088bd595d610ab3e997660eab MapboxGeocoder.swift: a288e92ec13fbd65bbdfd7c54c61b0e80d19e734 - MapboxMaps: de9ac5e180c0a5957619a8642b96767108d2f9b4 - MapboxMobileEvents: 9775eb995e06cc3ea10894bf6ab111683c8e73e7 - MapboxNavigation: cd28ef804d6025d23ad9d3a935ab0273f7163dec - MapboxNavigationNative: 8d81ec51c9e76da2a9b7a0106eb8b526042d7c81 - MapboxSpeech-pre: aeb16de604d07ceb4195150c3359d5401bb298e6 + MapboxMaps: 49dfea96f19cc40be82ce299de9883f50a624091 + MapboxMobileEvents: 23e673d72ba9a7b4bd20dd20853f323d70efcb22 + MapboxNavigation: 6b9e531fa0f8e64b03197eb62c70588979755796 + MapboxNavigationNative: 0bc4f99903a513cd1450336a8d34d5e006528869 + MapboxSpeech-pre: c2739e843762ac6b222fb7132ac71903aa750af3 Polyline: fce41d72e1146c41c6d081f7656827226f643dff Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 Turf: 4efd14674a1a2f9527b7c0aadde8003a7b73b1be -PODFILE CHECKSUM: a247a3ff0698b3c2e1e7ba58d8d6744eed13967c +PODFILE CHECKSUM: 7935612098dd9561da75555944a41c57f5e5f67c -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 From 8563e865493e9843f1c540d1e3362bde2e4f9dd7 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 12 Oct 2021 12:29:54 -0700 Subject: [PATCH 14/16] Update. --- CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift b/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift index e077f07d..d255c9e7 100644 --- a/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift +++ b/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift @@ -180,7 +180,7 @@ extension AppDelegate: CarPlayManagerDelegate { finalDestinationAnnotation.image = .default } - pointAnnotationManager.syncAnnotations([finalDestinationAnnotation]) + pointAnnotationManager.annotations = [finalDestinationAnnotation] } func carPlayManager(_ carPlayManager: CarPlayManager, From 857402f183e9d0773625fc567e0d810c84452af5 Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 14 Dec 2021 13:26:13 -0600 Subject: [PATCH 15/16] Update. --- Navigation-Examples.xcodeproj/project.pbxproj | 2 +- Podfile.lock | 80 +++++++++---------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/Navigation-Examples.xcodeproj/project.pbxproj b/Navigation-Examples.xcodeproj/project.pbxproj index ef8e7048..bbe14db6 100644 --- a/Navigation-Examples.xcodeproj/project.pbxproj +++ b/Navigation-Examples.xcodeproj/project.pbxproj @@ -634,7 +634,7 @@ "${BUILT_PRODUCTS_DIR}/MapboxGeocoder.swift/MapboxGeocoder.framework", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", - "${BUILT_PRODUCTS_DIR}/MapboxSpeech-pre/MapboxSpeech.framework", + "${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework", "${BUILT_PRODUCTS_DIR}/Polyline/Polyline.framework", "${BUILT_PRODUCTS_DIR}/Solar-dev/Solar.framework", "${BUILT_PRODUCTS_DIR}/Turf/Turf.framework", diff --git a/Podfile.lock b/Podfile.lock index b964a212..a1fa32d6 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,34 +1,33 @@ PODS: - - MapboxCommon (19.0.0) - - MapboxCoreMaps (10.0.0-rc.9.1): - - MapboxCommon (~> 19.0) - - MapboxCoreNavigation (2.0.0-rc.5): - - MapboxDirections-pre (= 2.0.0-rc.3) - - MapboxMobileEvents (~> 1.0.0) - - MapboxNavigationNative (~> 68.0) - - Turf (= 2.0.0-rc.1) - - MapboxDirections-pre (2.0.0-rc.3): + - MapboxCommon (21.0.0-rc.2) + - MapboxCoreMaps (10.2.0-rc.1): + - MapboxCommon (~> 21.0.0-rc) + - MapboxCoreNavigation (2.2.0-alpha.2): + - MapboxDirections-pre (~> 2.2.0-alpha.1) + - MapboxMobileEvents (~> 1.0) + - MapboxNavigationNative (~> 81.0) + - MapboxDirections-pre (2.2.0-alpha.1): - Polyline (~> 5.0) - - Turf (~> 2.0.0-rc.1) + - Turf (~> 2.0) - MapboxGeocoder.swift (0.14.0) - - MapboxMaps (10.0.0-rc.9): - - MapboxCommon (= 19.0.0) - - MapboxCoreMaps (= 10.0.0-rc.9.1) - - MapboxMobileEvents (= 1.0.4) - - Turf (= 2.0.0-rc.1) - - MapboxMobileEvents (1.0.4) - - MapboxNavigation (2.0.0-rc.5): - - MapboxCoreNavigation (= 2.0.0-rc.5) - - MapboxMaps (= 10.0.0-rc.9) - - MapboxMobileEvents (~> 1.0.0) - - MapboxSpeech-pre (= 2.0.0-rc.1) + - MapboxMaps (10.2.0-rc.1): + - MapboxCommon (= 21.0.0-rc.2) + - MapboxCoreMaps (= 10.2.0-rc.1) + - MapboxMobileEvents (= 1.0.6) + - Turf (~> 2.0) + - MapboxMobileEvents (1.0.6) + - MapboxNavigation (2.2.0-alpha.2): + - MapboxCoreNavigation (= 2.2.0-alpha.2) + - MapboxMaps (= 10.2.0-rc.1) + - MapboxMobileEvents (~> 1.0) + - MapboxSpeech (~> 2.0) - Solar-dev (~> 3.0) - - MapboxNavigationNative (68.0.0): - - MapboxCommon (~> 19.0) - - MapboxSpeech-pre (2.0.0-rc.1) + - MapboxNavigationNative (81.0.0): + - MapboxCommon (~> 21.0.0-rc.1) + - MapboxSpeech (2.0.0) - Polyline (5.0.2) - Solar-dev (3.0.1) - - Turf (2.0.0-rc.1) + - Turf (2.1.0) DEPENDENCIES: - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `main`) @@ -39,11 +38,10 @@ SPEC REPOS: trunk: - MapboxCommon - MapboxCoreMaps - - MapboxCoreNavigation - - MapboxDirections + - MapboxDirections-pre + - MapboxGeocoder.swift - MapboxMaps - MapboxMobileEvents - - MapboxNavigation - MapboxNavigationNative - MapboxSpeech - Polyline @@ -60,27 +58,27 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MapboxCoreNavigation: - :commit: 19b97cec6f618f78fad39a14150a03f429e7f287 + :commit: 1ecc321139f3e08780aef7b6ed42f6e272ee2830 :git: https://github.com/mapbox/mapbox-navigation-ios.git MapboxNavigation: - :commit: 19b97cec6f618f78fad39a14150a03f429e7f287 + :commit: 1ecc321139f3e08780aef7b6ed42f6e272ee2830 :git: https://github.com/mapbox/mapbox-navigation-ios.git SPEC CHECKSUMS: - MapboxCommon: c87a136d3d58ed9430adae9d8eab7c00705f8dc5 - MapboxCoreMaps: 5e184ca5480b03bbd42789d1c65042af44c2bb32 - MapboxCoreNavigation: 93288356921eb3bb07c8524016d7e436c274d362 - MapboxDirections-pre: b4b3f2921a9c255088bd595d610ab3e997660eab + MapboxCommon: 71271abe50982d05572d8c4466d152dd1449561c + MapboxCoreMaps: 03b1545fbcbd46fb7b4a993b12155a473a4b030d + MapboxCoreNavigation: 4db3436cc86cd5a0427a99ea556065b1e5a6aa7f + MapboxDirections-pre: 5a16b832f3ec209ade28565ee7b9c1a69b75c2d6 MapboxGeocoder.swift: a288e92ec13fbd65bbdfd7c54c61b0e80d19e734 - MapboxMaps: 49dfea96f19cc40be82ce299de9883f50a624091 - MapboxMobileEvents: 23e673d72ba9a7b4bd20dd20853f323d70efcb22 - MapboxNavigation: 6b9e531fa0f8e64b03197eb62c70588979755796 - MapboxNavigationNative: 0bc4f99903a513cd1450336a8d34d5e006528869 - MapboxSpeech-pre: c2739e843762ac6b222fb7132ac71903aa750af3 + MapboxMaps: b6c65b42c17bda42de91a33bedcb9b8e2cafd83e + MapboxMobileEvents: 14d7ac3ee95b4142c4fec2205dfd48ff453e8871 + MapboxNavigation: 7c583658832b560091b56e15283af05cdaf01748 + MapboxNavigationNative: e07367a43b31a7aaf7a54fc717ee3c2f4561203a + MapboxSpeech: e4ed02984444b6373374c72c369edaf045cc490c Polyline: fce41d72e1146c41c6d081f7656827226f643dff Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 - Turf: 4efd14674a1a2f9527b7c0aadde8003a7b73b1be + Turf: d1220730a00b50a9fb5862c1fb6a5dd698c9e367 -PODFILE CHECKSUM: 7935612098dd9561da75555944a41c57f5e5f67c +PODFILE CHECKSUM: 11a4d6e5f78652e7052548bf1e61f7f5e2b7f9e8 COCOAPODS: 1.11.2 From 3f32420f24a6d526e0fdd898bdadfb02a56470bd Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Tue, 14 Dec 2021 13:30:48 -0600 Subject: [PATCH 16/16] Update. --- .../AppDelegate+CarPlayManagerDelegate.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift b/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift index d255c9e7..0545eb00 100644 --- a/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift +++ b/CarPlayExample/AppDelegate+CarPlayManagerDelegate.swift @@ -28,6 +28,9 @@ extension AppDelegate: CarPlayManagerDelegate { case .panningInBrowsingMode: break + case .panningInNavigationMode: + break + case .previewing: break @@ -52,6 +55,9 @@ extension AppDelegate: CarPlayManagerDelegate { case .panningInBrowsingMode: break + case .panningInNavigationMode: + break + case .previewing: break @@ -76,6 +82,9 @@ extension AppDelegate: CarPlayManagerDelegate { case .panningInBrowsingMode: break + case .panningInNavigationMode: + break + case .previewing: break @@ -175,9 +184,10 @@ extension AppDelegate: CarPlayManagerDelegate { pointAnnotationManager: PointAnnotationManager) { var finalDestinationAnnotation = finalDestinationAnnotation if let image = UIImage(named: "marker") { - finalDestinationAnnotation.image = PointAnnotation.Image.custom(image: image, name: "marker") + finalDestinationAnnotation.image = .init(image: image, name: "marker") } else { - finalDestinationAnnotation.image = .default + let image = UIImage(named: "default_marker", in: .mapboxNavigation, compatibleWith: nil)! + finalDestinationAnnotation.image = .init(image: image, name: "marker") } pointAnnotationManager.annotations = [finalDestinationAnnotation]