diff --git a/Apps/Examples/Examples/All Examples/BasicMapExample.swift b/Apps/Examples/Examples/All Examples/BasicMapExample.swift index 79a9387bd050..a0cc6cf995a8 100644 --- a/Apps/Examples/Examples/All Examples/BasicMapExample.swift +++ b/Apps/Examples/Examples/All Examples/BasicMapExample.swift @@ -21,20 +21,6 @@ final class BasicMapExample: UIViewController, ExampleProtocol { view.addSubview(mapView) - let targets = [ - FeaturesetQueryTarget( - featureset: .layer("my-layer"), - filter: Exp(.eq) { - Exp(.get) { "type" } - "hotel" - } - ), - FeaturesetQueryTarget(featureset: .featureset("poi", importId: "basemap")) - ] - mapView.mapboxMap.queryRenderedFeatures(with: CGPoint(x: 0, y: 0), - targets: targets) { _ in - // handle features in result - } } override func viewDidAppear(_ animated: Bool) { diff --git a/Sources/MapboxMaps/Style/Style+Localization.swift b/Sources/MapboxMaps/Style/Style+Localization.swift index 1d28d54252f8..c60b62b8c8d4 100644 --- a/Sources/MapboxMaps/Style/Style+Localization.swift +++ b/Sources/MapboxMaps/Style/Style+Localization.swift @@ -108,7 +108,7 @@ extension StyleManager { options: .caseInsensitive) if case .expression(let textField) = symbolLayer.textField { - var stringExpression = String(decoding: try JSONEncoder().encode(textField), as: UTF8.self) + var stringExpression = String(data: try JSONEncoder().encode(textField), encoding: .utf8)! stringExpression.updateOnceExpression(replacement: replacement, regex: expressionCoalesce) stringExpression.updateExpression(replacement: replacement, regex: expressionAbbr) diff --git a/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift b/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift index 7bd00afefa9b..a4ddf17037e5 100644 --- a/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift +++ b/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift @@ -141,13 +141,13 @@ final class AnnotationManagerImplTests: XCTestCase { func checkExpression(key: String, props: [String: Any]) throws { let value = try XCTUnwrap(props[key] as? [Any]) let valueData = try XCTUnwrap(JSONSerialization.data(withJSONObject: value)) - let valueString = try XCTUnwrap(String(decoding: valueData, as: UTF8.self)) + let valueString = try XCTUnwrap(String(data: valueData, encoding: .utf8)) let fallbackValue = me.layerProperties[key] ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: key).value let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) : Data(String(describing: fallbackValue).utf8) - let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let fallbackValueString = try XCTUnwrap(String(data: fallbackValueData, encoding: .utf8)) let expectedString = "[\"coalesce\",[\"get\",\"\(key)\",[\"get\",\"layerProperties\"]],\(fallbackValueString)]" XCTAssertEqual(valueString, expectedString) diff --git a/Tests/MapboxMapsTests/Helpers/Encodable+JsonString.swift b/Tests/MapboxMapsTests/Helpers/Encodable+JsonString.swift index ea6e686c9d76..bafbc1009c9c 100644 --- a/Tests/MapboxMapsTests/Helpers/Encodable+JsonString.swift +++ b/Tests/MapboxMapsTests/Helpers/Encodable+JsonString.swift @@ -2,6 +2,6 @@ import Foundation extension Encodable { func jsonString() throws -> String { - try String(decoding: JSONEncoder().encode(self), as: UTF8.self) + String(data: try JSONEncoder().encode(self), encoding: .utf8)! } } diff --git a/Tests/MapboxMapsTests/Style/ExpressionTests/FormatOptionsTests.swift b/Tests/MapboxMapsTests/Style/ExpressionTests/FormatOptionsTests.swift index 7d3097077291..42455cd43e8b 100644 --- a/Tests/MapboxMapsTests/Style/ExpressionTests/FormatOptionsTests.swift +++ b/Tests/MapboxMapsTests/Style/ExpressionTests/FormatOptionsTests.swift @@ -112,15 +112,15 @@ final class FormatOptionsTests: XCTestCase { let encoded = try DictionaryEncoder().encode(formatOptions) XCTAssertEqual( - String(decoding: try JSONSerialization.data(withJSONObject: encoded["font-scale"] as Any), as: UTF8.self), + String(data: try JSONSerialization.data(withJSONObject: encoded["font-scale"] as Any), encoding: .utf8), #"["case",[">=",["to-number",["get","point_count"]],4],1,2]"# ) XCTAssertEqual( - String(decoding: try JSONSerialization.data(withJSONObject: encoded["text-font"] as Any), as: UTF8.self), + String(data: try JSONSerialization.data(withJSONObject: encoded["text-font"] as Any), encoding: .utf8), #"["case",[">=",["to-number",["get","point_count"]],4],["Open Sans Semibold"],["Arial Unicode MS Bold"]]"# ) XCTAssertEqual( - String(decoding: try JSONSerialization.data(withJSONObject: encoded["text-color"] as Any), as: UTF8.self), + String(data: try JSONSerialization.data(withJSONObject: encoded["text-color"] as Any), encoding: .utf8), ##"["case",[">=",["to-number",["get","point_count"]],4],"#ffffff","#000000"]"## ) } diff --git a/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift b/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift index 9d1882099bf6..e1f8d266366c 100644 --- a/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Style/StyleIntegrationTests.swift @@ -226,7 +226,7 @@ internal class StyleIntegrationTests: MapViewIntegrationTestCase { XCTAssertNoThrow { let convertedExpression = try self.mapView.mapboxMap.convertExpressionForLocalization(symbolLayer: symbolLayer, localeValue: "zh") let data = try JSONSerialization.data(withJSONObject: XCTUnwrap(convertedExpression), options: [.prettyPrinted]) - let convertedString = String(decoding: data, as: UTF8.self).replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "\n", with: "") + let convertedString = String(data: data, encoding: .utf8)!.replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "\n", with: "") let result = "[\"format\",[\"coalesce\",[\"get\",\"name_zh\"],[\"get\",\"name\"]]]" XCTAssertEqual(result, convertedString) @@ -261,7 +261,7 @@ internal class StyleIntegrationTests: MapViewIntegrationTestCase { ], ] - let styleJSON: String = String(decoding: try! JSONSerialization.data(withJSONObject: styleJSONObject, options: [.prettyPrinted]), as: UTF8.self) + let styleJSON: String = String(data: try! JSONSerialization.data(withJSONObject: styleJSONObject, options: [.prettyPrinted]), encoding: .utf8)! XCTAssertFalse(styleJSON.isEmpty, "ValueConverter should create valid JSON string.") let styleJSONFinishedLoading = expectation(description: "Style JSON has finished loading") diff --git a/Tests/MapboxMapsTests/Style/StyleTransitionTests.swift b/Tests/MapboxMapsTests/Style/StyleTransitionTests.swift index 590c16d943b5..7037ef1c85c9 100644 --- a/Tests/MapboxMapsTests/Style/StyleTransitionTests.swift +++ b/Tests/MapboxMapsTests/Style/StyleTransitionTests.swift @@ -18,7 +18,7 @@ class StyleTransitionTests: XCTestCase { let encoder = JSONEncoder() encoder.outputFormatting = .sortedKeys let encodedTransition = try! encoder.encode(transition) - let dataString = String(decoding: encodedTransition, as: UTF8.self) + let dataString = String(data: encodedTransition, encoding: .utf8) XCTAssertEqual(dataString, jsonString) }