Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Objective-C compatibility; adopt Swift language features #2230

Merged
merged 57 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
14df7b1
WIP: Starting out with a blanket wipe of @objc. 90 build errors.
Sep 16, 2019
87434c6
WIP: Refactoring. Single digit errors.
Sep 20, 2019
717794b
Fixing UnimplementedLogging protocol issues
Sep 20, 2019
91a43c2
Adding stubs for LegacyRouteController
Sep 20, 2019
6016b34
Continuing to churn through this. 142 errors.
Sep 20, 2019
9ac081a
adding defaults for CarPlayManagerDelegate
Sep 20, 2019
6add446
Continuing to go fast. 84 remain.
Sep 20, 2019
8d4bee5
Really whittling it down now. 9 errors remain.
Sep 20, 2019
b055108
Fixing extension issues, can't override from extensions in swift. 5 i…
Sep 20, 2019
903b12e
Moving to proper place in file
Sep 20, 2019
83f3bbe
adding default handling for TopBannerViewControllerDelegate
Sep 20, 2019
b03a9fd
Took care of all remaining issues on first-pass. Ready for second phase.
Sep 20, 2019
9da8da3
Removing OBJ-C example.
Sep 23, 2019
484a320
All build errors fixed. Kobe's Guidance cards are not working, and th…
Sep 23, 2019
ccab3eb
Fixing integration tests with Instruction Cards.
Sep 24, 2019
ed9c2bf
Fixing last remaining test failure.
Sep 24, 2019
e74d9bb
Apparently CI doesn't like the unified logging module. Lets see if we…
Sep 24, 2019
6a5b021
Fixing UserCourseView and some other issues that were causing the CI …
Sep 25, 2019
159664e
Removing Orphaned class.
Sep 25, 2019
98b5a22
Fixing a warning that CI is complaining about
Sep 25, 2019
c1332e1
Replacing janky `delegateIdentifier` property (supposed to tell you w…
Sep 25, 2019
1bf136d
Removing mention of OBJ-C from documentation. Also adding cover.md to…
Sep 26, 2019
05fa803
Replacing all OBJ-C constants and enumerations with swift patterns.
Sep 26, 2019
0aab920
Fixing lingering issues.
Sep 30, 2019
293a0da
Fixed default protocol method implementation visibility
1ec5 Oct 15, 2019
745448d
Getting rid of `Self.` in type extensions, which only works in swift 5.1
Oct 15, 2019
b610d1f
Fixed indentation
1ec5 Oct 16, 2019
37f2c60
Fixed Xcode 10 syntax error
1ec5 Oct 16, 2019
20fb6a0
Rewrote String.md5 for Swift 5 compatibility
1ec5 Oct 16, 2019
512db91
Restored user course view to map view
1ec5 Oct 18, 2019
3dd9c7c
Testing CI Build Failure
Oct 28, 2019
aafc146
PR Comments
Nov 1, 2019
4a0d77b
PR comment: documentation for notification user info keys
Nov 1, 2019
80d6e44
PR Comment: Adding note about unimplemented feature
Nov 1, 2019
02549c4
Updating with better copy
Nov 1, 2019
c1535b1
WIP: adding proper swift error for voice/speech issues
Nov 1, 2019
b92fec8
Implementing swift speech errors
Nov 4, 2019
e659378
There actually aren't any unknown speech errors.
Nov 4, 2019
aaf83d5
Adding documentation and changelog entries
Nov 5, 2019
0e29a77
whoopsie
Nov 5, 2019
20a91b5
Fixing `testDefaultUserInterfaceUsage` test
Nov 5, 2019
b14e936
Adding interface deprecations
Nov 8, 2019
6d36650
Adding testing for `UnimplementedLogging` that _hopefully_ should sat…
Nov 8, 2019
1aa6f21
Final changelog and documentation entries.
Nov 8, 2019
d025291
Taking minh's suggestion to make `userDistanceToManeuverLocation` ini…
Nov 8, 2019
ff2abea
Doh!
Nov 8, 2019
8f7819e
Fixed misleading indentation; removed extraneous blank lines
1ec5 Nov 12, 2019
f6548b6
Fixed documentation comment syntax
1ec5 Nov 12, 2019
73555ac
Fixed documentation comment indentation
1ec5 Nov 12, 2019
4e9b7d6
Apply suggestions from code review
JThramer Nov 13, 2019
93eedcc
Update MapboxNavigation/CarPlayManagerDelegate.swift
JThramer Nov 13, 2019
69220fc
Wrapping up final outstanding issues.
Nov 19, 2019
9147d60
Merge branch 'master' into jerrad/objc-delenda-est
Nov 19, 2019
755e450
Other PR suggestions
Nov 19, 2019
3a7813f
Updating test to reflect new uniquing mechanism on UnimplmenetedLogging.
Nov 20, 2019
0f9ef94
Fixing indendation issue.
Nov 20, 2019
2a1ac22
PR Suggestion: Replace `engine` with `synthesizer`
Nov 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Bench/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

window = UIWindow(frame: UIScreen.main.bounds)

if isRunningTests() {
Expand Down
5 changes: 0 additions & 5 deletions Bench/BenchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ struct Item {
}

class BenchViewController: UITableViewController {

var dataSource = [Section]()
let cellIdentifier = "cellId"

override func viewDidLoad() {

super.viewDidLoad()

tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
Expand Down Expand Up @@ -66,7 +64,6 @@ class BenchViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)
let item = dataSource[indexPath.section].items[indexPath.row]

Expand All @@ -76,7 +73,6 @@ class BenchViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

tableView.deselectRow(at: indexPath, animated: true)

let item = dataSource[indexPath.section].items[indexPath.row]
Expand All @@ -90,7 +86,6 @@ class BenchViewController: UITableViewController {
}

extension BenchViewController: NavigationViewControllerDelegate {

func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) {
navigationController?.popViewController(animated: true)
}
Expand Down
2 changes: 0 additions & 2 deletions Bench/ControlRouteViewController.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import UIKit
import MapboxNavigation


class ControlRouteViewController: NavigationViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

Expand Down
7 changes: 0 additions & 7 deletions BenchTests/BenchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import MapboxDirections
@testable import MapboxNavigation
@testable import Bench


class BenchTests: XCTestCase, CLLocationManagerDelegate {

let token = "deadbeef"

override func setUp() {
Expand All @@ -16,7 +14,6 @@ class BenchTests: XCTestCase, CLLocationManagerDelegate {
}

func testControlRoute1() {

let route = Fixture.route(from: "PipeFittersUnion-FourSeasonsBoston")
let trace = Fixture.locations(from: "PipeFittersUnion-FourSeasonsBoston.trace")

Expand All @@ -33,7 +30,6 @@ class BenchTests: XCTestCase, CLLocationManagerDelegate {
}

func testControlRoute2() {

let route = Fixture.route(from: "DCA-Arboretum")
let trace = Fixture.locations(from: "DCA-Arboretum.trace")

Expand All @@ -50,7 +46,6 @@ class BenchTests: XCTestCase, CLLocationManagerDelegate {
}

func navigationViewController(route: Route, locationManager: ReplayLocationManager) -> NavigationViewController {

let speechAPI = SpeechAPISpy(accessToken: token)
let directions = DirectionsSpy(accessToken: token)
let service = MapboxNavigationService(route: route,
Expand All @@ -66,5 +61,3 @@ class BenchTests: XCTestCase, CLLocationManagerDelegate {
return NavigationViewController(for: route, options: options)
}
}


2 changes: 0 additions & 2 deletions BenchUITests/BenchUITests.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import XCTest

class BenchUITests: XCTestCase {

override func setUp() {
continueAfterFailure = false
XCUIApplication().launch()
}

func testExample() {

}
}
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@

## master

### Packaging
* This library can no longer be used in applications written in pure Objective-C. If you need to use this library’s public API from Objective-C code, you will need to implement a wrapper in Swift that bridges the subset of the API you need from Swift to Objective-C. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))

### User interface
* `UserCourseView` is now a type alias of the `UIView` class and the `CourseUpdatable` protocol rather than a protocol in its own right. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))
* Fixed an issue where user notifications displayed right turn arrows for left turn maneuvers. ([#2270](https://github.com/mapbox/mapbox-navigation-ios/pull/2270))
* Renamed `NavigationMapView.showRoutes(_:legIndex:)` to `NavigationMapView.show(_:legIndex:)`. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))
* Renamed `NavigationMapView.showWaypoints(_:legIndex:)` to `NavigationMapView.showWaypoints(on:legIndex:)`. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))
* Renamed `MapboxVoiceController.play(_:)` to `MapboxVoiceController.play(instruction:data:)`. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))

