From 7157fcd4bcd742a0597ab2d4e48cc7201f9a9395 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Wed, 27 Mar 2019 09:58:41 -0400 Subject: [ios, core] Updates project for iOS SDK 12.2 / Always use vendored optional (#14241) --- circle.yml | 27 ++++++++++++++++++++++ cmake/loop-darwin.cmake | 4 ++++ platform/darwin/src/NSBundle+MGLAdditions.m | 7 +++++- platform/darwin/test/MGLAttributionInfoTests.m | 15 ++++++++++-- platform/darwin/test/MGLOfflineStorageTests.mm | 9 ++++---- .../MGLAnnotationViewIntegrationTests.m | 1 - .../Integration Tests/MGLCameraTransitionTests.mm | 2 +- platform/ios/ios.xcodeproj/project.pbxproj | 6 ++--- platform/ios/src/MGLMapView.mm | 13 +++++++---- vendor/optional.cmake | 10 +++----- 10 files changed, 70 insertions(+), 24 deletions(-) diff --git a/circle.yml b/circle.yml index b47281cf26..063df5573b 100644 --- a/circle.yml +++ b/circle.yml @@ -44,6 +44,8 @@ workflows: - linux-gcc5-debug-coverage - linux-doxygen - ios-debug + - ios-debug-xcode-102: + name: ios-debug-xcode-10.2 - ios-release-template: name: ios-release - ios-release-tag: @@ -924,6 +926,31 @@ jobs: - collect-xcode-build-logs - upload-xcode-build-logs +# ------------------------------------------------------------------------------ + ios-debug-xcode-102: + macos: + xcode: "10.2.0" + environment: + BUILDTYPE: Debug + HOMEBREW_NO_AUTO_UPDATE: 1 + steps: + - install-macos-dependencies + - install-dependencies + - build-ios-test + - check-public-symbols + - run: + name: Check symbol namespacing for mapbox-events-ios + command: make ios-check-events-symbols + - run: + name: Lint plist files + command: make ios-lint + - run: + name: Nitpick Darwin code generation + command: scripts/nitpick/generated-code.js darwin + - save-dependencies + - collect-xcode-build-logs + - upload-xcode-build-logs + # ------------------------------------------------------------------------------ ios-sanitize-nightly: macos: diff --git a/cmake/loop-darwin.cmake b/cmake/loop-darwin.cmake index a330375653..46d8f9edc0 100644 --- a/cmake/loop-darwin.cmake +++ b/cmake/loop-darwin.cmake @@ -7,6 +7,10 @@ target_include_directories(mbgl-loop-darwin PRIVATE src ) +target_link_libraries(mbgl-loop-darwin PUBLIC + optional +) + create_source_groups(mbgl-loop-darwin) set_target_properties(mbgl-loop-darwin PROPERTIES FOLDER "Core") diff --git a/platform/darwin/src/NSBundle+MGLAdditions.m b/platform/darwin/src/NSBundle+MGLAdditions.m index d472e40b1f..da70a95373 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.m +++ b/platform/darwin/src/NSBundle+MGLAdditions.m @@ -35,10 +35,15 @@ const MGLExceptionName MGLBundleNotFoundException = @"MGLBundleNotFoundException + (nullable NSString *)mgl_applicationBundleIdentifier { NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier; + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && (__IPHONE_OS_VERSION_MAX_ALLOWED < 120200)) || \ + (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 101404)) + // Before SDK 12.2 (bundled with Xcode 10.2): There’s no main bundle identifier when running in a unit test bundle. + // 12.2 and after: the above bundle identifier is: com.apple.dt.xctest.tool if (!bundleIdentifier) { - // There’s no main bundle identifier when running in a unit test bundle. bundleIdentifier = [NSBundle bundleForClass:[MGLAccountManager class]].bundleIdentifier; } +#endif return bundleIdentifier; } diff --git a/platform/darwin/test/MGLAttributionInfoTests.m b/platform/darwin/test/MGLAttributionInfoTests.m index 48779f3407..b6f053a8af 100644 --- a/platform/darwin/test/MGLAttributionInfoTests.m +++ b/platform/darwin/test/MGLAttributionInfoTests.m @@ -55,10 +55,21 @@ XCTAssertEqualObjects(infos[3].URL, [NSURL URLWithString:@"https://apps.mapbox.com/feedback/"]); XCTAssertTrue(infos[3].feedbackLink); NSURL *styleURL = [MGLStyle satelliteStreetsStyleURLWithVersion:99]; + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 120200) || \ + (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101404) + NSString *bundleId = @"com.apple.dt.xctest.tool"; +#else + NSString *bundleId = @"com.mapbox.Mapbox"; +#endif + + NSString *urlString = [NSString stringWithFormat:@"https://apps.mapbox.com/feedback/?referrer=%@#/77.63680/12.98108/14.00/0.0/0", bundleId]; XCTAssertEqualObjects([infos[3] feedbackURLAtCenterCoordinate:mapbox zoomLevel:14], - [NSURL URLWithString:@"https://apps.mapbox.com/feedback/?referrer=com.mapbox.Mapbox#/77.63680/12.98108/14.00/0.0/0"]); + [NSURL URLWithString:urlString]); + + urlString = [NSString stringWithFormat:@"https://apps.mapbox.com/feedback/?referrer=%@&owner=mapbox&id=satellite-streets-v99&access_token=pk.feedcafedeadbeefbadebede&map_sdk_version=1.0.0#/77.63680/12.98108/3.14/90.9/13", bundleId]; XCTAssertEqualObjects([infos[3] feedbackURLForStyleURL:styleURL atCenterCoordinate:mapbox zoomLevel:3.14159 direction:90.9 pitch:12.5], - [NSURL URLWithString:@"https://apps.mapbox.com/feedback/?referrer=com.mapbox.Mapbox&owner=mapbox&id=satellite-streets-v99&access_token=pk.feedcafedeadbeefbadebede&map_sdk_version=1.0.0#/77.63680/12.98108/3.14/90.9/13"]); + [NSURL URLWithString:urlString]); } - (void)testStyle { diff --git a/platform/darwin/test/MGLOfflineStorageTests.mm b/platform/darwin/test/MGLOfflineStorageTests.mm index 7f0ead7cab..86dc28eb04 100644 --- a/platform/darwin/test/MGLOfflineStorageTests.mm +++ b/platform/darwin/test/MGLOfflineStorageTests.mm @@ -1,6 +1,7 @@ #import #import "MGLOfflineStorage_Private.h" +#import "NSBundle+MGLAdditions.h" #import "NSDate+MGLAdditions.h" #import @@ -10,7 +11,6 @@ #pragma clang diagnostic ignored "-Wshadow" @interface MGLOfflineStorageTests : XCTestCase - @end @implementation MGLOfflineStorageTests @@ -21,8 +21,7 @@ appropriateForURL:nil create:NO error:nil]; - // Unit tests don't use the main bundle; use com.mapbox.ios.sdk instead. - NSString *bundleIdentifier = [NSBundle bundleForClass:[MGLMapView class]].bundleIdentifier; + NSString *bundleIdentifier = [NSBundle mgl_applicationBundleIdentifier]; cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:@".mapbox"]; XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:cacheDirectoryURL.path], @"Cache subdirectory should exist."); @@ -208,8 +207,8 @@ appropriateForURL:nil create:NO error:nil]; - // Unit tests don't use the main bundle; use com.mapbox.ios.sdk instead. - NSString *bundleIdentifier = [NSBundle bundleForClass:[MGLMapView class]].bundleIdentifier; + // As of iOS SDK 12.2 unit tests now have a bundle id: com.apple.dt.xctest.tool + NSString *bundleIdentifier = [NSBundle mgl_applicationBundleIdentifier]; cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:@".mapbox"]; XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:cacheDirectoryURL.path], @"Cache subdirectory should exist."); diff --git a/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m b/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m index 7ec45de072..0b32df55b4 100644 --- a/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m +++ b/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m @@ -405,7 +405,6 @@ static const CGFloat kAnnotationScale = 0.125f; NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReuseIdentifer"; - CGFloat epsilon = 0.0000001; CGSize size = self.mapView.bounds.size; CGSize annotationSize = CGSizeMake(40.0, 40.0); diff --git a/platform/ios/Integration Tests/MGLCameraTransitionTests.mm b/platform/ios/Integration Tests/MGLCameraTransitionTests.mm index e422c46cf4..60d5fc6c9a 100644 --- a/platform/ios/Integration Tests/MGLCameraTransitionTests.mm +++ b/platform/ios/Integration Tests/MGLCameraTransitionTests.mm @@ -277,7 +277,7 @@ // Now set another coordinate. MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:target2 - fromDistance:altitude + altitude:altitude pitch:0.0 heading:0.0]; diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 535f83728f..2e09e9063f 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -3677,7 +3677,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Integration Tests/integration-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Integration Test Harness.app/Integration Test Harness"; }; @@ -3707,7 +3707,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.integration-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Integration Tests/integration-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Integration Test Harness.app/Integration Test Harness"; }; @@ -3991,7 +3991,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.integration-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Integration Tests/integration-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Integration Test Harness.app/Integration Test Harness"; }; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index bf2421521f..51db11ab8c 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2508,10 +2508,15 @@ public: { MGLLogInfo(@"Resetting the map to the current style’s default viewport."); auto camera = self.mbglMap.getStyle().getDefaultCamera(); - CGFloat pitch = *camera.pitch; - CLLocationDirection heading = mbgl::util::wrap(*camera.bearing, 0., 360.); - CLLocationDistance altitude = MGLAltitudeForZoomLevel(*camera.zoom, pitch, 0, self.frame.size); - self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(*camera.center) + + double pitch = camera.pitch ? *camera.pitch : 0.0; + double bearing = camera.bearing ? *camera.bearing : 0.0; + double zoom = camera.zoom ? *camera.zoom : 0.0; + mbgl::LatLng center = camera.center ? *camera.center : mbgl::LatLng(); + + CLLocationDirection heading = mbgl::util::wrap(bearing, 0., 360.); + CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoom, pitch, 0, self.frame.size); + self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(center) altitude:altitude pitch:pitch heading:heading]; diff --git a/vendor/optional.cmake b/vendor/optional.cmake index fa299da6a6..ed7bfe8a38 100644 --- a/vendor/optional.cmake +++ b/vendor/optional.cmake @@ -1,9 +1,5 @@ add_library(optional INTERFACE) -# This polyfill is needed for Windows and Android since these standard libraries don't ship with -# usable versions of -if(WIN32 OR MBGL_PLATFORM STREQUAL "android") - target_include_directories(optional SYSTEM INTERFACE - ${CMAKE_SOURCE_DIR}/vendor/optional/include - ) -endif() +target_include_directories(optional SYSTEM INTERFACE + ${CMAKE_SOURCE_DIR}/vendor/optional/include +) -- cgit v1.2.1