Skip to content

Commit

Permalink
Merge pull request #1549 from mapbox/1ec5-cllocationmanager-deredeclare
Browse files Browse the repository at this point in the history
Deredeclare CLLocationManagerDelegate conformance on MGLMapView
  • Loading branch information
1ec5 authored Jul 10, 2018
2 parents ee588e1 + 0936040 commit 6c49b28
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 78 deletions.
2 changes: 0 additions & 2 deletions Examples/Swift/Example-Swift-BridgingHeader.h
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#pragma once

#import "MGLMapView+CustomAdditions.h"
10 changes: 0 additions & 10 deletions Examples/Swift/MGLMapView+CustomAdditions.h

This file was deleted.

11 changes: 0 additions & 11 deletions Examples/Swift/MGLMapView+CustomAdditions.m

This file was deleted.

10 changes: 2 additions & 8 deletions MapboxNavigation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@
C549F8321F17F2C5001A0A2D /* MapboxMobileEvents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C549F8311F17F2C5001A0A2D /* MapboxMobileEvents.framework */; };
C549F8331F17F2C5001A0A2D /* MapboxMobileEvents.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C549F8311F17F2C5001A0A2D /* MapboxMobileEvents.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C54C655220336F2600D338E0 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54C655120336F2600D338E0 /* Constants.swift */; };
C55C299920D2E2F600B0406C /* NavigationMapViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55C299820D2E2F600B0406C /* NavigationMapViewTests.swift */; };
C551B0E620D42222009A986F /* NavigationLocationManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C551B0E520D42222009A986F /* NavigationLocationManagerTests.swift */; };
C55C299920D2E2F600B0406C /* NavigationMapViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55C299820D2E2F600B0406C /* NavigationMapViewTests.swift */; };
C561735B1F182113005954F6 /* RouteStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = C561735A1F182113005954F6 /* RouteStep.swift */; };
C565168B1FE1E23E00A0AD18 /* MapboxVoiceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C565168A1FE1E23E00A0AD18 /* MapboxVoiceController.swift */; };
C57491DF1FACC42F006F97BC /* CGPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57491DE1FACC42F006F97BC /* CGPoint.swift */; };
Expand Down Expand Up @@ -251,7 +251,6 @@
C5F2DCA0206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; };
C5F2DCA1206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; };
DA23C9611F4FC05C00BA9522 /* MGLMapView+MGLNavigationAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D825F91E6A2DBE0088F83B /* MGLMapView+MGLNavigationAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA23C9641F4FC0A600BA9522 /* MGLMapView+CustomAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DA23C9631F4FC0A600BA9522 /* MGLMapView+CustomAdditions.m */; };
DA3525702010A5210048DDFC /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DA35256E2010A5200048DDFC /* Localizable.stringsdict */; };
DAAE5F301EAE4C4700832871 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DAAE5F321EAE4C4700832871 /* Localizable.strings */; };
DAB2CCE71DF7AFDF001B2FE1 /* dc-line.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DAB2CCE61DF7AFDE001B2FE1 /* dc-line.geojson */; };
Expand Down Expand Up @@ -627,8 +626,8 @@
C53C197A1F38EAEA008DB406 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
C549F8311F17F2C5001A0A2D /* MapboxMobileEvents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapboxMobileEvents.framework; path = Carthage/Build/iOS/MapboxMobileEvents.framework; sourceTree = "<group>"; };
C54C655120336F2600D338E0 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
C55C299820D2E2F600B0406C /* NavigationMapViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationMapViewTests.swift; sourceTree = "<group>"; };
C551B0E520D42222009A986F /* NavigationLocationManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationLocationManagerTests.swift; sourceTree = "<group>"; };
C55C299820D2E2F600B0406C /* NavigationMapViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationMapViewTests.swift; sourceTree = "<group>"; };
C561735A1F182113005954F6 /* RouteStep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteStep.swift; sourceTree = "<group>"; };
C565168A1FE1E23E00A0AD18 /* MapboxVoiceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxVoiceController.swift; sourceTree = "<group>"; };
C57491DE1FACC42F006F97BC /* CGPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CGPoint.swift; path = ../MapboxNavigation/CGPoint.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -669,8 +668,6 @@
DA181204201290FC00C91918 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = es; path = Resources/es.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
DA1812052012910000C91918 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = vi; path = Resources/vi.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
DA181207201292E700C91918 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = fr; path = Resources/fr.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
DA23C9621F4FC0A600BA9522 /* MGLMapView+CustomAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MGLMapView+CustomAdditions.h"; sourceTree = "<group>"; };
DA23C9631F4FC0A600BA9522 /* MGLMapView+CustomAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MGLMapView+CustomAdditions.m"; sourceTree = "<group>"; };
DA3327391F50C6DA00C5EE88 /* sl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sl; path = sl.lproj/Main.strings; sourceTree = "<group>"; };
DA33273A1F50C6FC00C5EE88 /* sl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sl; path = sl.lproj/Main.strings; sourceTree = "<group>"; };
DA33273B1F50C70E00C5EE88 /* sl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sl; path = sl.lproj/Navigation.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1037,8 +1034,6 @@
358D14671E5E3B7700ADE590 /* ViewController.swift */,
C5D9800C1EFA8BA9006DBF2E /* CustomViewController.swift */,
6441B1691EFC64E50076499F /* WaypointConfirmationViewController.swift */,
DA23C9621F4FC0A600BA9522 /* MGLMapView+CustomAdditions.h */,
DA23C9631F4FC0A600BA9522 /* MGLMapView+CustomAdditions.m */,
);
name = Swift;
path = Examples/Swift;
Expand Down Expand Up @@ -1916,7 +1911,6 @@
files = (
358D14681E5E3B7700ADE590 /* ViewController.swift in Sources */,
C5D9800D1EFA8BA9006DBF2E /* CustomViewController.swift in Sources */,
DA23C9641F4FC0A600BA9522 /* MGLMapView+CustomAdditions.m in Sources */,
6441B16A1EFC64E50076499F /* WaypointConfirmationViewController.swift in Sources */,
358D14661E5E3B7700ADE590 /* AppDelegate.swift in Sources */,
);
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/MGLMapView+MGLNavigationAdditions.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import <Mapbox/Mapbox.h>

