diff --git a/CHANGELOG.md b/CHANGELOG.md index f103885d8f87..a5b4b7743d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone. * Add support for runtime source properties. ([#1267](https://github.com/mapbox/mapbox-maps-ios/pull/1267)) * Start location services lazily. ([#1262](https://github.com/mapbox/mapbox-maps-ios/pull/1262)) +* Fix localization crash on iOS 11 and 12. ([#1278](https://github.com/mapbox/mapbox-maps-ios/pull/1278)) ## 10.5.0-beta.1 - April 7, 2022 diff --git a/Sources/MapboxMaps/Style/Style+Localization.swift b/Sources/MapboxMaps/Style/Style+Localization.swift index d4ed7d92ba26..950ae7da3827 100644 --- a/Sources/MapboxMaps/Style/Style+Localization.swift +++ b/Sources/MapboxMaps/Style/Style+Localization.swift @@ -83,8 +83,8 @@ extension Style { let expressionAbbr = try NSRegularExpression(pattern: "\\[\"get\",\\s*\"abbr\"\\]", options: .caseInsensitive) - if var stringExpression = String(data: try JSONEncoder().encode(symbolLayer.textField), encoding: .utf8), - stringExpression != "null" { + if case .expression(let textField) = symbolLayer.textField, + var stringExpression = String(data: try JSONEncoder().encode(textField), encoding: .utf8) { stringExpression.updateOnceExpression(replacement: replacement, regex: expressionCoalesce) stringExpression.updateExpression(replacement: replacement, regex: expressionAbbr)