Skip to content

Commit

Permalink
Fix localization crash on iOS 11 and 12
Browse files Browse the repository at this point in the history
* Style.localizeLabels(into:forLayerIds:) crashed on iOS 11 and 12 if
  any of the symbol layers had text-field set to nil.

Fixes #954
  • Loading branch information
macdrevx committed Apr 15, 2022
1 parent a203376 commit b9ee0f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Sources/MapboxMaps/Style/Style+Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b9ee0f2

Please sign in to comment.