@interface MGLMapView (MGLNavigationAdditions) <CLLocationManagerDelegate>
@interface MGLMapView (MGLNavigationAdditions)

- (void)mapViewDidFinishRenderingFrameFullyRendered:(BOOL)fullyRendered;

Expand Down
48 changes: 2 additions & 46 deletions docs/guides/Simulating Routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ By default, with Xcode there are a few ways to simulate locations:

1. In the Simulator.app, you can select `City Bicycle` or `Freeway Drive`

![](https://user-images.githubusercontent.com/1058624/40988613-63b3254e-68a0-11e8-9f96-e8556dbb7478.png)
![](img/simulator-location.png)

2. Provide a GPX file with a series of latitudes and longtiudes.

Expand All @@ -20,51 +20,7 @@ However, there are issues with both of these. One is tied down to a specific loc

To simulate a route, we are overriding the location manager's [`locationManager(_:didUpdateLocations:)`](https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate/1423615-locationmanager?language=swift) from a series of locations that are coming from a provided route. To do this, we need to expose the location manager on MGLMapView since it is private.

### Steps

1. Add these two files to your project:

`MGLMapView+CustomAdditions.h`:

```objc
#import <Mapbox/Mapbox.h>

@interface MGLMapView (CustomAdditions) <CLLocationManagerDelegate>

// FIXME: This will be removed once https://github.com/mapbox/mapbox-gl-native/issues/6867 is implemented
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations;

@property (nonatomic, readonly) CLLocationManager *locationManager;

@end
```
`MGLMapView+CustomAdditions.m`:
```objc
#import "MGLMapView+CustomAdditions.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincomplete-implementation"
// Supressing compiler warning until https://github.com/mapbox/mapbox-gl-native/issues/6867 is implemented
@implementation MGLMapView (CustomAdditions)
#pragma clang diagnostic pop
@dynamic locationManager;
@end
```

2. Accept popup about `Create Bridging Header`

![](https://user-images.githubusercontent.com/1058624/40989148-cc580d48-68a1-11e8-85ed-5d1e76992ed8.png)

3. Confirm in `Build Settings` that `Objective-C Bridging Header` has the correct path to the bridging header file just added.

![](https://user-images.githubusercontent.com/1058624/40989272-1f440c3c-68a2-11e8-9a4d-f00cdf752187.png)

4. Provide a route to the SimulatedLocationManager

```swift
let simulator = SimulatedLocationManager(route: route)
let routeController = RouteController(along: userRoute!, directions: directions, locationManager: simulator)
```
```
Binary file added docs/img/simulator-location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6c49b28

Please sign in to comment.