From ff0ea6246e3712372894859a2ae34465b54957ee Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 20 May 2021 00:31:18 -0400 Subject: [PATCH 01/15] Make __map private --- .../Camera/CameraAnimationsManager.swift | 2 +- .../Foundation/CameraManagerProtocol.swift | 4 ++ Sources/MapboxMaps/Foundation/MapView.swift | 6 +- Sources/MapboxMaps/Foundation/MapboxMap.swift | 71 ++++++++++++++++++- ...estureManager+GestureHandlerDelegate.swift | 15 ++-- .../Location/LocationSupportableMapView.swift | 2 +- .../MapView/Configuration/RenderOptions.swift | 10 ++- .../MapView/MapView+Supportable.swift | 6 +- .../MapboxMaps/Offline/OfflineCallbacks.swift | 19 ++--- .../Generated/Sources/GeojsonSource.swift | 2 +- Sources/MapboxMaps/Style/StyleEncodable.swift | 2 +- Sources/MapboxMaps/Style/StyleErrors.swift | 2 +- .../Foundation/MapboxMapTests.swift | 11 ++- .../LocationSupportableMapViewMock.swift | 8 +-- .../Map/DidIdleFailureIntegrationTest.swift | 4 +- .../Map/MapInitOptionsIntegrationTests.swift | 8 +-- .../Map/ObservableIntegrationTests.swift | 4 +- 17 files changed, 120 insertions(+), 56 deletions(-) diff --git a/Sources/MapboxMaps/Foundation/Camera/CameraAnimationsManager.swift b/Sources/MapboxMaps/Foundation/Camera/CameraAnimationsManager.swift index bd1d3eff5d1..136b6f8faf1 100644 --- a/Sources/MapboxMaps/Foundation/Camera/CameraAnimationsManager.swift +++ b/Sources/MapboxMaps/Foundation/Camera/CameraAnimationsManager.swift @@ -28,7 +28,7 @@ public class CameraAnimationsManager { minZoom: options.minimumZoomLevel as NSNumber, maxPitch: options.maximumPitch as NSNumber, minPitch: options.minimumPitch as NSNumber) - mapView?.mapboxMap.__map.setBoundsFor(boundOptions) + try? mapView?.mapboxMap.setCameraBounds(for: boundOptions) } } diff --git a/Sources/MapboxMaps/Foundation/CameraManagerProtocol.swift b/Sources/MapboxMaps/Foundation/CameraManagerProtocol.swift index 1d3f738dafb..734ce491a14 100644 --- a/Sources/MapboxMaps/Foundation/CameraManagerProtocol.swift +++ b/Sources/MapboxMaps/Foundation/CameraManagerProtocol.swift @@ -148,6 +148,10 @@ internal protocol CameraManagerProtocol { /// Returns the bounds of the map. var cameraBounds: CameraBounds { get } + /// Sets the camera bounds using a `CameraBoundsOptions` + /// - Parameter options: `CameraBoundsOptions` - `nil` parameters take no effect. + func setCameraBounds(for options: CameraBoundsOptions) throws + // MARK: - Drag API /// Prepares the drag gesture to use the provided screen coordinate as a pivot diff --git a/Sources/MapboxMaps/Foundation/MapView.swift b/Sources/MapboxMaps/Foundation/MapView.swift index 8421198125b..a0ee8f73b83 100644 --- a/Sources/MapboxMaps/Foundation/MapView.swift +++ b/Sources/MapboxMaps/Foundation/MapView.swift @@ -41,7 +41,7 @@ open class MapView: UIView { public var options = RenderOptions() { didSet { - mapboxMap.__map.setPrefetchZoomDeltaForDelta(options.prefetchZoomDelta) + mapboxMap.prefetchZoomDelta = options.prefetchZoomDelta preferredFPS = options.preferredFramesPerSecond metalView?.presentsWithTransaction = options.presentsWithTransaction } @@ -148,11 +148,11 @@ open class MapView: UIView { } if let cameraOptions = resolvedMapInitOptions.cameraOptions { - mapboxMap.__map.setCameraFor(MapboxCoreMaps.CameraOptions(cameraOptions)) + mapboxMap._setCamera(to: cameraOptions) } // Set prefetchZoomDelta - mapboxMap.__map.setPrefetchZoomDeltaForDelta(options.prefetchZoomDelta) + mapboxMap.prefetchZoomDelta = options.prefetchZoomDelta // Set preferrredFPS preferredFPS = options.preferredFramesPerSecond diff --git a/Sources/MapboxMaps/Foundation/MapboxMap.swift b/Sources/MapboxMaps/Foundation/MapboxMap.swift index b9dd8032da5..3cd491642e1 100644 --- a/Sources/MapboxMaps/Foundation/MapboxMap.swift +++ b/Sources/MapboxMaps/Foundation/MapboxMap.swift @@ -5,7 +5,7 @@ import UIKit public final class MapboxMap { /// The underlying renderer object responsible for rendering the map - public let __map: Map + private let __map: Map internal var size: CGSize { get { @@ -87,6 +87,57 @@ public final class MapboxMap { __map.setStyleJSONForJson(JSON) } + // MARK: - Prefetching + + /// When loading a map, if `prefetchZoomDelta` is set to any number greater + /// than 0, the map will first request a tile for `zoom - prefetchZoomDelta` + /// in an attempt to display a full map at lower resolution as quick as + /// possible. + /// + /// It will get clamped at the tile source minimum zoom. The default delta + /// is 4. + public var prefetchZoomDelta: UInt8 { + get { + return __map.getPrefetchZoomDelta() + } + set { + __map.setPrefetchZoomDeltaForDelta(newValue) + } + } + + /// Returns the map's options + public var options: MapOptions { + return __map.getOptions() + } + + /// Reduces memory use. Useful to call when the application gets paused or + /// sent to background. + internal func reduceMemoryUse() { + __map.reduceMemoryUse() + } + + /// Gets the resource options for the map. + /// + /// All optional fields of the returned object are initialized with the + /// actual values. + /// + /// - Note: The result of this property is different from the `ResourceOptions` + /// that were provided to the map's initializer. + public var resourceOptions: ResourceOptions { + return __map.getResourceOptions() + } + + /// Gets elevation for the given coordinate. + /// + /// - Note: Elevation is only available for the visible region on the screen. + /// + /// - Parameter coordinate: Coordinate for which to return the elevation. + /// - Returns: Elevation (in meters) multiplied by current terrain + /// exaggeration, or empty if elevation for the coordinate is not available. + public func elevation(at coordinate: CLLocationCoordinate2D) -> Double? { + return __map.getElevationFor(coordinate)?.doubleValue + } + // MARK: - Camera Fitting /// Transforms a view's frame into a set of coordinate bounds @@ -231,6 +282,18 @@ extension MapboxMap: CameraManagerProtocol { return __map.getBounds() } + /// Sets the bounds of the map. + /// + /// - Parameter options: New camera bounds. Nil values will not take effect. + /// - Throws: `MapError` + public func setCameraBounds(for options: CameraBoundsOptions) throws { + let expected = __map.setBoundsFor(options) + + if expected.isError() { + throw MapError(coreError: expected.error as! NSString) + } + } + // MARK: - Drag API public func dragStart(for point: CGPoint) { @@ -357,3 +420,9 @@ extension MapboxMap: MapEventsObservable { return handler } } + +extension MapboxMap { + internal var __testingMap: Map { + return __map + } +} diff --git a/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift b/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift index 81ae9b6dd4d..55e4ac82277 100644 --- a/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift +++ b/Sources/MapboxMaps/Gestures/GestureManager+GestureHandlerDelegate.swift @@ -29,16 +29,13 @@ extension GestureManager: GestureHandlerDelegate { } internal func panBegan(at point: CGPoint) { - cameraManager.mapView?.mapboxMap.__map.dragStart(forPoint: point.screenCoordinate) + cameraManager.mapView?.mapboxMap.dragStart(for: point) } // MapView has been panned internal func panned(from startPoint: CGPoint, to endPoint: CGPoint) { - - if let cameraOptions = cameraManager.mapView?.mapboxMap.__map.getDragCameraOptionsFor( - fromPoint: startPoint.screenCoordinate, - toPoint: endPoint.screenCoordinate) { - cameraManager.setCamera(to: CameraOptions(cameraOptions)) + if let cameraOptions = cameraManager.mapView?.mapboxMap.dragCameraOptions(from: startPoint, to: endPoint) { + cameraManager.setCamera(to: cameraOptions) } } @@ -46,15 +43,15 @@ extension GestureManager: GestureHandlerDelegate { func panEnded(at endPoint: CGPoint, shouldDriftTo driftEndPoint: CGPoint) { if endPoint != driftEndPoint, - let driftCameraOptions = cameraManager.mapView?.mapboxMap.__map.getDragCameraOptionsFor(fromPoint: endPoint.screenCoordinate, toPoint: driftEndPoint.screenCoordinate) { + let driftCameraOptions = cameraManager.mapView?.mapboxMap.dragCameraOptions(from: endPoint, to: driftEndPoint) { _ = cameraManager.ease( - to: CameraOptions(driftCameraOptions), + to: driftCameraOptions, duration: Double(cameraManager.options.decelerationRate), curve: .easeOut, completion: nil) } - cameraManager.mapView?.mapboxMap.__map.dragEnd() + cameraManager.mapView?.mapboxMap.dragEnd() } internal func cancelGestureTransitions() { diff --git a/Sources/MapboxMaps/Location/LocationSupportableMapView.swift b/Sources/MapboxMaps/Location/LocationSupportableMapView.swift index 99a72232d6a..ae21935d2aa 100644 --- a/Sources/MapboxMaps/Location/LocationSupportableMapView.swift +++ b/Sources/MapboxMaps/Location/LocationSupportableMapView.swift @@ -12,7 +12,7 @@ import MapboxMapsStyle public protocol LocationSupportableMapView: UIView { /// Returns the screen coordinate for a given location coordinate (lat-long) - func screenCoordinate(for locationCoordinate: CLLocationCoordinate2D) -> ScreenCoordinate + func point(for coordinate: CLLocationCoordinate2D) -> CGPoint /// Allows the `LocationSupportableMapView` to subscribe to a delegate func subscribeRenderFrameHandler(_ handler: @escaping (MapboxCoreMaps.Event) -> Void) diff --git a/Sources/MapboxMaps/MapView/Configuration/RenderOptions.swift b/Sources/MapboxMaps/MapView/Configuration/RenderOptions.swift index 6fe9f79a2eb..df1788a4532 100644 --- a/Sources/MapboxMaps/MapView/Configuration/RenderOptions.swift +++ b/Sources/MapboxMaps/MapView/Configuration/RenderOptions.swift @@ -13,9 +13,13 @@ public struct RenderOptions: Equatable { /// See Also `CADisplayLink.preferredFramesPerSecond` public var preferredFramesPerSecond: PreferredFPS = .maximum - /// When loading a map, if `PrefetchZoomDelta` is set to any number greater than 0, the map - /// map at lower resolution as quick as possible. It will get clamped at the tile source - /// minimum zoom. The default `PrefetchZoomDelta` is 4. + /// When loading a map, if `prefetchZoomDelta` is set to any number greater + /// than 0, the map will first request a tile for `zoom - prefetchZoomDelta` + /// in an attempt to display a full map at lower resolution as quick as + /// possible. + /// + /// It will get clamped at the tile source minimum zoom. The default delta + /// is 4. public var prefetchZoomDelta: UInt8 = 4 /// A Boolean value that indicates whether the underlying `CAMetalLayer` of the `MapView` diff --git a/Sources/MapboxMaps/MapView/MapView+Supportable.swift b/Sources/MapboxMaps/MapView/MapView+Supportable.swift index a094a756eeb..63d3178794e 100644 --- a/Sources/MapboxMaps/MapView/MapView+Supportable.swift +++ b/Sources/MapboxMaps/MapView/MapView+Supportable.swift @@ -32,10 +32,10 @@ extension MapView: OrnamentSupportableView { extension MapView: LocationSupportableMapView { - public func screenCoordinate(for locationCoordinate: CLLocationCoordinate2D) -> ScreenCoordinate { - return mapboxMap.__map.pixelForCoordinate(for: locationCoordinate) + public func point(for coordinate: CLLocationCoordinate2D) -> CGPoint { + return mapboxMap.point(for: coordinate) } - + public func metersPerPointAtLatitude(latitude: CLLocationDegrees) -> CLLocationDistance { return Projection.getMetersPerPixelAtLatitude(forLatitude: latitude, zoom: Double(cameraState.zoom)) } diff --git a/Sources/MapboxMaps/Offline/OfflineCallbacks.swift b/Sources/MapboxMaps/Offline/OfflineCallbacks.swift index b70d0718a7b..aa74b85a3b3 100644 --- a/Sources/MapboxMaps/Offline/OfflineCallbacks.swift +++ b/Sources/MapboxMaps/Offline/OfflineCallbacks.swift @@ -1,13 +1,6 @@ import Foundation @_implementationOnly import MapboxCommon_Private -/// Errors that OfflineManager and TileStore APIs can return as a Result type -/// These typically represent an API error; as such these are currently internal -internal enum OfflineError: Error { - case typeMismatch - case invalidResult -} - /// Returns a closure suitable for the OfflineManager and TileStore callback based /// APIs, that converts the expected type into a Swift Result type. /// - Parameters: @@ -28,8 +21,8 @@ internal func coreAPIClosureAdapter( } guard let expected = expected as? Expected else { - assertionFailure("Invalid Expected types or none.") - result = .failure(OfflineError.typeMismatch) + assertionFailure("Invalid MBXExpected types or none.") + result = .failure(TypeConversionError.unexpectedType) return } @@ -39,7 +32,7 @@ internal func coreAPIClosureAdapter( result = .failure(SwiftError(coreError: error)) } else { assertionFailure("Unexpected value or error: \(expected), expected: \(T.self)") - result = .failure(OfflineError.invalidResult) + result = .failure(TypeConversionError.invalidObject) } } } @@ -56,8 +49,8 @@ internal func coreAPIClosureAdapter( } guard let expected = expected as? Expected else { - assertionFailure("Invalid Expected types or none.") - result = .failure(OfflineError.typeMismatch) + assertionFailure("Invalid MBXExpected types or none.") + result = .failure(TypeConversionError.unexpectedType) return } @@ -67,7 +60,7 @@ internal func coreAPIClosureAdapter( result = .failure(SwiftError(coreError: error)) } else { assertionFailure("Unexpected value or error: \(expected)") - result = .failure(OfflineError.invalidResult) + result = .failure(TypeConversionError.invalidObject) } } } diff --git a/Sources/MapboxMaps/Style/Generated/Sources/GeojsonSource.swift b/Sources/MapboxMaps/Style/Generated/Sources/GeojsonSource.swift index d97cca293ae..29910605e2f 100644 --- a/Sources/MapboxMaps/Style/Generated/Sources/GeojsonSource.swift +++ b/Sources/MapboxMaps/Style/Generated/Sources/GeojsonSource.swift @@ -84,4 +84,4 @@ For more advanced use cases, in place of `operator`, you can use a custom reduce } } -// End of generated file. \ No newline at end of file +// End of generated file. diff --git a/Sources/MapboxMaps/Style/StyleEncodable.swift b/Sources/MapboxMaps/Style/StyleEncodable.swift index 5d8185a2951..9cfb9892134 100644 --- a/Sources/MapboxMaps/Style/StyleEncodable.swift +++ b/Sources/MapboxMaps/Style/StyleEncodable.swift @@ -14,7 +14,7 @@ public extension StyleEncodable where Self: Encodable { let data = try JSONEncoder().encode(self) guard let jsonObject = try JSONSerialization.jsonObject(with: data) as? [String: Any] else { - throw TypeConversionError.invalidJSONObject + throw TypeConversionError.invalidObject } return jsonObject } diff --git a/Sources/MapboxMaps/Style/StyleErrors.swift b/Sources/MapboxMaps/Style/StyleErrors.swift index f98ba5f3e42..548ce206b5a 100644 --- a/Sources/MapboxMaps/Style/StyleErrors.swift +++ b/Sources/MapboxMaps/Style/StyleErrors.swift @@ -26,7 +26,7 @@ public struct StyleError: RawRepresentable, LocalizedError { } public enum TypeConversionError: Error { - case invalidJSONObject + case invalidObject case unexpectedType } diff --git a/Tests/MapboxMapsTests/Foundation/MapboxMapTests.swift b/Tests/MapboxMapsTests/Foundation/MapboxMapTests.swift index 9a9282455b1..d196dd58c98 100644 --- a/Tests/MapboxMapsTests/Foundation/MapboxMapTests.swift +++ b/Tests/MapboxMapsTests/Foundation/MapboxMapTests.swift @@ -25,8 +25,7 @@ final class MapboxMapTests: XCTestCase { } func testInitializationOfResourceOptions() { - let actualResourceOptions = mapboxMap.__map.getResourceOptions() - + let actualResourceOptions = mapboxMap.resourceOptions XCTAssertEqual(actualResourceOptions, mapInitOptions.resourceOptions) } @@ -42,7 +41,7 @@ final class MapboxMapTests: XCTestCase { pixelRatio: mapInitOptions.mapOptions.pixelRatio, glyphsRasterizationOptions: nil) // __map.getOptions() always returns nil for glyphsRasterizationOptions - let actualMapOptions = mapboxMap.__map.getOptions() + let actualMapOptions = mapboxMap.options XCTAssertEqual(actualMapOptions, expectedMapOptions) } @@ -58,14 +57,14 @@ final class MapboxMapTests: XCTestCase { mapboxMap.size = expectedSize - XCTAssertEqual(CGSize(mapboxMap.__map.getSize()), expectedSize) + XCTAssertEqual(CGSize(mapboxMap.__testingMap.getSize()), expectedSize) } func testGetSize() { let expectedSize = Size( width: .random(in: 100...1000), height: .random(in: 100...1000)) - mapboxMap.__map.setSizeFor(expectedSize) + mapboxMap.__testingMap.setSizeFor(expectedSize) let actualSize = mapboxMap.size @@ -73,7 +72,7 @@ final class MapboxMapTests: XCTestCase { } func testGetCameraOptions() { - XCTAssertEqual(mapboxMap.cameraState, CameraState(mapboxMap.__map.getCameraState())) + XCTAssertEqual(mapboxMap.cameraState, CameraState(mapboxMap.__testingMap.getCameraState())) } func testCameraForCoordinateArray() { diff --git a/Tests/MapboxMapsTests/Location/LocationSupportableMapViewMock.swift b/Tests/MapboxMapsTests/Location/LocationSupportableMapViewMock.swift index 5710de6ad76..ab41e7087da 100644 --- a/Tests/MapboxMapsTests/Location/LocationSupportableMapViewMock.swift +++ b/Tests/MapboxMapsTests/Location/LocationSupportableMapViewMock.swift @@ -14,6 +14,10 @@ import UIKit class LocationSupportableMapViewMock: UIView, LocationSupportableMapView { + public func point(for coordinate: CLLocationCoordinate2D) -> CGPoint { + return .zero + } + func subscribeRenderFrameHandler(_ handler: @escaping (MapboxCoreMaps.Event) -> Void) { print("Pass through implementation") } @@ -22,10 +26,6 @@ class LocationSupportableMapViewMock: UIView, LocationSupportableMapView { print("Pass through implementation") } - func screenCoordinate(for locationCoordinate: CLLocationCoordinate2D) -> ScreenCoordinate { - return ScreenCoordinate(x: 0.0, y: 0.0) - } - func metersPerPointAtLatitude(latitude: CLLocationDegrees) -> CLLocationDistance { return CLLocationDistance() } diff --git a/Tests/MapboxMapsTests/MapView/Integration Tests/Map/DidIdleFailureIntegrationTest.swift b/Tests/MapboxMapsTests/MapView/Integration Tests/Map/DidIdleFailureIntegrationTest.swift index f87acb1fa4c..50c62827ede 100644 --- a/Tests/MapboxMapsTests/MapView/Integration Tests/Map/DidIdleFailureIntegrationTest.swift +++ b/Tests/MapboxMapsTests/MapView/Integration Tests/Map/DidIdleFailureIntegrationTest.swift @@ -131,7 +131,7 @@ internal class DidIdleFailureIntegrationTest: IntegrationTestCase { self.hadResourceEventError?(self.mapView!, eventError) }) - view.mapboxMap.__map.subscribe(for: observer, events: ["resource-request"]) + view.mapboxMap.subscribe(observer, events: ["resource-request"]) self.observer = observer @@ -150,7 +150,7 @@ internal class DidIdleFailureIntegrationTest: IntegrationTestCase { internal override func tearDownWithError() throws { if let observer = observer { - mapView?.mapboxMap.__map.unsubscribe(for: observer, events: ["resource-request"]) + mapView?.mapboxMap.unsubscribe(observer, events: ["resource-request"]) } mapView?.removeFromSuperview() diff --git a/Tests/MapboxMapsTests/MapView/Integration Tests/Map/MapInitOptionsIntegrationTests.swift b/Tests/MapboxMapsTests/MapView/Integration Tests/Map/MapInitOptionsIntegrationTests.swift index bedd52cafec..a66383a66f4 100644 --- a/Tests/MapboxMapsTests/MapView/Integration Tests/Map/MapInitOptionsIntegrationTests.swift +++ b/Tests/MapboxMapsTests/MapView/Integration Tests/Map/MapInitOptionsIntegrationTests.swift @@ -21,12 +21,11 @@ class MapInitOptionsIntegrationTests: XCTestCase { styleURI: .outdoors) let mapView = MapView(frame: .zero, mapInitOptions: mapInitOptions) - let resourceOptions = mapView.mapboxMap.__map.getResourceOptions() + let resourceOptions = mapView.mapboxMap.resourceOptions XCTAssertEqual(resourceOptions, mapInitOptions.resourceOptions) XCTAssertEqual(resourceOptions.accessToken, credentialsManager.accessToken) - XCTAssertEqual(mapView.mapboxMap.__map.getStyleURI(), StyleURI.outdoors.rawValue) XCTAssertEqual(mapView.mapboxMap.style.uri, .outdoors) } @@ -60,12 +59,11 @@ class MapInitOptionsIntegrationTests: XCTestCase { XCTAssertEqual(optionsFromProvider, providerReturnValue) // Now check the resource options from the initialized MapView - let resourceOptions = mapView.mapboxMap.__map.getResourceOptions() + let resourceOptions = mapView.mapboxMap.resourceOptions XCTAssertEqual(resourceOptions, providerReturnValue.resourceOptions) XCTAssertEqual(resourceOptions.accessToken, credentialsManager.accessToken) - XCTAssertEqual(mapView.mapboxMap.__map.getStyleURI(), StyleURI.satellite.rawValue) XCTAssertEqual(mapView.mapboxMap.style.uri, .satellite) } @@ -91,7 +89,7 @@ class MapInitOptionsIntegrationTests: XCTestCase { XCTAssertNil(mapView.mapInitOptionsProvider) // Now check the resource options from the initialized MapView - let resourceOptions = mapView.mapboxMap.__map.getResourceOptions() + let resourceOptions = mapView.mapboxMap.resourceOptions // The map should use the default MapInitOptions XCTAssertEqual(resourceOptions, ResourceOptions(accessToken: CredentialsManager.default.accessToken)) diff --git a/Tests/MapboxMapsTests/MapView/Integration Tests/Map/ObservableIntegrationTests.swift b/Tests/MapboxMapsTests/MapView/Integration Tests/Map/ObservableIntegrationTests.swift index ff7c9337059..3cd73f3d8fa 100644 --- a/Tests/MapboxMapsTests/MapView/Integration Tests/Map/ObservableIntegrationTests.swift +++ b/Tests/MapboxMapsTests/MapView/Integration Tests/Map/ObservableIntegrationTests.swift @@ -45,7 +45,7 @@ class ObservableIntegrationTests: MapViewIntegrationTestCase { eventExpectation.fulfill() } - mapView.mapboxMap.__map.subscribe(for: observer, events: ["resource-request"]) + mapView.mapboxMap.subscribe(observer, events: ["resource-request"]) style.uri = .streets @@ -57,6 +57,6 @@ class ObservableIntegrationTests: MapViewIntegrationTestCase { wait(for: [styleLoadExpectation, eventExpectation], timeout: 5.0) - mapView.mapboxMap.__map.unsubscribe(for: observer) + mapView.mapboxMap.unsubscribe(observer) } } From a182c50239eb31af164ff2d46a7a0789c4583706 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 20 May 2021 00:31:54 -0400 Subject: [PATCH 02/15] Test adding MapboxCoreMaps package to host [run device tests] --- Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index 313ea3d3dbe..85bc2f97b7c 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -242,6 +242,7 @@ CA19C342263B411C00748F1A /* MapInitOptionsTests.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5A6922A2627566A00A03412 /* MapInitOptionsTests.xib */; }; CA19C344263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; CA19C345263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; + CA28AAE526561CDE00B486F2 /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CA28AAE426561CDE00B486F2 /* MapboxCoreMaps */; }; CA2E4A1B2538D3530096DEDE /* MapViewIntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA53616D2537ECA600A8AE38 /* MapViewIntegrationTestCase.swift */; }; CA2E4A1C2538D3530096DEDE /* IntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5361862537EE0600A8AE38 /* IntegrationTestCase.swift */; }; CA2E4A1D2538D3530096DEDE /* DidIdleFailureIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2E498825380B300096DEDE /* DidIdleFailureIntegrationTest.swift */; }; @@ -788,6 +789,7 @@ buildActionMask = 2147483647; files = ( CA952ECD251C30B80099C080 /* MapboxMaps.framework in Frameworks */, + CA28AAE526561CDE00B486F2 /* MapboxCoreMaps in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1750,6 +1752,9 @@ CA952ED0251C30B80099C080 /* PBXTargetDependency */, ); name = MapboxTestHost; + packageProductDependencies = ( + CA28AAE426561CDE00B486F2 /* MapboxCoreMaps */, + ); productName = MapboxMapsTestHost; productReference = CA4453C52436E71500477B4F /* MapboxTestHost.app */; productType = "com.apple.product-type.application"; @@ -2695,6 +2700,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + CA28AAE426561CDE00B486F2 /* MapboxCoreMaps */ = { + isa = XCSwiftPackageProductDependency; + package = CAB77E3B2654AB310071D74C /* XCRemoteSwiftPackageReference "mapbox-core-maps-ios" */; + productName = MapboxCoreMaps; + }; CAB77E3C2654AB310071D74C /* MapboxCoreMaps */ = { isa = XCSwiftPackageProductDependency; package = CAB77E3B2654AB310071D74C /* XCRemoteSwiftPackageReference "mapbox-core-maps-ios" */; From a35bc4851005e670679bbb5fac46aa9915e6de37 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 20 May 2021 18:36:05 -0400 Subject: [PATCH 03/15] Update documentation for map event --- .../Foundation/Extensions/Core/MapEvents.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/MapboxMaps/Foundation/Extensions/Core/MapEvents.swift b/Sources/MapboxMaps/Foundation/Extensions/Core/MapEvents.swift index ae7b28d4b25..2fe552b8e03 100644 --- a/Sources/MapboxMaps/Foundation/Extensions/Core/MapEvents.swift +++ b/Sources/MapboxMaps/Foundation/Extensions/Core/MapEvents.swift @@ -100,8 +100,16 @@ public extension MapEvents { case mapIdle /** - * The requested style data has been loaded. The 'type' property defines what kind of style data has been loaded. + * The requested style data has been loaded. The 'type' property defines + * what kind of style data has been loaded. + * Event may be emitted synchronously, for example, when StyleManager#setStyleJSON is used to load style. * + * Based on an event data 'type' property value, following use-cases may be implemented: + * - 'style': Style is parsed, style layer properties could be read and modified, style layers and sources could be + * added or removed before rendering is started. + * - 'sprite': Style's sprite sheet is parsed and it is possible to add or update images. + * - 'sources': All sources defined by the style are loaded and their properties could be read and updated if needed. + * * * Event data format (Object): * ``` * . From db890ab4852bc1a9800fd70a38b215945f8152b1 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 20 May 2021 18:38:20 -0400 Subject: [PATCH 04/15] Set build dir for make file. [run device tests] --- .circleci/config.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d7b0c71bfaf..59c452456b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -355,9 +355,28 @@ jobs: name: Install Device Farm Dependencies command: make install-devicefarm-dependencies - install-dependencies + + + + # There's a command for this, but it only works if run *after* the build. + # In this case, we need to determine the derived data path *before* building. + - run: + name: Locate derived data directory + command: | + xcodebuild \ + -showBuildSettings \ + -project Mapbox/MapboxMaps.xcodeproj \ + -scheme 'MapboxTestHost' \ + | sed -n 's:^ *BUILD_DIR = \(.*\)/Build/Products$:export DERIVED_DATA_PATH="\1":p' \ + >> $BASH_ENV - run: name: Testing << parameters.scheme >> on AWS Device Farm - command: make test-with-device-farm SCHEME=<< parameters.scheme >> APP_NAME=<< parameters.app-name >> CONFIGURATION=Release + command: | + make test-with-device-farm \ + SCHEME=<< parameters.scheme >> \ + APP_NAME=<< parameters.app-name >> \ + CONFIGURATION=Release \ + BUILD_DIR="$DERIVED_DATA_PATH" when: always # get xcresults here, may be zipped with more than one result - run: From 7aa928bb71ff789aa4e470ece92532feb3b822e1 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 20 May 2021 18:55:08 -0400 Subject: [PATCH 05/15] Revert "Test adding MapboxCoreMaps package to host" This reverts commit 77d7e0c0b95063839afb20d340f493dba7c1b7b1. [run device tests] --- Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index 85bc2f97b7c..313ea3d3dbe 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -242,7 +242,6 @@ CA19C342263B411C00748F1A /* MapInitOptionsTests.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5A6922A2627566A00A03412 /* MapInitOptionsTests.xib */; }; CA19C344263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; CA19C345263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; - CA28AAE526561CDE00B486F2 /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CA28AAE426561CDE00B486F2 /* MapboxCoreMaps */; }; CA2E4A1B2538D3530096DEDE /* MapViewIntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA53616D2537ECA600A8AE38 /* MapViewIntegrationTestCase.swift */; }; CA2E4A1C2538D3530096DEDE /* IntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5361862537EE0600A8AE38 /* IntegrationTestCase.swift */; }; CA2E4A1D2538D3530096DEDE /* DidIdleFailureIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2E498825380B300096DEDE /* DidIdleFailureIntegrationTest.swift */; }; @@ -789,7 +788,6 @@ buildActionMask = 2147483647; files = ( CA952ECD251C30B80099C080 /* MapboxMaps.framework in Frameworks */, - CA28AAE526561CDE00B486F2 /* MapboxCoreMaps in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1752,9 +1750,6 @@ CA952ED0251C30B80099C080 /* PBXTargetDependency */, ); name = MapboxTestHost; - packageProductDependencies = ( - CA28AAE426561CDE00B486F2 /* MapboxCoreMaps */, - ); productName = MapboxMapsTestHost; productReference = CA4453C52436E71500477B4F /* MapboxTestHost.app */; productType = "com.apple.product-type.application"; @@ -2700,11 +2695,6 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - CA28AAE426561CDE00B486F2 /* MapboxCoreMaps */ = { - isa = XCSwiftPackageProductDependency; - package = CAB77E3B2654AB310071D74C /* XCRemoteSwiftPackageReference "mapbox-core-maps-ios" */; - productName = MapboxCoreMaps; - }; CAB77E3C2654AB310071D74C /* MapboxCoreMaps */ = { isa = XCSwiftPackageProductDependency; package = CAB77E3B2654AB310071D74C /* XCRemoteSwiftPackageReference "mapbox-core-maps-ios" */; From e3866f4b7aefb9d43c8cf4f905df8c61d51002bd Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 21 May 2021 11:38:49 -0400 Subject: [PATCH 06/15] Added MapboxCoreMaps to test host as dependency [run device tests] --- Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index 313ea3d3dbe..f1dfd640dc9 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -1750,6 +1750,9 @@ CA952ED0251C30B80099C080 /* PBXTargetDependency */, ); name = MapboxTestHost; + packageProductDependencies = ( + CAB77E3C2654AB310071D74C /* MapboxCoreMaps */, + ); productName = MapboxMapsTestHost; productReference = CA4453C52436E71500477B4F /* MapboxTestHost.app */; productType = "com.apple.product-type.application"; From 3ee854e9aa5007f23424125bcf733a1098eb2e90 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 21 May 2021 11:52:34 -0400 Subject: [PATCH 07/15] Try marking MapboxMaps's dependency as optional [run device tests] --- Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index f1dfd640dc9..8932814021f 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -242,6 +242,7 @@ CA19C342263B411C00748F1A /* MapInitOptionsTests.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5A6922A2627566A00A03412 /* MapInitOptionsTests.xib */; }; CA19C344263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; CA19C345263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; + CA28AAEE265807B600B486F2 /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3C2654AB310071D74C /* MapboxCoreMaps */; settings = {ATTRIBUTES = (Required, ); }; }; CA2E4A1B2538D3530096DEDE /* MapViewIntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA53616D2537ECA600A8AE38 /* MapViewIntegrationTestCase.swift */; }; CA2E4A1C2538D3530096DEDE /* IntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5361862537EE0600A8AE38 /* IntegrationTestCase.swift */; }; CA2E4A1D2538D3530096DEDE /* DidIdleFailureIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2E498825380B300096DEDE /* DidIdleFailureIntegrationTest.swift */; }; @@ -315,7 +316,7 @@ CA99A8702540CD1900D16C78 /* StyleLoadIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA99A86E2540CD1900D16C78 /* StyleLoadIntegrationTests.swift */; }; CA9F8CE32641F95C00A8BCB6 /* StyleManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA9F8CE22641F95C00A8BCB6 /* StyleManagerProtocol.swift */; }; CAA73A9D256F750B00E14EE0 /* FlyToTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA73A9B256F750B00E14EE0 /* FlyToTests.swift */; }; - CAB77E3D2654AB310071D74C /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3C2654AB310071D74C /* MapboxCoreMaps */; }; + CAB77E3D2654AB310071D74C /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3C2654AB310071D74C /* MapboxCoreMaps */; settings = {ATTRIBUTES = (Weak, ); }; }; CAB77E402654AB4F0071D74C /* MapboxMobileEvents in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3F2654AB4F0071D74C /* MapboxMobileEvents */; }; CAB77E432654AB6E0071D74C /* Turf in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E422654AB6E0071D74C /* Turf */; }; CAB77E452654AC5E0071D74C /* CameraAnimationsManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB77E442654AC5E0071D74C /* CameraAnimationsManagerProtocol.swift */; }; @@ -788,6 +789,7 @@ buildActionMask = 2147483647; files = ( CA952ECD251C30B80099C080 /* MapboxMaps.framework in Frameworks */, + CA28AAEE265807B600B486F2 /* MapboxCoreMaps in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1752,7 +1754,7 @@ name = MapboxTestHost; packageProductDependencies = ( CAB77E3C2654AB310071D74C /* MapboxCoreMaps */, - ); + ); productName = MapboxMapsTestHost; productReference = CA4453C52436E71500477B4F /* MapboxTestHost.app */; productType = "com.apple.product-type.application"; From fa327e3ea6aafedac2c56e858294a446cfce3fde Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 21 May 2021 12:23:13 -0400 Subject: [PATCH 08/15] Try DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC=YES [run device tests] --- Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index 8932814021f..cace0894c6a 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -316,7 +316,7 @@ CA99A8702540CD1900D16C78 /* StyleLoadIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA99A86E2540CD1900D16C78 /* StyleLoadIntegrationTests.swift */; }; CA9F8CE32641F95C00A8BCB6 /* StyleManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA9F8CE22641F95C00A8BCB6 /* StyleManagerProtocol.swift */; }; CAA73A9D256F750B00E14EE0 /* FlyToTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA73A9B256F750B00E14EE0 /* FlyToTests.swift */; }; - CAB77E3D2654AB310071D74C /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3C2654AB310071D74C /* MapboxCoreMaps */; settings = {ATTRIBUTES = (Weak, ); }; }; + CAB77E3D2654AB310071D74C /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3C2654AB310071D74C /* MapboxCoreMaps */; settings = {ATTRIBUTES = (Required, ); }; }; CAB77E402654AB4F0071D74C /* MapboxMobileEvents in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3F2654AB4F0071D74C /* MapboxMobileEvents */; }; CAB77E432654AB6E0071D74C /* Turf in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E422654AB6E0071D74C /* Turf */; }; CAB77E452654AC5E0071D74C /* CameraAnimationsManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB77E442654AC5E0071D74C /* CameraAnimationsManagerProtocol.swift */; }; @@ -2477,6 +2477,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = dwarf; + DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC = YES; ENABLE_TESTABILITY = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = "$(GCC_WARN_64_TO_32_BIT_CONVERSION)"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; @@ -2496,6 +2497,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC = YES; ENABLE_NS_ASSERTIONS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = "$(GCC_WARN_64_TO_32_BIT_CONVERSION)"; MTL_ENABLE_DEBUG_INFO = NO; From 18349e9d3aeb26eec1a04fc2466895574dcbb30c Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 21 May 2021 13:30:25 -0400 Subject: [PATCH 09/15] Test moving frameworks [run device tests] --- Makefile | 5 +++++ Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b8b44b8b8fb..4629245572c 100644 --- a/Makefile +++ b/Makefile @@ -333,6 +333,11 @@ $(DEVICE_FARM_UPLOAD_IPA): $(XCTESTRUN_PACKAGE) | $(DEVICE_TEST_PATH) $(PAYLOAD_ # Creating IPA package for upload cp -R $(BUILT_DEVICE_PRODUCTS_DIR)/$(APP_NAME).app $(PAYLOAD_DIR) + + # Test moving frameworks for AWS to re-codesign + cp -R $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks/*.framework/Frameworks/*.framework $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks + + cp $(XCTESTRUN_PACKAGE) $(PAYLOAD_DIR)/$(APP_NAME).app/xctestrun.zip -rm $(DEVICE_FARM_UPLOAD_IPA) diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index cace0894c6a..3259f51e6fc 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -242,7 +242,6 @@ CA19C342263B411C00748F1A /* MapInitOptionsTests.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5A6922A2627566A00A03412 /* MapInitOptionsTests.xib */; }; CA19C344263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; CA19C345263B412700748F1A /* empty-style-chicago.json in Resources */ = {isa = PBXBuildFile; fileRef = CA19C343263B412700748F1A /* empty-style-chicago.json */; }; - CA28AAEE265807B600B486F2 /* MapboxCoreMaps in Frameworks */ = {isa = PBXBuildFile; productRef = CAB77E3C2654AB310071D74C /* MapboxCoreMaps */; settings = {ATTRIBUTES = (Required, ); }; }; CA2E4A1B2538D3530096DEDE /* MapViewIntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA53616D2537ECA600A8AE38 /* MapViewIntegrationTestCase.swift */; }; CA2E4A1C2538D3530096DEDE /* IntegrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5361862537EE0600A8AE38 /* IntegrationTestCase.swift */; }; CA2E4A1D2538D3530096DEDE /* DidIdleFailureIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2E498825380B300096DEDE /* DidIdleFailureIntegrationTest.swift */; }; @@ -789,7 +788,6 @@ buildActionMask = 2147483647; files = ( CA952ECD251C30B80099C080 /* MapboxMaps.framework in Frameworks */, - CA28AAEE265807B600B486F2 /* MapboxCoreMaps in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1753,7 +1751,6 @@ ); name = MapboxTestHost; packageProductDependencies = ( - CAB77E3C2654AB310071D74C /* MapboxCoreMaps */, ); productName = MapboxMapsTestHost; productReference = CA4453C52436E71500477B4F /* MapboxTestHost.app */; From 2d9bbff3b70e3d82db75a0d12327f2a2f174c4ed Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 21 May 2021 22:21:37 -0400 Subject: [PATCH 10/15] Update build directory [run device tests] --- .circleci/config.yml | 50 +++++++++++++++++++++++++------------------- Makefile | 49 +++++++++++++++++++++++++++++++------------ 2 files changed, 64 insertions(+), 35 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 59c452456b2..3e0ecdfebcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -381,26 +381,32 @@ jobs: # get xcresults here, may be zipped with more than one result - run: name: "Gathering results" - command: make gather-results + command: make gather-results BUILD_DIR="$DERIVED_DATA_PATH" when: always - run: name: "Parsing xcresults for errors" command: | - RESULTS=`find build/testruns -name '*.xcresult'` - xargs swift run --package-path scripts/xcparty xcparty \<<< "$RESULTS" | tee build/testruns/failures.txt + RESULTS=`find "$DERIVED_DATA_PATH/testruns" -name '*.xcresult'` + xargs swift run --package-path scripts/xcparty xcparty \<<< "$RESULTS" | tee "$DERIVED_DATA_PATH/testruns/failures.txt" when: on_fail - run: name: Symbolicate crash logs - command: make symbolicate SCHEME=<< parameters.scheme >> APP_NAME=<< parameters.app-name >> CONFIGURATION=Release - when: always - # - run: - # name: Converting and uploading coverage - # command: | - # make device-update-codecov-with-profdata \ - # SCHEME=<< parameters.scheme >> \ - # APP_NAME=<< parameters.app-name >> \ - # CONFIGURATION=Release \ - # COVERAGE_MAPBOX_MAPS_DEVICE=build/Build/Products/Release-iphoneos/MapboxMaps.framework/MapboxMaps + command: | + make symbolicate \ + SCHEME=<< parameters.scheme >> \ + APP_NAME=<< parameters.app-name >> \ + CONFIGURATION=Release \ + BUILD_DIR="$DERIVED_DATA_PATH" + when: always + - run: + name: Converting and uploading coverage + command: | + make device-update-codecov-with-profdata \ + SCHEME=<< parameters.scheme >> \ + APP_NAME=<< parameters.app-name >> \ + CONFIGURATION=Release \ + BUILD_DIR="$DERIVED_DATA_PATH" \ + COVERAGE_MAPBOX_MAPS_DEVICE="$DERIVED_DATA_PATH/Build/Products/Release-iphoneos/MapboxMaps.framework/MapboxMaps" - store-device-farm-artifacts - store-logs - report-failure: @@ -459,15 +465,15 @@ jobs: CONFIGURATION=Release \ BUILD_DIR="$DERIVED_DATA_PATH" when: always - # - run: - # name: Converting and uploading coverage - # command: | - # pip3 install awscli gitpython - # make device-update-codecov-with-profdata \ - # SCHEME=<< parameters.scheme >> \ - # APP_NAME=<< parameters.app-name >> \ - # CONFIGURATION=Release \ - # BUILD_DIR="$DERIVED_DATA_PATH" + - run: + name: Converting and uploading coverage + command: | + pip3 install awscli gitpython + make device-update-codecov-with-profdata \ + SCHEME=<< parameters.scheme >> \ + APP_NAME=<< parameters.app-name >> \ + CONFIGURATION=Release \ + BUILD_DIR="$DERIVED_DATA_PATH" - store-device-farm-artifacts: derived_data_path: $DERIVED_DATA_PATH - store-logs: diff --git a/Makefile b/Makefile index 4629245572c..e25e5d94813 100644 --- a/Makefile +++ b/Makefile @@ -394,26 +394,48 @@ COVERAGE_ROOT_DIR ?= $(BUILD_DIR)/Build/ProfileData COVERAGE_MAPBOX_MAPS ?= $(BUILD_DIR)/Build/Products/$(CONFIGURATION)-iphonesimulator/MapboxMaps.o COVERAGE_ARCH ?= x86_64 +# .PHONY: update-codecov-with-profdata +# update-codecov-with-profdata: +# curl -sSfL --retry 5 --connect-timeout 5 https://codecov.io/bash > /tmp/codecov.sh +# @PROF_DATA=`find $(COVERAGE_ROOT_DIR) -regex '.*\.profraw'` ; \ +# for RESULT in $${PROF_DATA[@]} ; \ +# do \ +# echo "Generating $${RESULT}.lcov" ; \ +# xcrun llvm-profdata merge -o $${RESULT}.profdata $${RESULT} ; \ +# xcrun llvm-cov export \ +# $(COVERAGE_MAPBOX_MAPS) \ +# -instr-profile=$${RESULT}.profdata \ +# -arch=$(COVERAGE_ARCH) \ +# -format=lcov > $${RESULT}.lcov ; \ +# echo "Uploading $${RESULT}.lcov to CodeCov.io" ; \ +# bash /tmp/codecov.sh \ +# -f $${RESULT}.lcov \ +# -t $(CODECOV_TOKEN) \ +# -J '^MapboxMaps$$' \ +# -n $${RESULT}.lcov \ +# -F "$$(echo '$(SCHEME)' | sed 's/[[:upper:]]/_&/g;s/^_//' | tr '[:upper:]' '[:lower:]')" ; \ +# echo "Generating lcov JSON" ; \ +# xcrun llvm-cov export \ +# $(COVERAGE_MAPBOX_MAPS) \ +# -instr-profile=$${RESULT}.profdata \ +# -arch=$(COVERAGE_ARCH) \ +# -format=text | python3 -m json.tool > $${RESULT}.json ; \ +# echo "Uploading to S3" ; \ +# python3 ./scripts/code-coverage/parse-code-coverage.py \ +# -g . \ +# -c MapboxMaps \ +# --scheme $(SCHEME) \ +# --report $${RESULT}.json ; \ +# done +# @echo "Done" + .PHONY: update-codecov-with-profdata update-codecov-with-profdata: - curl -sSfL --retry 5 --connect-timeout 5 https://codecov.io/bash > /tmp/codecov.sh @PROF_DATA=`find $(COVERAGE_ROOT_DIR) -regex '.*\.profraw'` ; \ for RESULT in $${PROF_DATA[@]} ; \ do \ echo "Generating $${RESULT}.lcov" ; \ xcrun llvm-profdata merge -o $${RESULT}.profdata $${RESULT} ; \ - xcrun llvm-cov export \ - $(COVERAGE_MAPBOX_MAPS) \ - -instr-profile=$${RESULT}.profdata \ - -arch=$(COVERAGE_ARCH) \ - -format=lcov > $${RESULT}.lcov ; \ - echo "Uploading $${RESULT}.lcov to CodeCov.io" ; \ - bash /tmp/codecov.sh \ - -f $${RESULT}.lcov \ - -t $(CODECOV_TOKEN) \ - -J '^MapboxMaps$$' \ - -n $${RESULT}.lcov \ - -F "$$(echo '$(SCHEME)' | sed 's/[[:upper:]]/_&/g;s/^_//' | tr '[:upper:]' '[:lower:]')" ; \ echo "Generating lcov JSON" ; \ xcrun llvm-cov export \ $(COVERAGE_MAPBOX_MAPS) \ @@ -429,6 +451,7 @@ update-codecov-with-profdata: done @echo "Done" + COVERAGE_MAPBOX_MAPS_DEVICE ?= $(BUILT_DEVICE_PRODUCTS_DIR)/MapboxMaps.o .PHONY: device-update-codecov-with-profdata From ba041449cfaa0ee7b0d9500a9f21dd0cda68b6d6 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 21 May 2021 23:00:23 -0400 Subject: [PATCH 11/15] Log storage --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e0ecdfebcf..f56d63cae1b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -407,8 +407,10 @@ jobs: CONFIGURATION=Release \ BUILD_DIR="$DERIVED_DATA_PATH" \ COVERAGE_MAPBOX_MAPS_DEVICE="$DERIVED_DATA_PATH/Build/Products/Release-iphoneos/MapboxMaps.framework/MapboxMaps" - - store-device-farm-artifacts - - store-logs + - store-device-farm-artifacts: + derived_data_path: $DERIVED_DATA_PATH + - store-logs: + derived_data_path: $DERIVED_DATA_PATH - report-failure: report_failure: << parameters.report_failure >> message: "<< parameters.scheme >> device tests" From ce4092150ad284fdbcd0b421f2db36ae5bc113c4 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 May 2021 16:46:47 -0400 Subject: [PATCH 12/15] Test with mv [run device tests] [run app device tests] --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e25e5d94813..67770f97cb5 100644 --- a/Makefile +++ b/Makefile @@ -335,8 +335,7 @@ $(DEVICE_FARM_UPLOAD_IPA): $(XCTESTRUN_PACKAGE) | $(DEVICE_TEST_PATH) $(PAYLOAD_ cp -R $(BUILT_DEVICE_PRODUCTS_DIR)/$(APP_NAME).app $(PAYLOAD_DIR) # Test moving frameworks for AWS to re-codesign - cp -R $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks/*.framework/Frameworks/*.framework $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks - + mv $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks/*.framework/Frameworks/*.framework $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks cp $(XCTESTRUN_PACKAGE) $(PAYLOAD_DIR)/$(APP_NAME).app/xctestrun.zip From 856ea546a0240e4e80137c478736c40c508f40f2 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 May 2021 17:14:04 -0400 Subject: [PATCH 13/15] Fix lint errors [run device tests] [run app device tests] --- Makefile | 4 ++-- Sources/MapboxMaps/Foundation/MapboxMap.swift | 3 +++ Sources/MapboxMaps/MapView/MapView+Supportable.swift | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 67770f97cb5..6d5d1a70c5f 100644 --- a/Makefile +++ b/Makefile @@ -334,8 +334,8 @@ $(DEVICE_FARM_UPLOAD_IPA): $(XCTESTRUN_PACKAGE) | $(DEVICE_TEST_PATH) $(PAYLOAD_ # Creating IPA package for upload cp -R $(BUILT_DEVICE_PRODUCTS_DIR)/$(APP_NAME).app $(PAYLOAD_DIR) - # Test moving frameworks for AWS to re-codesign - mv $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks/*.framework/Frameworks/*.framework $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks + # Test moving frameworks for AWS to re-codesign (if they exist) + mv $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks/*.framework/Frameworks/*.framework $(PAYLOAD_DIR)/$(APP_NAME).app/Frameworks || true cp $(XCTESTRUN_PACKAGE) $(PAYLOAD_DIR)/$(APP_NAME).app/xctestrun.zip diff --git a/Sources/MapboxMaps/Foundation/MapboxMap.swift b/Sources/MapboxMaps/Foundation/MapboxMap.swift index 3cd491642e1..b5348ac9ee7 100644 --- a/Sources/MapboxMaps/Foundation/MapboxMap.swift +++ b/Sources/MapboxMaps/Foundation/MapboxMap.swift @@ -1,3 +1,4 @@ +// swiftlint:disable file_length import MapboxCoreMaps import Turf import UIKit @@ -290,7 +291,9 @@ extension MapboxMap: CameraManagerProtocol { let expected = __map.setBoundsFor(options) if expected.isError() { + // swiftlint:disable force_cast throw MapError(coreError: expected.error as! NSString) + // swiftlint:enable force_cast } } diff --git a/Sources/MapboxMaps/MapView/MapView+Supportable.swift b/Sources/MapboxMaps/MapView/MapView+Supportable.swift index 63d3178794e..b0551d9fb78 100644 --- a/Sources/MapboxMaps/MapView/MapView+Supportable.swift +++ b/Sources/MapboxMaps/MapView/MapView+Supportable.swift @@ -35,7 +35,7 @@ extension MapView: LocationSupportableMapView { public func point(for coordinate: CLLocationCoordinate2D) -> CGPoint { return mapboxMap.point(for: coordinate) } - + public func metersPerPointAtLatitude(latitude: CLLocationDegrees) -> CLLocationDistance { return Projection.getMetersPerPixelAtLatitude(forLatitude: latitude, zoom: Double(cameraState.zoom)) } From 14f683efde83d386866b02c62074757e5041d80c Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 May 2021 18:09:50 -0400 Subject: [PATCH 14/15] Minor clean up [run device tests] --- .circleci/config.yml | 2 -- Makefile | 1 - Mapbox/MapboxMaps.xcodeproj/project.pbxproj | 2 -- 3 files changed, 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f56d63cae1b..2f330b11684 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -356,8 +356,6 @@ jobs: command: make install-devicefarm-dependencies - install-dependencies - - # There's a command for this, but it only works if run *after* the build. # In this case, we need to determine the derived data path *before* building. - run: diff --git a/Makefile b/Makefile index 6d5d1a70c5f..45b0d3e2a59 100644 --- a/Makefile +++ b/Makefile @@ -450,7 +450,6 @@ update-codecov-with-profdata: done @echo "Done" - COVERAGE_MAPBOX_MAPS_DEVICE ?= $(BUILT_DEVICE_PRODUCTS_DIR)/MapboxMaps.o .PHONY: device-update-codecov-with-profdata diff --git a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj index 3259f51e6fc..3bae27573fa 100644 --- a/Mapbox/MapboxMaps.xcodeproj/project.pbxproj +++ b/Mapbox/MapboxMaps.xcodeproj/project.pbxproj @@ -2474,7 +2474,6 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = dwarf; - DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC = YES; ENABLE_TESTABILITY = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = "$(GCC_WARN_64_TO_32_BIT_CONVERSION)"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; @@ -2494,7 +2493,6 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC = YES; ENABLE_NS_ASSERTIONS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = "$(GCC_WARN_64_TO_32_BIT_CONVERSION)"; MTL_ENABLE_DEBUG_INFO = NO; From 3bf07691b5b1c9e0923c1c18e4c910b1af1417d0 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 May 2021 19:04:07 -0400 Subject: [PATCH 15/15] Update change log --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13598c9d0a5..3fa055c0a0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ Mapbox welcomes participation and contributions from everyone. - Introduced separate minZoom/maxZoom fields into CustomGeometrySourceOptions API instead of the formerly used `zoomRange` - Improved zooming performance. - Fixed terrain transparency issue when a sky layer is not used. +- `MapboxMap.__map` is now private. ([#374](https://github.com/mapbox/mapbox-maps-ios/pull/374)) +- Added `CameraManagerProtocol.setCameraBounds`, `MapboxMap.prefetchZoomDelta`, `MapboxMap.options`, `MapboxMap.reduceMemoryUse()`, `MapboxMap.resourceOptions` and `MapboxMap.elevation(at:)`. ([#374](https://github.com/mapbox/mapbox-maps-ios/pull/374)) +- Removed `OfflineError.invalidResult` and `OfflineError.typeMismatch`. ([#374](https://github.com/mapbox/mapbox-maps-ios/pull/374)) ### Features ✨ and improvements 🏁