From cf295de16eee1073de46905bf32ee9f3b6cb0419 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 11 Jun 2018 10:35:05 -0400 Subject: [PATCH 1/4] Fixed crash in iOS 9.3 (accessing NSLocale.languageCode) --- platform/darwin/src/MGLVectorTileSource.mm | 4 +++- platform/ios/CHANGELOG.md | 1 + platform/macos/CHANGELOG.md | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/darwin/src/MGLVectorTileSource.mm b/platform/darwin/src/MGLVectorTileSource.mm index e55ed130601..af63c23f67a 100644 --- a/platform/darwin/src/MGLVectorTileSource.mm +++ b/platform/darwin/src/MGLVectorTileSource.mm @@ -109,7 +109,9 @@ + (NSString *)preferredMapboxStreetsLanguage { + (NSString *)preferredMapboxStreetsLanguageForPreferences:(NSArray *)preferencesArray { BOOL acceptsEnglish = [preferencesArray filteredArrayUsingPredicate: [NSPredicate predicateWithBlock:^BOOL(NSString * _Nullable language, NSDictionary * _Nullable bindings) { - return [[NSLocale localeWithLocaleIdentifier:language].languageCode isEqualToString:@"en"]; + + NSString *languageCode = [[NSLocale localeWithLocaleIdentifier:language] objectForKey:NSLocaleLanguageCode]; + return [languageCode isEqualToString:@"en"]; }]].count; NSArray *availableLanguages = acceptsEnglish ? MGLMapboxStreetsLanguages : MGLMapboxStreetsAlternativeLanguages; diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 04565658057..836ea48ff01 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -21,6 +21,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added custom `-hitTest:withEvent:` to `MGLSMCalloutView` to avoid registering taps in transparent areas of the standard annotation callout. ([#11939](https://github.com/mapbox/mapbox-gl-native/pull/11939)) * Improved performance and memory impact of `MGLScaleBar`. ([#11921](https://github.com/mapbox/mapbox-gl-native/pull/11921)) * Fixed race conditions that could cause crashes when re-using `MGLMapSnapshotter` or using multiple snapshotters at the same time. ([#11831](https://github.com/mapbox/mapbox-gl-native/pull/11831)) +* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0) ## 4.0.2 - May 29, 2018 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 8d5f450268a..4ae948b53a7 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -16,6 +16,7 @@ * Adjusted when and how the camera transition update and finish callbacks are called, fixing recursion bugs. ([#11614](https://github.com/mapbox/mapbox-gl-native/pull/11614)) * Fixed an issue preventing nested key path expressions get parsed accordingly to the spec. ([#11959](https://github.com/mapbox/mapbox-gl-native/pull/11959)) * Fixed race conditions that could cause crashes when re-using `MGLMapSnapshotter` or using multiple snapshotters at the same time. ([#11831](https://github.com/mapbox/mapbox-gl-native/pull/11831)) +* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0) ## 0.7.1 From d488dea118da4217e252c17902276ac8768e6c59 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 11 Jun 2018 10:42:20 -0400 Subject: [PATCH 2/4] Updated changelogs --- platform/ios/CHANGELOG.md | 2 +- platform/macos/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 836ea48ff01..541dfee38d8 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -21,7 +21,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added custom `-hitTest:withEvent:` to `MGLSMCalloutView` to avoid registering taps in transparent areas of the standard annotation callout. ([#11939](https://github.com/mapbox/mapbox-gl-native/pull/11939)) * Improved performance and memory impact of `MGLScaleBar`. ([#11921](https://github.com/mapbox/mapbox-gl-native/pull/11921)) * Fixed race conditions that could cause crashes when re-using `MGLMapSnapshotter` or using multiple snapshotters at the same time. ([#11831](https://github.com/mapbox/mapbox-gl-native/pull/11831)) -* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0) +* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0) ([#12123](https://github.com/mapbox/mapbox-gl-native/pull/12123)) ## 4.0.2 - May 29, 2018 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 4ae948b53a7..33a231fe3cb 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -16,7 +16,7 @@ * Adjusted when and how the camera transition update and finish callbacks are called, fixing recursion bugs. ([#11614](https://github.com/mapbox/mapbox-gl-native/pull/11614)) * Fixed an issue preventing nested key path expressions get parsed accordingly to the spec. ([#11959](https://github.com/mapbox/mapbox-gl-native/pull/11959)) * Fixed race conditions that could cause crashes when re-using `MGLMapSnapshotter` or using multiple snapshotters at the same time. ([#11831](https://github.com/mapbox/mapbox-gl-native/pull/11831)) -* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0) +* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0, and used in Darwin code) ([#12123](https://github.com/mapbox/mapbox-gl-native/pull/12123)) ## 0.7.1 From acfc9bd6bc110809cccd4436905d2797a9ea6b67 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 11 Jun 2018 14:42:06 -0400 Subject: [PATCH 3/4] Updated to use @available --- platform/darwin/src/MGLVectorTileSource.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/darwin/src/MGLVectorTileSource.mm b/platform/darwin/src/MGLVectorTileSource.mm index af63c23f67a..88ddee1d98e 100644 --- a/platform/darwin/src/MGLVectorTileSource.mm +++ b/platform/darwin/src/MGLVectorTileSource.mm @@ -109,8 +109,15 @@ + (NSString *)preferredMapboxStreetsLanguage { + (NSString *)preferredMapboxStreetsLanguageForPreferences:(NSArray *)preferencesArray { BOOL acceptsEnglish = [preferencesArray filteredArrayUsingPredicate: [NSPredicate predicateWithBlock:^BOOL(NSString * _Nullable language, NSDictionary * _Nullable bindings) { + NSString *languageCode; + + if (@available(iOS 10.0, macOS 10.12.0, *)) { + languageCode = [NSLocale localeWithLocaleIdentifier:language].languageCode; + } + else { + languageCode = [[NSLocale localeWithLocaleIdentifier:language] objectForKey:NSLocaleLanguageCode]; + } - NSString *languageCode = [[NSLocale localeWithLocaleIdentifier:language] objectForKey:NSLocaleLanguageCode]; return [languageCode isEqualToString:@"en"]; }]].count; From 8308bf422756095ec911568292e478b019e52fb3 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 11 Jun 2018 15:02:47 -0400 Subject: [PATCH 4/4] Updated changelogs --- platform/ios/CHANGELOG.md | 2 +- platform/macos/CHANGELOG.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 541dfee38d8..df03f42cf38 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -21,7 +21,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added custom `-hitTest:withEvent:` to `MGLSMCalloutView` to avoid registering taps in transparent areas of the standard annotation callout. ([#11939](https://github.com/mapbox/mapbox-gl-native/pull/11939)) * Improved performance and memory impact of `MGLScaleBar`. ([#11921](https://github.com/mapbox/mapbox-gl-native/pull/11921)) * Fixed race conditions that could cause crashes when re-using `MGLMapSnapshotter` or using multiple snapshotters at the same time. ([#11831](https://github.com/mapbox/mapbox-gl-native/pull/11831)) -* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0) ([#12123](https://github.com/mapbox/mapbox-gl-native/pull/12123)) +* Fixed crash in `-[MGLStyle localizeLabelsIntoLocale:]` on iOS 9.3 (attempting to access a property that was introduced in iOS 10.0) ([#12123](https://github.com/mapbox/mapbox-gl-native/pull/12123)) ## 4.0.2 - May 29, 2018 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 33a231fe3cb..2a9eb13a88d 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -16,7 +16,8 @@ * Adjusted when and how the camera transition update and finish callbacks are called, fixing recursion bugs. ([#11614](https://github.com/mapbox/mapbox-gl-native/pull/11614)) * Fixed an issue preventing nested key path expressions get parsed accordingly to the spec. ([#11959](https://github.com/mapbox/mapbox-gl-native/pull/11959)) * Fixed race conditions that could cause crashes when re-using `MGLMapSnapshotter` or using multiple snapshotters at the same time. ([#11831](https://github.com/mapbox/mapbox-gl-native/pull/11831)) -* Fixed crash on iOS 9.3 (`NSLocale.languageCode` introduced in iOS 10.0, and used in Darwin code) ([#12123](https://github.com/mapbox/mapbox-gl-native/pull/12123)) +* Fixed crash in `-[MGLStyle localizeLabelsIntoLocale:]` on iOS 9.3 (attempting to access a property that was introduced in iOS 10.0 and used in Darwin code) ([#12123](https://github.com/mapbox/mapbox-gl-native/pull/12123)) + ## 0.7.1