### Error handling
* The `MapboxVoiceController` and `RouteVoiceController` now emit `SpeechError`s instead of an `NSError` object. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))
* Added the `VoiceControllerDelegate.voiceController(_:didFallBackTo:becauseOf:)` method for detecting when the voice controller falls back to `AVSpeechSynthesizer`. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))

### Other changes
* Since pure Swift protocols cannot have optional methods, various delegate protocols now provide default no-op implementations for all their methods and conform to the `UnimplementedLogging` protocol, which can inform you at runtime when a delegate method is called but has not been implemented. Messages are sent through Apple Unified Logging and can be disabled globally through [Unifed Logging](https://developer.apple.com/documentation/os/logging#2878594), or by overriding the delegate function with a no-op implementation. ([#2230](https://github.com/mapbox/mapbox-navigation-ios/pull/2230))

## v0.38.0

Expand Down Expand Up @@ -146,7 +161,6 @@
* You can now customize the control layer of the map template comprising of the navigation bar's leading and trailing buttons and the map buttons. ([#1962](https://github.com/mapbox/mapbox-navigation-ios/pull/1962))
* Added new map buttons in the `CarPlayManager` and the `CarPlayMapViewController`. You can now access map buttons that perform built-in actions on the map by accessing read-only properties such as: `CarPlayManager.exitButton`, `CarPlayManager.muteButton`, `CarPlayManager.showFeedbackButton`, `CarPlayManager.overviewButton`, `CarPlayMapViewController.recenterButton`, `CarPlayMapViewController.zoomInButton`, `CarPlayMapViewController.zoomOutButton`, `CarPlayMapViewController.panningInterfaceDisplayButton(for:)`, `CarPlayMapViewController.panningInterfaceDismissalButton(for:)`. ([#1962](https://github.com/mapbox/mapbox-navigation-ios/pull/1962))


### Other changes

* Replaced `NavigationViewController(for:styles:navigationService:viewController:)` with `NavigationViewController(for:options:)`, which accepts a `NavigationOptions` object (not to be confused with `NavigationRouteOptions`). `NavigationOptions` contains various options for customizing the user experience of a turn-by-turn navigation session, including replacing the bottom banner with a custom view controller. ([#1951](https://github.com/mapbox/mapbox-navigation-ios/pull/1951))
Expand Down Expand Up @@ -630,7 +644,6 @@

* Exposes `RouteVoiceController.speak(_:)` which would allow custom subclass of MapboxVoiceController to override this method and pass a modified SpokenInstruction to our superclass implementation.


## v0.13.1 (February 7, 2018)

### Core Navigation
Expand Down
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.2.0"
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.5.0"
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" "6.2.1"
github "AndriiDoroshko/SnappyShrimp" "1.6.4"
github "CedarBDD/Cedar" "v1.0"
github "Quick/Nimble" "v8.0.2"
github "Quick/Quick" "v2.1.0"
github "Quick/Nimble" "v8.0.4"
github "Quick/Quick" "v2.2.0"
github "ceeK/Solar" "2.1.0"
github "mapbox/MapboxDirections.swift" "v0.30.0"
github "mapbox/MapboxGeocoder.swift" "v0.10.2"
Expand Down
9 changes: 1 addition & 8 deletions Example/AppDelegate+CarPlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ let CarPlayWaypointKey: String = "MBCarPlayWaypoint"
*/
@available(iOS 12.0, *)
extension AppDelegate: CPApplicationDelegate {

// MARK: CPApplicationDelegate

func application(_ application: UIApplication, didConnectCarInterfaceController interfaceController: CPInterfaceController, to window: CPWindow) {
Expand All @@ -46,15 +45,13 @@ extension AppDelegate: CPApplicationDelegate {
@available(iOS 12.0, *)
extension AppDelegate: CarPlayManagerDelegate {
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceAlong route: Route, desiredSimulationMode: SimulationMode) -> NavigationService {

if let nvc = self.window?.rootViewController?.presentedViewController as? NavigationViewController, let service = nvc.navigationService {
//Do not set simulation mode if we already have an active navigation session.
return service
}
return MapboxNavigationService(route: route, simulating: desiredSimulationMode)
}


// MARK: CarPlayManagerDelegate
func carPlayManager(_ carPlayManager: CarPlayManager, didBeginNavigationWith service: NavigationService) {
currentAppRootViewController?.beginNavigationWithCarplay(navigationService: service)
Expand All @@ -78,7 +75,6 @@ extension AppDelegate: CarPlayManagerDelegate {
}

func carPlayManager(_ carPlayManager: CarPlayManager, leadingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, in template: CPTemplate, for activity: CarPlayActivity) -> [CPBarButton]? {

guard let interfaceController = self.carPlayManager.interfaceController else {
return nil
}
Expand Down Expand Up @@ -107,7 +103,6 @@ extension AppDelegate: CarPlayManagerDelegate {
}

func carPlayManager(_ carPlayManager: CarPlayManager, trailingNavigationBarButtonsCompatibleWith traitCollection: UITraitCollection, in template: CPTemplate, for activity: CarPlayActivity) -> [CPBarButton]? {

switch activity {
case .previewing:
let disableSimulateText = "Disable Simulation"
Expand All @@ -133,11 +128,10 @@ extension AppDelegate: CarPlayManagerDelegate {
}

func carPlayManager(_ carPlayManager: CarPlayManager, mapButtonsCompatibleWith traitCollection: UITraitCollection, in template: CPTemplate, for activity: CarPlayActivity) -> [CPMapButton]? {

switch activity {
case .browsing:
guard let mapViewController = carPlayManager.carPlayMapViewController,
let mapTemplate = template as? CPMapTemplate else {
let mapTemplate = template as? CPMapTemplate else {
return nil
}
var mapButtons = [mapViewController.recenterButton,
Expand Down Expand Up @@ -175,7 +169,6 @@ extension AppDelegate: CarPlaySearchControllerDelegate {

@available(iOS 12.0, *)
extension AppDelegate: CPListTemplateDelegate {

func listTemplate(_ listTemplate: CPListTemplate, didSelect item: CPListItem, completionHandler: @escaping () -> Void) {
// Selected a favorite
if let userInfo = item.userInfo as? [String: Any],
Expand Down
3 changes: 0 additions & 3 deletions Example/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import UIKit
import MapboxNavigation


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

weak var currentAppRootViewController: ViewController?

var window: UIWindow?
Expand All @@ -15,7 +13,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
lazy var carPlaySearchController: CarPlaySearchController = CarPlaySearchController()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

if isRunningTests() {
window!.rootViewController = UIViewController()
}
Expand Down
5 changes: 2 additions & 3 deletions Example/CustomStyles.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Foundation
import MapboxNavigation

// MARK: CustomDayStyle

/**
To find more pieces of the UI to customize, checkout DayStyle.swift.
*/
// MARK: CustomDayStyle
class CustomDayStyle: DayStyle {

required init() {
super.init()
mapStyleURL = URL(string: "mapbox://styles/mapbox/satellite-streets-v9")!
Expand All @@ -22,7 +22,6 @@ class CustomDayStyle: DayStyle {

// MARK: CustomNightStyle
class CustomNightStyle: NightStyle {

required init() {
super.init()
mapStyleURL = URL(string: "mapbox://styles/mapbox/satellite-streets-v9")!
Expand Down
13 changes: 6 additions & 7 deletions Example/CustomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import MapboxDirections
import Turf

class CustomViewController: UIViewController, MGLMapViewDelegate {

var destination: MGLPointAnnotation!
let directions = Directions.shared
var navigationService: NavigationService!
Expand Down Expand Up @@ -81,7 +80,7 @@ class CustomViewController: UIViewController, MGLMapViewDelegate {
}

func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
self.mapView.showRoutes([navigationService.route])
self.mapView.show([navigationService.route])
}

// Notifications sent on all location updates
Expand Down Expand Up @@ -115,7 +114,7 @@ class CustomViewController: UIViewController, MGLMapViewDelegate {
// Fired when the user is no longer on the route.
// Update the route on the map.
@objc func rerouted(_ notification: NSNotification) {
self.mapView.showRoutes([navigationService.route])
self.mapView.show([navigationService.route])
}

@IBAction func cancelButtonPressed(_ sender: Any) {
Expand Down Expand Up @@ -161,9 +160,9 @@ class CustomViewController: UIViewController, MGLMapViewDelegate {
let route = navigationService.route

// find the leg that contains the step, legIndex, and stepIndex
guard let leg = route.legs.first(where: { $0.steps.contains(step) }),
let legIndex = route.legs.firstIndex(of: leg),
let stepIndex = leg.steps.firstIndex(of: step) else {
guard let leg = route.legs.first(where: { $0.steps.contains(step) }),
let legIndex = route.legs.firstIndex(of: leg),
let stepIndex = leg.steps.firstIndex(of: step) else {
return
}

Expand Down Expand Up @@ -207,7 +206,7 @@ class CustomViewController: UIViewController, MGLMapViewDelegate {
guard let view = previewInstructionsView else { return }
view.removeFromSuperview()

// reclaim the delegate, from the preview banner
// reclaim the delegate, from the preview banner
instructionsBannerView.delegate = self

// nil out both the view and index
Expand Down
1 change: 0 additions & 1 deletion Example/FavoritesList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import CarPlay
import CoreLocation

public enum FavoritesList {

enum POI: RawRepresentable {
typealias RawValue = String
case mapboxSF, timesSquare
Expand Down
9 changes: 0 additions & 9 deletions Example/MBViewController.h

This file was deleted.

Loading