Format Swift files with SwiftFormat (#2385)

This commit is contained in:
Bart Louwers
2024-05-12 03:59:27 +02:00
committed by GitHub
parent 9bdc950a3b
commit 32f1bbc902
15 changed files with 540 additions and 550 deletions

View File

@@ -19,6 +19,11 @@ repos:
hooks:
- id: actionlint
additional_dependencies: [shellcheck-py]
- repo: https://github.com/nicklockwood/SwiftFormat
rev: "0.53.8"
hooks:
- id: swiftformat
args: [--swiftversion, "5.8"]
ci:
# sometimes fails https://github.com/keith/pre-commit-buildifier/issues/13
skip: [buildifier]

View File

@@ -1,8 +1,9 @@
#!/usr/bin/swift
import Foundation
/// Generates Entitlement files .xcent for codesigning, containing the correct team id
import Swift
import Foundation
let fileManager = FileManager.default
@@ -16,12 +17,11 @@ guard let rawTeamIdEnv = getenv("IOS_DEVELOPMENT_TEAM") else {
let teamId2 = String(utf8String: rawTeamIdEnv)
for file in contentsOfCurrentWorkingDirectory {
if (file.pathExtension == "template") {
if file.pathExtension == "template" {
var content = ""
do {
content = try String(contentsOf: file, encoding: .utf8)
}
catch {
} catch {
print("Error reading xcent file: \(error).")
}
@@ -32,9 +32,8 @@ for file in contentsOfCurrentWorkingDirectory {
do {
try content.write(to: targetFile, atomically: false, encoding: .utf8)
print("Entitlement " + targetFile.absoluteString + " generated.")
}
catch {
} catch {
print("Error writing xcent file: \(error).")
}
}
}
}

View File

@@ -1,5 +1,5 @@
import XCTest
import MapLibre
import XCTest
/**
Test cases that ensure the inline examples in the project documentation
@@ -29,7 +29,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
static let shared = MLNOfflineStorageMock()
func addPack(for: MLNOfflineRegion, withContext: Data, completionHandler: MLNOfflinePackAdditionCompletionHandler? = nil) {
XCTAssert(MLNOfflineStorage.shared.responds(to: #selector(MLNOfflineStorage.shared.addPack(for:withContext:completionHandler:))))
if let completionHandler = completionHandler {
if let completionHandler {
completionHandler(nil, NSError(domain: "MLNDocumentationExampleError", code: 0, userInfo: [NSLocalizedDescriptionKey: "\(#function) is mocked and not functional."]))
}
}
@@ -48,33 +48,33 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
styleLoadingExpectation = nil
super.tearDown()
}
func mapView(_ mapView: MLNMapView, didFinishLoading style: MLNStyle) {
func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {
styleLoadingExpectation.fulfill()
}
func testMLNLight() {
//#-example-code
// #-example-code
let light = MLNLight()
let position = MLNSphericalPosition(radial: 5, azimuthal: 180, polar: 80)
light.position = NSExpression(forConstantValue: NSValue(mlnSphericalPosition: position))
light.anchor = NSExpression(forConstantValue: "map")
mapView.style?.light = light
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.light)
}
func testMLNTilePyramidOfflineRegion() {
class MLNStyle {
static var lightStyleURL: URL {
return MLNDocumentationExampleTests.styleURL
MLNDocumentationExampleTests.styleURL
}
}
typealias MLNOfflineStorage = MLNOfflineStorageMock
//#-example-code
// #-example-code
let northeast = CLLocationCoordinate2D(latitude: 40.989329, longitude: -102.062592)
let southwest = CLLocationCoordinate2D(latitude: 36.986207, longitude: -109.049896)
let bbox = MLNCoordinateBounds(sw: southwest, ne: northeast)
@@ -82,36 +82,36 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let region = MLNTilePyramidOfflineRegion(styleURL: MLNStyle.lightStyleURL, bounds: bbox, fromZoomLevel: 11, toZoomLevel: 14)
let context = "Tile Pyramid Region".data(using: .utf8)
MLNOfflineStorage.shared.addPack(for: region, withContext: context!)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(region)
}
func testMLNShapeOfflineRegion() {
class MLNStyle {
static var lightStyleURL: URL {
return MLNDocumentationExampleTests.styleURL
MLNDocumentationExampleTests.styleURL
}
}
typealias MLNOfflineStorage = MLNOfflineStorageMock
//#-example-code
// #-example-code
var coordinates = [
CLLocationCoordinate2D(latitude: 45.522585, longitude: -122.685699),
CLLocationCoordinate2D(latitude: 45.534611, longitude: -122.708873),
CLLocationCoordinate2D(latitude: 45.530883, longitude: -122.678833)
CLLocationCoordinate2D(latitude: 45.530883, longitude: -122.678833),
]
let triangle = MLNPolygon(coordinates: &coordinates, count: UInt(coordinates.count))
let region = MLNShapeOfflineRegion(styleURL: MLNStyle.lightStyleURL, shape: triangle, fromZoomLevel: 11, toZoomLevel: 14)
let context = "Triangle Region".data(using: .utf8)
MLNOfflineStorage.shared.addPack(for: region, withContext: context!)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(region)
}
func testMLNOfflinePack() {
typealias MLNOfflineStorage = MLNOfflineStorageMock
@@ -121,9 +121,9 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let region = MLNTilePyramidOfflineRegion(styleURL: MLNDocumentationExampleTests.styleURL, bounds: bbox, fromZoomLevel: 11, toZoomLevel: 14)
let context = "Tile Pyramid Region".data(using: .utf8)!
//#-example-code
MLNOfflineStorage.shared.addPack(for: region, withContext: context) { (pack, error) in
guard let pack = pack else {
// #-example-code
MLNOfflineStorage.shared.addPack(for: region, withContext: context) { pack, error in
guard let pack else {
// If adding the pack fails, log an error to console.
print("Error:", error?.localizedDescription ?? "unknown error adding pack at \(#file)(\(#line)) in \(#function)")
return
@@ -132,23 +132,23 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
// Start an MLNOfflinePack download
pack.resume()
}
//#-end-example-code
// #-end-example-code
}
func testMLNShape$shapeWithData_encoding_error_() {
let mainBundle = Bundle(for: MLNDocumentationExampleTests.self)
//#-example-code
// #-example-code
let url = mainBundle.url(forResource: "amsterdam", withExtension: "geojson")!
let data = try! Data(contentsOf: url)
let feature = try! MLNShape(data: data, encoding: String.Encoding.utf8.rawValue) as! MLNShapeCollectionFeature
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(feature.shapes.first as? MLNPolygonFeature)
}
func testMLNShapeSource() {
//#-example-code
// #-example-code
var coordinates: [CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 37.77, longitude: -122.42),
CLLocationCoordinate2D(latitude: 38.91, longitude: -77.04),
@@ -156,27 +156,27 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let polyline = MLNPolylineFeature(coordinates: &coordinates, count: UInt(coordinates.count))
let source = MLNShapeSource(identifier: "lines", features: [polyline], options: nil)
mapView.style?.addSource(source)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.source(withIdentifier: "lines"))
}
func testMLNRasterTileSource() {
//#-example-code
// #-example-code
let source = MLNRasterTileSource(identifier: "clouds", tileURLTemplates: ["https://example.com/raster-tiles/{z}/{x}/{y}.png"], options: [
.minimumZoomLevel: 9,
.maximumZoomLevel: 16,
.tileSize: 512,
.attributionInfos: [
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
]
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")),
],
])
mapView.style?.addSource(source)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.source(withIdentifier: "clouds"))
}
func testMLNRasterDEMSource() {
// We want to use mapbox.terrain-rgb in the example, but using a mapbox:
// URL requires setting an access token. So this identically named
@@ -187,53 +187,54 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
super.init(identifier: identifier, configurationURL: bogusURL, tileSize: tileSize)
}
}
//#-example-code
// #-example-code
let terrainRGBURL = URL(string: "maptiler://sources/terrain-rgb")!
let source = MLNRasterDEMSource(identifier: "hills", configurationURL: terrainRGBURL)
mapView.style?.addSource(source)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.source(withIdentifier: "hills"))
}
func testMLNVectorTileSource() {
//#-example-code
// #-example-code
let source = MLNVectorTileSource(identifier: "pois", tileURLTemplates: ["https://example.com/vector-tiles/{z}/{x}/{y}.mvt"], options: [
.minimumZoomLevel: 9,
.maximumZoomLevel: 16,
.attributionInfos: [
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
]
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")),
],
])
mapView.style?.addSource(source)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.source(withIdentifier: "pois"))
}
func testMLNPolyline() {
//#-example-code
// #-example-code
let coordinates = [
CLLocationCoordinate2D(latitude: 35.68476, longitude: -220.24257),
CLLocationCoordinate2D(latitude: 37.78428, longitude: -122.41310)
CLLocationCoordinate2D(latitude: 37.78428, longitude: -122.41310),
]
let polyline = MLNPolyline(coordinates: coordinates, count: UInt(coordinates.count))
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(polyline)
}
func testMLNImageSource() {
//#-example-code
// #-example-code
let coordinates = MLNCoordinateQuad(
topLeft: CLLocationCoordinate2D(latitude: 46.437, longitude: -80.425),
bottomLeft: CLLocationCoordinate2D(latitude: 37.936, longitude: -80.425),
bottomRight: CLLocationCoordinate2D(latitude: 37.936, longitude: -71.516),
topRight: CLLocationCoordinate2D(latitude: 46.437, longitude: -71.516))
topLeft: CLLocationCoordinate2D(latitude: 46.437, longitude: -80.425),
bottomLeft: CLLocationCoordinate2D(latitude: 37.936, longitude: -80.425),
bottomRight: CLLocationCoordinate2D(latitude: 37.936, longitude: -71.516),
topRight: CLLocationCoordinate2D(latitude: 46.437, longitude: -71.516)
)
let source = MLNImageSource(identifier: "radar", coordinateQuad: coordinates, url: URL(string: "https://maplibre.org/maplibre-gl-js-docs/assets/radar.gif")!)
mapView.style?.addSource(source)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.source(withIdentifier: "radar"))
}
@@ -241,8 +242,8 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
func testMLNCircleStyleLayer() {
let population = MLNVectorTileSource(identifier: "population", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(population)
//#-example-code
// #-example-code
let layer = MLNCircleStyleLayer(identifier: "circles", source: population)
layer.sourceLayerIdentifier = "population"
#if os(macOS)
@@ -261,7 +262,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
layer.circleOpacity = NSExpression(forConstantValue: 0.7)
layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married")
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "circles"))
}
@@ -270,10 +271,10 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let trails = MLNVectorTileSource(identifier: "trails", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(trails)
//#-example-code
// #-example-code
let layer = MLNLineStyleLayer(identifier: "trails-path", source: trails)
layer.sourceLayerIdentifier = "trails"
let stops = NSExpression(forConstantValue: [14: 2,
18: 20])
layer.lineWidth = NSExpression(forMLNInterpolating: .zoomLevelVariable,
@@ -289,7 +290,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
layer.lineCap = NSExpression(forConstantValue: "round")
layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking")
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "trails-path"))
}
@@ -298,7 +299,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let parks = MLNVectorTileSource(identifier: "parks", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(parks)
//#-example-code
// #-example-code
let layer = MLNFillStyleLayer(identifier: "parks", source: parks)
layer.sourceLayerIdentifier = "parks"
#if os(macOS)
@@ -308,49 +309,49 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
#endif
layer.predicate = NSPredicate(format: "type == %@", "national-park")
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "parks"))
}
func testMLNFillExtrusionStyleLayer() {
let buildings = MLNVectorTileSource(identifier: "buildings", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(buildings)
//#-example-code
// #-example-code
let layer = MLNFillExtrusionStyleLayer(identifier: "buildings", source: buildings)
layer.sourceLayerIdentifier = "building"
layer.fillExtrusionHeight = NSExpression(forKeyPath: "height")
layer.fillExtrusionBase = NSExpression(forKeyPath: "min_height")
layer.predicate = NSPredicate(format: "extrude == 'true'")
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "buildings"))
}
func testMLNHeatmapStyleLayer() {
let earthquakes = MLNShapeSource(identifier: "earthquakes", url: URL(string: "https://example.com/earthquakes.json")!, options: [:])
mapView.style?.addSource(earthquakes)
//#-example-code
// #-example-code
let layer = MLNHeatmapStyleLayer(identifier: "earthquake-heat", source: earthquakes)
layer.heatmapWeight = NSExpression(forMLNInterpolating: .zoomLevelVariable,
curveType: .linear,
parameters: nil,
stops: NSExpression(forConstantValue: [0: 0,
6: 1]))
curveType: .linear,
parameters: nil,
stops: NSExpression(forConstantValue: [0: 0,
6: 1]))
layer.heatmapIntensity = NSExpression(forMLNInterpolating: .zoomLevelVariable,
curveType: .linear,
parameters: nil,
stops: NSExpression(forConstantValue: [0: 1,
9: 3]))
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "earthquake-heat"))
}
@@ -358,7 +359,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let pois = MLNVectorTileSource(identifier: "pois", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(pois)
//#-example-code
// #-example-code
let layer = MLNSymbolStyleLayer(identifier: "coffeeshops", source: pois)
layer.sourceLayerIdentifier = "pois"
layer.iconImageName = NSExpression(forConstantValue: "coffee")
@@ -374,7 +375,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
layer.textAnchor = NSExpression(forConstantValue: "left")
layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee")
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "coffeeshops"))
}
@@ -385,16 +386,16 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
.maximumZoomLevel: 16,
.tileSize: 512,
.attributionInfos: [
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
]
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")),
],
])
mapView.style?.addSource(source)
//#-example-code
// #-example-code
let layer = MLNRasterStyleLayer(identifier: "clouds", source: source)
layer.rasterOpacity = NSExpression(forConstantValue: 0.5)
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "clouds"))
}
@@ -405,23 +406,23 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
.maximumZoomLevel: 16,
.tileSize: 256,
.attributionInfos: [
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
]
MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")),
],
])
mapView.style?.addSource(source)
let canals = MLNVectorTileSource(identifier: "canals", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(canals)
let canalShadowLayer = MLNLineStyleLayer(identifier: "waterway-river-canal-shadow", source: canals)
mapView.style?.addLayer(canalShadowLayer)
//#-example-code
// #-example-code
let layer = MLNHillshadeStyleLayer(identifier: "hills", source: source)
layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6)
if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") {
mapView.style?.insertLayer(layer, below: canalShadowLayer)
}
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "hills"))
}
@@ -430,22 +431,22 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
let terrain = MLNVectorTileSource(identifier: "terrain", configurationURL: URL(string: "https://example.com/style.json")!)
mapView.style?.addSource(terrain)
//#-example-code
// #-example-code
let layer = MLNLineStyleLayer(identifier: "contour", source: terrain)
layer.sourceLayerIdentifier = "contours"
layer.predicate = NSPredicate(format: "(index == 5 || index == 10) && CAST(ele, 'NSNumber') >= 1500.0")
mapView.style?.addLayer(layer)
//#-end-example-code
// #-end-example-code
XCTAssertNotNil(mapView.style?.layer(withIdentifier: "contour"))
}
func testMLNMapView() {
//#-example-code
// #-example-code
#if os(macOS)
class MapClickGestureRecognizer: NSClickGestureRecognizer {
override func shouldRequireFailure(of otherGestureRecognizer: NSGestureRecognizer) -> Bool {
return otherGestureRecognizer is NSClickGestureRecognizer
otherGestureRecognizer is NSClickGestureRecognizer
}
}
#else
@@ -455,13 +456,13 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
}
mapView.addGestureRecognizer(mapTapGestureRecognizer)
#endif
//#-end-example-code
// #-end-example-code
}
func testMLNMapSnapshotter() throws {
throw XCTSkip("Snapshotter not implemented yet for Metal. See https://github.com/maplibre/maplibre-native/issues/1862")
let expectation = self.expectation(description: "MLNMapSnapshotter should produce a snapshot")
let expectation = expectation(description: "MLNMapSnapshotter should produce a snapshot")
#if os(macOS)
var image: NSImage? {
didSet {
@@ -475,138 +476,136 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
}
}
#endif
class MLNStyle {
static var satelliteStreetsStyleURL: URL {
return MLNDocumentationExampleTests.styleURL
MLNDocumentationExampleTests.styleURL
}
}
//#-example-code
// #-example-code
let camera = MLNMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0)
let options = MLNMapSnapshotOptions(styleURL: MLNStyle.satelliteStreetsStyleURL, camera: camera, size: CGSize(width: 320, height: 480))
options.zoomLevel = 10
let snapshotter = MLNMapSnapshotter(options: options)
snapshotter.start { (snapshot, error) in
if let error = error {
snapshotter.start { snapshot, error in
if let error {
fatalError(error.localizedDescription)
}
image = snapshot?.image
}
//#-end-example-code
// #-end-example-code
wait(for: [expectation], timeout: 5)
_ = image
}
func testMLNCluster() {
func testMLNCluster() {
enum ExampleError: Error {
case unexpectedFeatureType
case featureIsNotACluster
}
let geoJSON: [String: Any] = [
"type" : "Feature",
"geometry" : [
"coordinates" : [
"type": "Feature",
"geometry": [
"coordinates": [
-77.00896639534831,
38.87031006108791,
0.0
0.0,
],
"type" : "Point"
] as [String : Any],
"properties" : [
"cluster" : true,
"cluster_id" : 123,
"point_count" : 4567,
] as [String : Any]
"type": "Point",
] as [String: Any],
"properties": [
"cluster": true,
"cluster_id": 123,
"point_count": 4567,
] as [String: Any],
]
let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: [])
do {
//#-example-code
// #-example-code
let shape = try! MLNShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue)
guard let pointFeature = shape as? MLNPointFeature else {
throw ExampleError.unexpectedFeatureType
}
// Check for cluster conformance
guard let cluster = pointFeature as? MLNCluster else {
throw ExampleError.featureIsNotACluster
}
// Currently the only supported class that conforms to `MLNCluster` is
// `MLNPointFeatureCluster`
guard cluster is MLNPointFeatureCluster else {
throw ExampleError.unexpectedFeatureType
}
//#-end-example-code
// #-end-example-code
XCTAssert(cluster.clusterIdentifier == 123)
XCTAssert(cluster.clusterPointCount == 4567)
}
catch let error {
} catch {
XCTFail("Example failed with thrown error: \(error)")
}
}
}
func testMLNAttributedExpression() {
//#-example-code
// #-example-code
#if os(macOS)
let redColor = NSColor.red
let redColor = NSColor.red
#else
let redColor = UIColor.red
let redColor = UIColor.red
#endif
let expression = NSExpression(forConstantValue: "Foo")
let attributes: [MLNAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : NSExpression(forConstantValue: ["DIN Offc Pro Italic",
"Arial Unicode MS Regular"]),
let attributes: [MLNAttributedExpressionKey: NSExpression] = [.fontNamesAttribute: NSExpression(forConstantValue: ["DIN Offc Pro Italic",
"Arial Unicode MS Regular"]),
.fontScaleAttribute: NSExpression(forConstantValue: 1.2),
.fontColorAttribute: NSExpression(forConstantValue: redColor)]
let attributedExpression = MLNAttributedExpression(expression, attributes:attributes)
//#-end-example-code
let attributedExpression = MLNAttributedExpression(expression, attributes: attributes)
// #-end-example-code
XCTAssertNotNil(attributedExpression)
}
func testMLNShapeSourceOptionClusterProperties() {
//#-example-code
// #-example-code
let firstExpression = NSExpression(format: "sum:({$featureAccumulated, sumValue})")
let secondExpression = NSExpression(forKeyPath: "magnitude")
let clusterPropertiesDictionary = ["sumValue" : [firstExpression, secondExpression]]
let clusterPropertiesDictionary = ["sumValue": [firstExpression, secondExpression]]
let options : [MLNShapeSourceOption : Any] = [.clustered : true,
.clusterProperties: clusterPropertiesDictionary]
//#-end-example-code
let options: [MLNShapeSourceOption: Any] = [.clustered: true,
.clusterProperties: clusterPropertiesDictionary]
// #-end-example-code
let geoJSON: [String: Any] = [
"type" : "Feature",
"geometry" : [
"coordinates" : [
"type": "Feature",
"geometry": [
"coordinates": [
-77.00896639534831,
38.87031006108791,
0.0
0.0,
],
"type" : "Point"
] as [String : Any],
"properties" : [
"cluster" : true,
"cluster_id" : 123,
"point_count" : 4567,
] as [String : Any]
"type": "Point",
] as [String: Any],
"properties": [
"cluster": true,
"cluster_id": 123,
"point_count": 4567,
] as [String: Any],
]
let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: [])
let shape = try! MLNShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue)
let source = MLNShapeSource(identifier: "source", shape: shape, options: options)
mapView.style?.addSource(source)
}
// For testMLNMapView().
func myCustomFunction() {}
}

View File

@@ -1,5 +1,5 @@
import XCTest
import MapLibre
import XCTest
/**
Test cases that ensure the inline examples in the jazzy guides compile.
@@ -24,7 +24,7 @@ import MapLibre
class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
var mapView: MLNMapView!
var styleLoadingExpectation: XCTestExpectation!
override func setUp() {
super.setUp()
let styleURL = Bundle(for: MLNDocumentationGuideTests.self).url(forResource: "one-liner", withExtension: "json")
@@ -33,19 +33,19 @@ class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
styleLoadingExpectation = expectation(description: "Map view should finish loading style")
waitForExpectations(timeout: 10, handler: nil)
}
override func tearDown() {
mapView = nil
styleLoadingExpectation = nil
super.tearDown()
}
func mapView(_ mapView: MLNMapView, didFinishLoading style: MLNStyle) {
func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {
styleLoadingExpectation.fulfill()
}
func testMigratingToExpressions$Stops() {
//#-example-code
// #-example-code
// Swift sample on how to populate a stepping expression with multiple stops.
// Create a color ramp.
#if os(macOS)
@@ -76,28 +76,29 @@ class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
let stopsLineWidth = [
11.0: initialValue,
14.0: 6.0,
20.0: 18.0]
20.0: 18.0,
]
functionExpression = NSExpression(
forMLNStepping: .zoomLevelVariable,
from: NSExpression(forConstantValue: initialValue),
stops: NSExpression(forConstantValue: stopsLineWidth)
)
//#-end-example-code
// #-end-example-code
print(functionExpression)
print(stopsLineWidth)
}
func testMigratingToExpressions$Linear() {
//#-example-code
// #-example-code
let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson")!
let symbolSource = MLNSource(identifier: "source")
let symbolLayer = MLNSymbolStyleLayer(identifier: "place-city-sm", source: symbolSource)
let source = MLNShapeSource(identifier: "earthquakes", url: url, options: nil)
let mag = 1.0 // Update based on earthquake GeoJSON data
let mag = 1.0 // Update based on earthquake GeoJSON data
mapView.style?.addSource(source)
#if os(macOS)
let stops: [NSNumber: NSColor] = [
0: .yellow,
@@ -115,97 +116,36 @@ class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
10: .white,
]
#endif
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
let circleExpression : NSExpression
let circleExpression: NSExpression
if #available(iOS 15, *) {
circleExpression = NSExpression(
forMLNInterpolating: NSExpression(forConstantValue: mag),
curveType: .linear,
parameters: nil,
stops: NSExpression(forConstantValue: stops))
stops: NSExpression(forConstantValue: stops)
)
} else {
// This works up to iOS 14.5
circleExpression = NSExpression(
format: "mgl_interpolate:withCurveType:parameters:stops:(mag, 'linear', nil, %@)",
stops)
stops
)
}
layer.circleColor = circleExpression
layer.circleRadius = NSExpression(forConstantValue: 10)
mapView.style?.insertLayer(layer, below: symbolLayer)
//#-end-example-code
// #-end-example-code
print(circleExpression)
}
func testMigratingToExpressions$LinearConvenience() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
#if os(macOS)
let stops: [NSNumber: NSColor] = [
0: .yellow,
2.5: .orange,
5: .red,
7.5: .blue,
10: .white,
]
#else
let stops: [NSNumber: UIColor] = [
0: .yellow,
2.5: .orange,
5: .red,
7.5: .blue,
10: .white,
]
#endif
//#-example-code
layer.circleColor = NSExpression(forMLNInterpolating: NSExpression(forKeyPath: "mag"), curveType: .linear, parameters: nil, stops: NSExpression(forConstantValue: stops))
//#-end-example-code
layer.circleRadius = NSExpression(forConstantValue: 10)
mapView.style?.addLayer(layer)
}
func testMigratingToExpressions$Exponential() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
let stops = [
12: 0.5,
14: 2,
18: 18,
]
layer.circleRadius = NSExpression(forMLNInterpolating: .zoomLevelVariable,
curveType: .exponential,
parameters: NSExpression(forConstantValue: 1.5),
stops: NSExpression(forConstantValue: stops))
//#-end-example-code
}
func testMigratingToExpressions$ExponentialConvenience() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
let stops = [
12: 0.5,
14: 2,
18: 18,
]
layer.circleRadius = NSExpression(forMLNInterpolating: NSExpression.zoomLevelVariable, curveType: MLNExpressionInterpolationMode.exponential, parameters: NSExpression(forConstantValue: 1.5), stops: NSExpression(forConstantValue: stops))
//#-end-example-code
}
func testMigratingToExpressions$Interval() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
#if os(macOS)
let stops: [NSNumber: NSColor] = [
0: .yellow,
@@ -214,7 +154,71 @@ class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
7.5: .blue,
10: .white,
]
#else
let stops: [NSNumber: UIColor] = [
0: .yellow,
2.5: .orange,
5: .red,
7.5: .blue,
10: .white,
]
#endif
// #-example-code
layer.circleColor = NSExpression(forMLNInterpolating: NSExpression(forKeyPath: "mag"), curveType: .linear, parameters: nil, stops: NSExpression(forConstantValue: stops))
// #-end-example-code
layer.circleRadius = NSExpression(forConstantValue: 10)
mapView.style?.addLayer(layer)
}
func testMigratingToExpressions$Exponential() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
// #-example-code
let stops = [
12: 0.5,
14: 2,
18: 18,
]
layer.circleRadius = NSExpression(forMLNInterpolating: .zoomLevelVariable,
curveType: .exponential,
parameters: NSExpression(forConstantValue: 1.5),
stops: NSExpression(forConstantValue: stops))
// #-end-example-code
}
func testMigratingToExpressions$ExponentialConvenience() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
// #-example-code
let stops = [
12: 0.5,
14: 2,
18: 18,
]
layer.circleRadius = NSExpression(forMLNInterpolating: NSExpression.zoomLevelVariable, curveType: MLNExpressionInterpolationMode.exponential, parameters: NSExpression(forConstantValue: 1.5), stops: NSExpression(forConstantValue: stops))
// #-end-example-code
}
func testMigratingToExpressions$Interval() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
// #-example-code
#if os(macOS)
let stops: [NSNumber: NSColor] = [
0: .yellow,
2.5: .orange,
5: .red,
7.5: .blue,
10: .white,
]
layer.circleColor = NSExpression(forMLNStepping: .zoomLevelVariable,
from: NSExpression(forConstantValue: NSColor.green),
stops: NSExpression(forConstantValue: stops))
@@ -226,19 +230,19 @@ class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
7.5: .blue,
10: .white,
]
layer.circleColor = NSExpression(forMLNStepping: .zoomLevelVariable,
from: NSExpression(forConstantValue: UIColor.green),
stops: NSExpression(forConstantValue: stops))
#endif
//#-end-example-code
// #-end-example-code
}
func testMigratingToExpressions$Categorical() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
// #-example-code
// Category type
let type = NSExpression(forConstantValue: "type")
@@ -248,81 +252,83 @@ class MLNDocumentationGuideTests: XCTestCase, MLNMapViewDelegate {
let quarryBlast = NSExpression(forConstantValue: "quarry blast")
#if os(macOS)
let defaultColor = NSExpression(forConstantValue: NSColor.blue)
let orange = NSExpression(forConstantValue: NSColor.orange)
let red = NSExpression(forConstantValue: NSColor.red)
let yellow = NSExpression(forConstantValue: NSColor.yellow)
layer.circleColor = NSExpression(forMLNMatchingKey: type,
in: [earthquake:orange, explosion:red, quarryBlast:yellow],
default: defaultColor)
let defaultColor = NSExpression(forConstantValue: NSColor.blue)
let orange = NSExpression(forConstantValue: NSColor.orange)
let red = NSExpression(forConstantValue: NSColor.red)
let yellow = NSExpression(forConstantValue: NSColor.yellow)
layer.circleColor = NSExpression(forMLNMatchingKey: type,
in: [earthquake: orange, explosion: red, quarryBlast: yellow],
default: defaultColor)
#else
let defaultColor = NSExpression(forConstantValue: UIColor.blue)
let orange = NSExpression(forConstantValue: UIColor.orange)
let red = NSExpression(forConstantValue: UIColor.red)
let yellow = NSExpression(forConstantValue: UIColor.yellow)
let defaultColor = NSExpression(forConstantValue: UIColor.blue)
let orange = NSExpression(forConstantValue: UIColor.orange)
let red = NSExpression(forConstantValue: UIColor.red)
let yellow = NSExpression(forConstantValue: UIColor.yellow)
XCTExpectFailure("Awaiting unit test refactoring for https://github.com/maplibre/maplibre-native/issues/331")
layer.circleColor = NSExpression(forMLNMatchingKey: type,
in: [earthquake:orange, explosion:red, quarryBlast:yellow],
default: defaultColor)
XCTExpectFailure("Awaiting unit test refactoring for https://github.com/maplibre/maplibre-native/issues/331")
layer.circleColor = NSExpression(forMLNMatchingKey: type,
in: [earthquake: orange, explosion: red, quarryBlast: yellow],
default: defaultColor)
#endif
//#-end-example-code
// #-end-example-code
}
func testMigratingToExpressions$CategoricalValue() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
// #-example-code
#if os(macOS)
let stops : [String : NSColor] = ["earthquake" : NSColor.orange,
"explosion" : NSColor.red,
"quarry blast" : NSColor.yellow]
layer.circleColor = NSExpression(
format: "FUNCTION(%@, 'valueForKeyPath:', type)",
stops)
let stops: [String: NSColor] = ["earthquake": NSColor.orange,
"explosion": NSColor.red,
"quarry blast": NSColor.yellow]
layer.circleColor = NSExpression(
format: "FUNCTION(%@, 'valueForKeyPath:', type)",
stops
)
#else
let stops : [String : UIColor] = ["earthquake" : UIColor.orange,
"explosion" : UIColor.red,
"quarry blast" : UIColor.yellow]
layer.circleColor = NSExpression(
format: "FUNCTION(%@, 'valueForKeyPath:', type)",
stops)
let stops: [String: UIColor] = ["earthquake": UIColor.orange,
"explosion": UIColor.red,
"quarry blast": UIColor.yellow]
layer.circleColor = NSExpression(
format: "FUNCTION(%@, 'valueForKeyPath:', type)",
stops
)
#endif
//#-end-example-code
// #-end-example-code
}
func testMigratingToExpressions$Identity() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
// #-example-code
layer.circleRadius = NSExpression(forKeyPath: "mag")
//#-end-example-code
// #-end-example-code
}
func testMigratingToExpressions$Multiply() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
let layer = MLNCircleStyleLayer(identifier: "circles", source: source)
//#-example-code
// #-example-code
layer.circleRadius = NSExpression(forFunction: "multiply:by:", arguments: [NSExpression(forKeyPath: "mag"), 3])
//#-end-example-code
// #-end-example-code
}
func testMigratingToExpressions$Cast() {
let source = MLNShapeSource(identifier: "circles", shape: nil, options: nil)
//#-example-code
// #-example-code
let magnitudeLayer = MLNSymbolStyleLayer(identifier: "mag-layer", source: source)
magnitudeLayer.text = NSExpression(format: "CAST(mag, 'NSString')")
mapView.style?.addLayer(magnitudeLayer)
//#-end-example-code
// #-end-example-code
}
// MARK: Swift Example Code for Expected Failures
func testExpectPassSwift() {
XCTAssertNotNil(1)
}

View File

@@ -1,10 +1,9 @@
import XCTest
class MLNSDKTestHelpers {
class func checkTestsContainAllMethods(testClass: Swift.AnyClass, in p: Protocol) {
let testMethods = self.classMethodDescriptions(testClass)
let subjectMethods = self.protocolMethodDescriptions(p)
let testMethods = classMethodDescriptions(testClass)
let subjectMethods = protocolMethodDescriptions(p)
for method in subjectMethods {
if !testMethods.contains(method) {
@@ -14,16 +13,14 @@ class MLNSDKTestHelpers {
XCTAssert(true)
}
}
extension MLNSDKTestHelpers {
class func protocolMethodDescriptions(_ p: Protocol) -> Set<String> {
var methods = Set<String>()
var methodCount = UInt32()
let methodDescriptionList = protocol_copyMethodDescriptionList(p, false, true, &methodCount)
for i in 0..<Int(methodCount) {
for i in 0 ..< Int(methodCount) {
let description = methodDescriptionList![i]
XCTAssertNotNil(description.name?.description)
methods.insert(description.name!.description)
@@ -36,7 +33,7 @@ extension MLNSDKTestHelpers {
var methods = Set<String>()
var methodCount = UInt32()
let methodList = class_copyMethodList(cls, &methodCount)
for i in 0..<Int(methodCount) {
for i in 0 ..< Int(methodCount) {
let method = methodList![i]
let selector = method_getName(method)
methods.insert(selector.description)
@@ -44,5 +41,4 @@ extension MLNSDKTestHelpers {
free(methodList)
return methods
}
}

View File

@@ -1,45 +1,43 @@
import XCTest
class MLNSourceTests: MLNMapViewIntegrationTest {
// See testForRaisingExceptionsOnStaleStyleObjects for Obj-C sibling.
func testForRaisingExceptionsOnStaleStyleObjectsOnRemoveFromMapView() {
guard
let configURL = URL(string: "mapbox://examples.2uf7qges") else {
XCTFail()
return
let configURL = URL(string: "mapbox://examples.2uf7qges")
else {
XCTFail()
return
}
let source = MLNVectorTileSource(identifier: "trees", configurationURL: configURL)
mapView.style?.addSource(source)
let bundle = Bundle(for: type(of: self))
guard let styleURL = bundle.url(forResource: "one-liner", withExtension: "json") else {
XCTFail()
return
}
styleLoadingExpectation = nil;
mapView.centerCoordinate = CLLocationCoordinate2D(latitude : 38.897, longitude : -77.039)
mapView.zoomLevel = 10.5
mapView.styleURL = styleURL
styleLoadingExpectation = nil
mapView.centerCoordinate = CLLocationCoordinate2D(latitude: 38.897, longitude: -77.039)
mapView.zoomLevel = 10.5
mapView.styleURL = styleURL
waitForMapViewToFinishLoadingStyle(withTimeout: 10.0)
let expect = expectation(description: "Remove source should error")
do {
try mapView.style?.removeSource(source, error: ())
}
catch let error as NSError {
} catch let error as NSError {
XCTAssertEqual(error.domain, MLNErrorDomain)
XCTAssertEqual(error.code, MLNErrorCode.sourceCannotBeRemovedFromStyle.rawValue)
expect.fulfill()
}
wait(for: [expect], timeout: 0.1)
}
}

View File

@@ -1,21 +1,20 @@
import XCTest
class MLNMapSnapshotterSwiftTests: MLNMapViewIntegrationTest {
// Create snapshot options
private class func snapshotterOptions(size: CGSize) -> MLNMapSnapshotOptions {
let camera = MLNMapCamera()
let options = MLNMapSnapshotOptions(styleURL: MLNStyle.predefinedStyle("Hybrid").url , camera: camera, size: size)
let options = MLNMapSnapshotOptions(styleURL: MLNStyle.predefinedStyle("Hybrid").url, camera: camera, size: size)
let sw = CLLocationCoordinate2D(latitude: 52.3, longitude: 13.0)
let ne = CLLocationCoordinate2D(latitude: 52.5, longitude: 13.2)
options.coordinateBounds = MLNCoordinateBounds(sw:sw, ne:ne)
options.coordinateBounds = MLNCoordinateBounds(sw: sw, ne: ne)
return options
}
public override func setUp() {
override public func setUp() {
super.setUp()
MLNSettings.use(MLNWellKnownTileServer.mapTiler)
}
@@ -25,7 +24,7 @@ class MLNMapSnapshotterSwiftTests: MLNMapViewIntegrationTest {
// This Swift test, is essentially the same except for capturing the snapshotter
let timeout: TimeInterval = 10.0
let expectation = self.expectation(description: "snapshot")
let expectation = expectation(description: "snapshot")
let options = MLNMapSnapshotterSwiftTests.snapshotterOptions(size: mapView.bounds.size)
@@ -36,10 +35,9 @@ class MLNMapSnapshotterSwiftTests: MLNMapViewIntegrationTest {
dg.enter()
DispatchQueue.main.async {
let snapshotter = MLNMapSnapshotter(options: options)
snapshotter.start(completionHandler: { (snapshot, error) in
snapshotter.start(completionHandler: { snapshot, error in
// // Without capturing snapshotter:
// XCTAssertNil(snapshot)
@@ -61,20 +59,20 @@ class MLNMapSnapshotterSwiftTests: MLNMapViewIntegrationTest {
wait(for: [expectation], timeout: timeout)
}
func testSnapshotOverlaySwiftErgonomicsLOCKED() {
let options = MLNMapSnapshotterSwiftTests.snapshotterOptions(size: mapView.bounds.size)
let options = MLNMapSnapshotterSwiftTests.snapshotterOptions(size: mapView.bounds.size)
let snapshotter = MLNMapSnapshotter(options: options)
let expectation = self.expectation(description: "snapshot")
let expectation = expectation(description: "snapshot")
expectation.expectedFulfillmentCount = 2
snapshotter.start(overlayHandler: { (overlay) in
snapshotter.start(overlayHandler: { overlay in
guard let _ = overlay.context.makeImage() else {
XCTFail()
return
}
expectation.fulfill()
}) { (_, _) in
}) { _, _ in
expectation.fulfill()
}
wait(for: [expectation], timeout: 10)

View File

@@ -8,7 +8,6 @@
import XCTest
class bench_UITests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.

View File

@@ -8,20 +8,19 @@
import XCTest
extension XCTestCase {
/// `screenshot` — Save a PNG screenshot to the UITest results
/// - Parameter name: friendly name to include.
/// Associate an image with the Activity - See [add()](https://developer.apple.com/documentation/xctest/xctactivity/2887222-add)
/// - returns: XCTAttachment, which will need to be `add`ed to the `XCTActivity`
/**
```
/// rely on the calling test functions name
add(screenshot())
/**
```
/// rely on the calling test functions name
add(screenshot())
/// Add by name
add(screenshot(name: "Example"))
```
*/
/// Add by name
add(screenshot(name: "Example"))
```
*/
func screenshot(name: String = #function) -> XCTAttachment {
let attachmentName = "MapLibre-Screenshot-\(name)-\(UIDevice.current.name)-\(UIDevice.current.systemVersion).png"
let screenshot = XCUIScreen.main.screenshot()

View File

@@ -8,7 +8,6 @@
import XCTest
class iosapp_UITests: XCTestCase {
let app = XCUIApplication()
override func setUpWithError() throws {
@@ -31,42 +30,42 @@ class iosapp_UITests: XCTestCase {
func test_iosappScheme() throws {
/// Launch and take a screenshot
app.navigationBars["MapLibre Basic"].buttons["Map settings"].tap()
app.tables/*@START_MENU_TOKEN@*/.staticTexts["Reset position"]/*[[".cells.staticTexts[\"Reset position\"]",".staticTexts[\"Reset position\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app.tables/*@START_MENU_TOKEN@*/ .staticTexts["Reset position"]/*[[".cells.staticTexts[\"Reset position\"]",".staticTexts[\"Reset position\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .tap()
sleep(1)
add(screenshot())
}
/// Turn on Debug tile boundaries, tile info and FPS ornaments
/// Demonstrates how the Tile Boundaries look when rendered
func testDebugBoundaryTiles() {
app.windows.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.doubleTap()
let mapSettingsButton = app.navigationBars["MapLibre Basic"].buttons["Map settings"]
mapSettingsButton.tap()
/// setup initial conditions for position (0,0) and debug settings
let tablesQuery = app.tables
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Show zoom level ornament"]/*[[".cells.staticTexts[\"Show zoom level ornament\"]",".staticTexts[\"Show zoom level ornament\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
tablesQuery/*@START_MENU_TOKEN@*/ .staticTexts["Show zoom level ornament"]/*[[".cells.staticTexts[\"Show zoom level ornament\"]",".staticTexts[\"Show zoom level ornament\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .tap()
mapSettingsButton.tap()
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Show tile boundaries"]/*[[".cells.staticTexts[\"Show tile boundaries\"]",".staticTexts[\"Show tile boundaries\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
tablesQuery/*@START_MENU_TOKEN@*/ .staticTexts["Show tile boundaries"]/*[[".cells.staticTexts[\"Show tile boundaries\"]",".staticTexts[\"Show tile boundaries\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .tap()
mapSettingsButton.tap()
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Show tile info"]/*[[".cells.staticTexts[\"Show tile info\"]",".staticTexts[\"Show tile info\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
tablesQuery/*@START_MENU_TOKEN@*/ .staticTexts["Show tile info"]/*[[".cells.staticTexts[\"Show tile info\"]",".staticTexts[\"Show tile info\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .tap()
mapSettingsButton.tap()
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Show tile timestamps"]/*[[".cells.staticTexts[\"Show tile timestamps\"]",".staticTexts[\"Show tile timestamps\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
tablesQuery/*@START_MENU_TOKEN@*/ .staticTexts["Show tile timestamps"]/*[[".cells.staticTexts[\"Show tile timestamps\"]",".staticTexts[\"Show tile timestamps\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .tap()
mapSettingsButton.tap()
tablesQuery.staticTexts["Add Test Shapes"].tap()
sleep(1)
add(screenshot(name: "Add Test Shapes"))
mapSettingsButton.tap()
tablesQuery.staticTexts["Reset position"].tap()
sleep(1)
add(screenshot(name: "Null Island, Zoom=0"))
}
var mapSettingsButton: XCUIElement { get { app.navigationBars["MapLibre Basic"].buttons["Map settings"] } }
var mapSettingsButton: XCUIElement { app.navigationBars["MapLibre Basic"].buttons["Map settings"] }
/// Open and close the secondary map view a few times to ensure that the dynamic layout adjustment doesn't crash
func testSecondMap() {
@@ -77,7 +76,7 @@ class iosapp_UITests: XCTestCase {
let secondMapQuery = app.otherElements["Second Map"]
XCTAssert(!secondMapQuery.exists)
for _ in 0..<iterations {
for _ in 0 ..< iterations {
mapSettingsButton.tap()
app.tables.staticTexts["Show Second Map"].tap()
XCTAssert(secondMapQuery.waitForExistence(timeout: showTimeout))
@@ -94,76 +93,76 @@ class iosapp_UITests: XCTestCase {
func testAll() {
let allItems = [
"Reset position",
"Show tile boundaries",
"Hide tile boundaries",
"Show tile info",
"Hide tile info",
"Show tile timestamps",
"Hide tile timestamps",
"Show collision boxes",
"Hide collision boxes",
"Show overdraw visualization",
"Hide overdraw visualization",
"Show zoom level ornament",
"Hide zoom level ornament",
"Show frame time graph",
"Hide frame time graph",
"Show reuse queue stats",
"Hide reuse queue stats",
"Add 100 Views",
//"Add 1,000 Views", // These cause the test to time out
//"Add 10,000 Views",
"Add 100 Sprites",
//"Add 1,000 Sprites",
//"Add 10,000 Sprites",
"Animate an Annotation View",
"Add Test Shapes",
"Add 10x Test Shapes",
"Add Point With Custom Callout",
"Query Annotations",
"Enable Custom User Dot",
"Disable Custom User Dot",
"Remove Annotations",
"Select an offscreen point annotation",
"Center selected annotation",
"Add visible area polyline",
"Add Building Extrusions",
"Style Water With Function",
"Style Roads With Function",
"Add Raster & Apply Function",
"Add Shapes & Apply Fill",
"Style Symbol Color",
"Style Building Fill Color",
"Style Ferry Line Color",
"Remove Parks",
"Style Fill With Filter",
"Style Lines With Filter",
"Style Fill With Numeric Filter",
"Query and Style Features",
"Style Feature",
"Style Dynamic Point Collection",
"Update Shape Source: Data",
"Update Shape Source: URL",
"Update Shape Source: Features",
"Style Vector Tile Source",
"Style Raster Tile Source",
"Style Image Source",
"Add Route Line",
"Dynamically Style Polygon",
"Add Custom Lat/Lon Grid",
"Style Route line with gradient",
"Start World Tour",
"Random Tour",
"Show Second Map",
"Hide Second Map",
"Missing Icon",
"Limit Camera Changes",
"Unlimit Camera Changes",
"Turn On Content Insets",
"Turn Off Content Insets",
"Lat Long bounds with padding",
"Show Labels in Default Language",
"Reset position",
"Show tile boundaries",
"Hide tile boundaries",
"Show tile info",
"Hide tile info",
"Show tile timestamps",
"Hide tile timestamps",
"Show collision boxes",
"Hide collision boxes",
"Show overdraw visualization",
"Hide overdraw visualization",
"Show zoom level ornament",
"Hide zoom level ornament",
"Show frame time graph",
"Hide frame time graph",
"Show reuse queue stats",
"Hide reuse queue stats",
"Add 100 Views",
// "Add 1,000 Views", // These cause the test to time out
// "Add 10,000 Views",
"Add 100 Sprites",
// "Add 1,000 Sprites",
// "Add 10,000 Sprites",
"Animate an Annotation View",
"Add Test Shapes",
"Add 10x Test Shapes",
"Add Point With Custom Callout",
"Query Annotations",
"Enable Custom User Dot",
"Disable Custom User Dot",
"Remove Annotations",
"Select an offscreen point annotation",
"Center selected annotation",
"Add visible area polyline",
"Add Building Extrusions",
"Style Water With Function",
"Style Roads With Function",
"Add Raster & Apply Function",
"Add Shapes & Apply Fill",
"Style Symbol Color",
"Style Building Fill Color",
"Style Ferry Line Color",
"Remove Parks",
"Style Fill With Filter",
"Style Lines With Filter",
"Style Fill With Numeric Filter",
"Query and Style Features",
"Style Feature",
"Style Dynamic Point Collection",
"Update Shape Source: Data",
"Update Shape Source: URL",
"Update Shape Source: Features",
"Style Vector Tile Source",
"Style Raster Tile Source",
"Style Image Source",
"Add Route Line",
"Dynamically Style Polygon",
"Add Custom Lat/Lon Grid",
"Style Route line with gradient",
"Start World Tour",
"Random Tour",
"Show Second Map",
"Hide Second Map",
"Missing Icon",
"Limit Camera Changes",
"Unlimit Camera Changes",
"Turn On Content Insets",
"Turn Off Content Insets",
"Lat Long bounds with padding",
"Show Labels in Default Language",
]
for label in allItems {
@@ -175,7 +174,8 @@ class iosapp_UITests: XCTestCase {
// Only one of these will show up, run whichever one is there
mapSettingsButton.tap()
if let customLayer = staticItemIfExists("Add Custom Triangle Layer (OpenGL)") ??
staticItemIfExists("Add Custom Triangle Layer (Metal)") {
staticItemIfExists("Add Custom Triangle Layer (Metal)")
{
customLayer.tap()
sleep(1)
mapSettingsButton.tap()
@@ -188,7 +188,7 @@ class iosapp_UITests: XCTestCase {
}
// See `bestLanguageForUser`
for loc in [ "ar", "de", "en", "es", "fr", "ja", "ko", "pt", "ru", "zh", "zh-Hans", "zh-Hant" ] {
for loc in ["ar", "de", "en", "es", "fr", "ja", "ko", "pt", "ru", "zh", "zh-Hans", "zh-Hant"] {
if let name = NSLocale(localeIdentifier: loc).displayName(forKey: .identifier, value: loc) {
if let item = staticItemIfExists("Show Labels in " + name) {
item.tap()
@@ -223,9 +223,9 @@ class iosapp_UITests: XCTestCase {
private func tapBackButton(_ label: String, timeout: TimeInterval) -> Bool {
let bar = app.navigationBars[label]
if (bar.waitForExistence(timeout: timeout)) {
if bar.waitForExistence(timeout: timeout) {
let button = bar.buttons["Back"]
if (button.waitForExistence(timeout: 1)) {
if button.waitForExistence(timeout: 1) {
button.tap()
return true
}
@@ -247,14 +247,14 @@ class iosapp_UITests: XCTestCase {
}
}
}
/// Make sure the Custom Drawable Layer does not crash
func testCustomDrawableLayer() {
app.windows.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.doubleTap()
let mapSettingsButton = app.navigationBars["MapLibre Basic"].buttons["Map settings"]
mapSettingsButton.tap()
let tablesQuery = app.tables
tablesQuery.staticTexts["Add Custom Drawable Layer"].tap()
sleep(5)

View File

@@ -6,14 +6,16 @@ let package = Package(
products: [
.library(
name: "Mapbox",
targets: ["Mapbox"])
targets: ["Mapbox"]
),
],
dependencies: [
],
],
targets: [
.binaryTarget(
name: "Mapbox",
url: "MAPLIBRE_PACKAGE_URL",
checksum: "MAPLIBRE_PACKAGE_CHECKSUM")
checksum: "MAPLIBRE_PACKAGE_CHECKSUM"
),
]
)
)

View File

@@ -1,23 +1,19 @@
import XCTest
import MapLibre
import XCTest
class CustomAnnotationView: MLNAnnotationView {
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
class MLNAnnotationViewIntegrationTests: XCTestCase {
func testCreatingCustomAnnotationView() {
let customAnnotationView = CustomAnnotationView(reuseIdentifier: "resuse-id")
XCTAssertNotNil(customAnnotationView)
}
}

View File

@@ -1,109 +1,106 @@
import XCTest
import MapLibre
import XCTest
class MLNMapViewDelegateIntegrationTests: XCTestCase {
func testCoverage() {
MLNSDKTestHelpers.checkTestsContainAllMethods(testClass: MLNMapViewDelegateIntegrationTests.self, in: MLNMapViewDelegate.self)
}
}
extension MLNMapViewDelegateIntegrationTests: MLNMapViewDelegate {
func mapViewRegionIsChanging(_: MLNMapView) {}
func mapViewRegionIsChanging(_ mapView: MLNMapView) {}
func mapViewRegionIsChanging(_: MLNMapView, reason _: MLNCameraChangeReason) {}
func mapViewRegionIsChanging(_ mapView: MLNMapView, reason: MLNCameraChangeReason) {}
func mapView(_: MLNMapView, regionIsChangingWith _: MLNCameraChangeReason) {}
func mapView(_ mapView: MLNMapView, regionIsChangingWith reason: MLNCameraChangeReason) {}
func mapView(_: MLNMapView, didChange _: MLNUserTrackingMode, animated _: Bool) {}
func mapView(_ mapView: MLNMapView, didChange mode: MLNUserTrackingMode, animated: Bool) {}
func mapViewDidFinishLoadingMap(_: MLNMapView) {}
func mapViewDidFinishLoadingMap(_ mapView: MLNMapView) {}
func mapViewDidStopLocatingUser(_: MLNMapView) {}
func mapViewDidStopLocatingUser(_ mapView: MLNMapView) {}
func mapViewWillStartLoadingMap(_: MLNMapView) {}
func mapViewWillStartLoadingMap(_ mapView: MLNMapView) {}
func mapViewWillStartLocatingUser(_: MLNMapView) {}
func mapViewWillStartLocatingUser(_ mapView: MLNMapView) {}
func mapViewWillStartRenderingMap(_: MLNMapView) {}
func mapViewWillStartRenderingMap(_ mapView: MLNMapView) {}
func mapViewWillStartRenderingFrame(_: MLNMapView) {}
func mapViewWillStartRenderingFrame(_ mapView: MLNMapView) {}
func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {}
func mapView(_ mapView: MLNMapView, didFinishLoading style: MLNStyle) {}
func mapView(_: MLNMapView, didSelect _: MLNAnnotation) {}
func mapView(_ mapView: MLNMapView, didSelect annotation: MLNAnnotation) {}
func mapView(_: MLNMapView, didDeselect _: MLNAnnotation) {}
func mapView(_ mapView: MLNMapView, didDeselect annotation: MLNAnnotation) {}
func mapView(_: MLNMapView, didSingleTapAt _: CLLocationCoordinate2D) {}
func mapView(_ mapView: MLNMapView, didSingleTapAt coordinate: CLLocationCoordinate2D) {}
func mapView(_: MLNMapView, regionDidChangeAnimated _: Bool) {}
func mapView(_ mapView: MLNMapView, regionDidChangeAnimated animated: Bool) {}
func mapView(_: MLNMapView, regionDidChangeWith _: MLNCameraChangeReason, animated _: Bool) {}
func mapView(_ mapView: MLNMapView, regionDidChangeWith reason: MLNCameraChangeReason, animated: Bool) {}
func mapView(_: MLNMapView, regionWillChangeAnimated _: Bool) {}
func mapView(_ mapView: MLNMapView, regionWillChangeAnimated animated: Bool) {}
func mapView(_: MLNMapView, regionWillChangeWith _: MLNCameraChangeReason, animated _: Bool) {}
func mapView(_ mapView: MLNMapView, regionWillChangeWith reason: MLNCameraChangeReason, animated: Bool) {}
func mapViewDidFailLoadingMap(_: MLNMapView, withError _: Error) {}
func mapViewDidFailLoadingMap(_ mapView: MLNMapView, withError error: Error) {}
func mapView(_: MLNMapView, didUpdate _: MLNUserLocation?) {}
func mapView(_ mapView: MLNMapView, didUpdate userLocation: MLNUserLocation?) {}
func mapViewDidFinishRenderingMap(_: MLNMapView, fullyRendered _: Bool) {}
func mapViewDidFinishRenderingMap(_ mapView: MLNMapView, fullyRendered: Bool) {}
func mapViewDidBecomeIdle(_ mapView: MLNMapView) {}
func mapViewDidBecomeIdle(_: MLNMapView) {}
func mapView(_ mapView: MLNMapView, didFailToLocateUserWithError error: Error) {}
func mapView(_: MLNMapView, didFailToLocateUserWithError _: Error) {}
func mapView(_ mapView: MLNMapView, tapOnCalloutFor annotation: MLNAnnotation) {}
func mapView(_: MLNMapView, tapOnCalloutFor _: MLNAnnotation) {}
func mapViewDidFinishRenderingFrame(_ mapView: MLNMapView, fullyRendered: Bool) {}
func mapViewDidFinishRenderingFrame(_: MLNMapView, fullyRendered _: Bool) {}
func mapViewDidFinishRenderingFrame(_ mapView: MLNMapView, fullyRendered: Bool, frameEncodingTime: Double, frameRenderingTime: Double) {}
func mapView(_ mapView: MLNMapView, shapeAnnotationIsEnabled annotation: MLNShape) -> Bool { return false }
func mapViewDidFinishRenderingFrame(_: MLNMapView, fullyRendered _: Bool, frameEncodingTime _: Double, frameRenderingTime _: Double) {}
func mapView(_ mapView: MLNMapView, didAdd annotationViews: [MLNAnnotationView]) {}
func mapView(_: MLNMapView, shapeAnnotationIsEnabled _: MLNShape) -> Bool { false }
func mapView(_ mapView: MLNMapView, didSelect annotationView: MLNAnnotationView) {}
func mapView(_: MLNMapView, didAdd _: [MLNAnnotationView]) {}
func mapView(_ mapView: MLNMapView, didDeselect annotationView: MLNAnnotationView) {}
func mapView(_: MLNMapView, didSelect _: MLNAnnotationView) {}
func mapView(_ mapView: MLNMapView, alphaForShapeAnnotation annotation: MLNShape) -> CGFloat { return 0 }
func mapView(_: MLNMapView, didDeselect _: MLNAnnotationView) {}
func mapView(_ mapView: MLNMapView, viewFor annotation: MLNAnnotation) -> MLNAnnotationView? { return nil }
func mapView(_: MLNMapView, alphaForShapeAnnotation _: MLNShape) -> CGFloat { 0 }
func mapView(_ mapView: MLNMapView, imageFor annotation: MLNAnnotation) -> MLNAnnotationImage? { return nil }
func mapView(_: MLNMapView, viewFor _: MLNAnnotation) -> MLNAnnotationView? { nil }
func mapView(_ mapView: MLNMapView, annotationCanShowCallout annotation: MLNAnnotation) -> Bool { return false }
func mapView(_: MLNMapView, imageFor _: MLNAnnotation) -> MLNAnnotationImage? { nil }
func mapView(_ mapView: MLNMapView, calloutViewFor annotation: MLNAnnotation) -> MLNCalloutView? { return nil }
func mapView(_: MLNMapView, annotationCanShowCallout _: MLNAnnotation) -> Bool { false }
func mapView(_ mapView: MLNMapView, strokeColorForShapeAnnotation annotation: MLNShape) -> UIColor { return .black }
func mapView(_: MLNMapView, calloutViewFor _: MLNAnnotation) -> MLNCalloutView? { nil }
func mapView(_ mapView: MLNMapView, fillColorForPolygonAnnotation annotation: MLNPolygon) -> UIColor { return .black }
func mapView(_: MLNMapView, strokeColorForShapeAnnotation _: MLNShape) -> UIColor { .black }
func mapView(_ mapView: MLNMapView, leftCalloutAccessoryViewFor annotation: MLNAnnotation) -> UIView? { return nil }
func mapView(_: MLNMapView, fillColorForPolygonAnnotation _: MLNPolygon) -> UIColor { .black }
func mapView(_ mapView: MLNMapView, lineWidthForPolylineAnnotation annotation: MLNPolyline) -> CGFloat { return 0 }
func mapView(_: MLNMapView, leftCalloutAccessoryViewFor _: MLNAnnotation) -> UIView? { nil }
func mapView(_ mapView: MLNMapView, rightCalloutAccessoryViewFor annotation: MLNAnnotation) -> UIView? { return nil }
func mapView(_: MLNMapView, lineWidthForPolylineAnnotation _: MLNPolyline) -> CGFloat { 0 }
func mapView(_ mapView: MLNMapView, annotation: MLNAnnotation, calloutAccessoryControlTapped control: UIControl) {}
func mapView(_: MLNMapView, rightCalloutAccessoryViewFor _: MLNAnnotation) -> UIView? { nil }
func mapView(_ mapView: MLNMapView, shouldChangeFrom oldCamera: MLNMapCamera, to newCamera: MLNMapCamera) -> Bool { return false }
func mapView(_: MLNMapView, annotation _: MLNAnnotation, calloutAccessoryControlTapped _: UIControl) {}
func mapView(_ mapView: MLNMapView, shouldChangeFrom oldCamera: MLNMapCamera, to newCamera: MLNMapCamera, reason: MLNCameraChangeReason) -> Bool { return false }
func mapViewUserLocationAnchorPoint(_ mapView: MLNMapView) -> CGPoint { return CGPoint(x: 100, y: 100) }
func mapView(_ mapView: MLNMapView, didFailToLoadImage imageName: String) -> UIImage? { return nil }
func mapView(_ mapView: MLNMapView, shouldRemoveStyleImage imageName: String) -> Bool { return false }
func mapView(_: MLNMapView, shouldChangeFrom _: MLNMapCamera, to _: MLNMapCamera) -> Bool { false }
func mapView(_ mapView: MLNMapView, didChangeLocationManagerAuthorization manager: MLNLocationManager) {}
func mapView(_: MLNMapView, shouldChangeFrom _: MLNMapCamera, to _: MLNMapCamera, reason _: MLNCameraChangeReason) -> Bool { false }
func mapView(styleForDefaultUserLocationAnnotationView mapView: MLNMapView) -> MLNUserLocationAnnotationViewStyle { return MLNUserLocationAnnotationViewStyle() }
func mapViewUserLocationAnchorPoint(_: MLNMapView) -> CGPoint { CGPoint(x: 100, y: 100) }
func mapView(_: MLNMapView, didFailToLoadImage _: String) -> UIImage? { nil }
func mapView(_: MLNMapView, shouldRemoveStyleImage _: String) -> Bool { false }
func mapView(_: MLNMapView, didChangeLocationManagerAuthorization _: MLNLocationManager) {}
func mapView(styleForDefaultUserLocationAnnotationView _: MLNMapView) -> MLNUserLocationAnnotationViewStyle { MLNUserLocationAnnotationViewStyle() }
}

View File

@@ -1,65 +1,62 @@
import XCTest
import Mapbox
import XCTest
class MLNMapViewDelegateIntegrationTests: XCTestCase {
func testCoverage() {
MLNSDKTestHelpers.checkTestsContainAllMethods(testClass: MLNMapViewDelegateIntegrationTests.self, in: MLNMapViewDelegate.self)
}
}
extension MLNMapViewDelegateIntegrationTests: MLNMapViewDelegate {
func mapView(_: MLNMapView, shouldChangeFrom _: MLNMapCamera, to _: MLNMapCamera) -> Bool { false }
func mapView(_ mapView: MLNMapView, shouldChangeFrom oldCamera: MLNMapCamera, to newCamera: MLNMapCamera) -> Bool { return false }
func mapView(_: MLNMapView, lineWidthForPolylineAnnotation _: MLNPolyline) -> CGFloat { 0 }
func mapView(_ mapView: MLNMapView, lineWidthForPolylineAnnotation annotation: MLNPolyline) -> CGFloat { return 0 }
func mapView(_: MLNMapView, annotationCanShowCallout _: MLNAnnotation) -> Bool { false }
func mapView(_ mapView: MLNMapView, annotationCanShowCallout annotation: MLNAnnotation) -> Bool { return false }
func mapView(_: MLNMapView, imageFor _: MLNAnnotation) -> MLNAnnotationImage? { nil }
func mapView(_ mapView: MLNMapView, imageFor annotation: MLNAnnotation) -> MLNAnnotationImage? { return nil }
func mapView(_: MLNMapView, alphaForShapeAnnotation _: MLNShape) -> CGFloat { 0 }
func mapView(_ mapView: MLNMapView, alphaForShapeAnnotation annotation: MLNShape) -> CGFloat { return 0 }
func mapViewDidFinishRenderingFrame(_: MLNMapView, fullyRendered _: Bool) {}
func mapViewDidFinishRenderingFrame(_ mapView: MLNMapView, fullyRendered: Bool) {}
func mapViewDidFinishRenderingFrame(_: MLNMapView, fullyRendered _: Bool, frameTime _: Double) {}
func mapViewDidFinishRenderingFrame(_ mapView: MLNMapView, fullyRendered: Bool, frameTime: Double) {}
func mapViewDidFinishRenderingMap(_: MLNMapView, fullyRendered _: Bool) {}
func mapViewDidFinishRenderingMap(_ mapView: MLNMapView, fullyRendered: Bool) {}
func mapViewDidBecomeIdle(_ mapView: MLNMapView) {}
func mapViewDidBecomeIdle(_: MLNMapView) {}
func mapViewDidFailLoadingMap(_ mapView: MLNMapView, withError error: Error) {}
func mapViewDidFailLoadingMap(_: MLNMapView, withError _: Error) {}
func mapView(_ mapView: MLNMapView, didFailToLoadImage imageName: String) -> NSImage? { return nil }
func mapView(_ mapView: MLNMapView, shapeAnnotationIsEnabled annotation: MLNShape) -> Bool { return false }
func mapView(_: MLNMapView, didFailToLoadImage _: String) -> NSImage? { nil }
func mapView(_ mapView: MLNMapView, didDeselect annotation: MLNAnnotation) {}
func mapView(_: MLNMapView, shapeAnnotationIsEnabled _: MLNShape) -> Bool { false }
func mapView(_ mapView: MLNMapView, didSelect annotation: MLNAnnotation) {}
func mapView(_: MLNMapView, didDeselect _: MLNAnnotation) {}
func mapView(_ mapView: MLNMapView, didFinishLoading style: MLNStyle) {}
func mapView(_: MLNMapView, didSelect _: MLNAnnotation) {}
func mapViewWillStartRenderingFrame(_ mapView: MLNMapView) {}
func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {}
func mapViewWillStartRenderingMap(_ mapView: MLNMapView) {}
func mapViewWillStartRenderingFrame(_: MLNMapView) {}
func mapViewWillStartLoadingMap(_ mapView: MLNMapView) {}
func mapViewWillStartRenderingMap(_: MLNMapView) {}
func mapViewDidFinishLoadingMap(_ mapView: MLNMapView) {}
func mapViewWillStartLoadingMap(_: MLNMapView) {}
func mapViewCameraIsChanging(_ mapView: MLNMapView) {}
func mapViewDidFinishLoadingMap(_: MLNMapView) {}
func mapView(_ mapView: MLNMapView, cameraDidChangeAnimated animated: Bool) {}
func mapViewCameraIsChanging(_: MLNMapView) {}
func mapView(_ mapView: MLNMapView, cameraWillChangeAnimated animated: Bool) {}
func mapView(_: MLNMapView, cameraDidChangeAnimated _: Bool) {}
func mapView(_ mapView: MLNMapView, strokeColorForShapeAnnotation annotation: MLNShape) -> NSColor { return .black }
func mapView(_: MLNMapView, cameraWillChangeAnimated _: Bool) {}
func mapView(_ mapView: MLNMapView, fillColorForPolygonAnnotation annotation: MLNPolygon) -> NSColor { return .black }
func mapView(_: MLNMapView, strokeColorForShapeAnnotation _: MLNShape) -> NSColor { .black }
func mapView(_ mapView: MLNMapView, calloutViewControllerFor annotation: MLNAnnotation) -> NSViewController? { return nil }
func mapView(_: MLNMapView, fillColorForPolygonAnnotation _: MLNPolygon) -> NSColor { .black }
func mapView(_ mapView: MLNMapView, shouldRemoveStyleImage imageName: String) -> Bool { return false }
func mapView(_: MLNMapView, calloutViewControllerFor _: MLNAnnotation) -> NSViewController? { nil }
func mapView(_: MLNMapView, shouldRemoveStyleImage _: String) -> Bool { false }
}

View File

@@ -1,8 +1,9 @@
#!/usr/bin/swift
import Foundation
/// Generates Entitlement files .xcent for codesigning, containing the correct team id
import Swift
import Foundation
let fileManager = FileManager.default
@@ -16,12 +17,11 @@ guard let rawTeamIdEnv = getenv("IOS_DEVELOPMENT_TEAM") else {
let teamId2 = String(utf8String: rawTeamIdEnv)
for file in contentsOfCurrentWorkingDirectory {
if (file.pathExtension == "template") {
if file.pathExtension == "template" {
var content = ""
do {
content = try String(contentsOf: file, encoding: .utf8)
}
catch {
} catch {
print("Error reading xcent file: \(error).")
}
@@ -32,9 +32,8 @@ for file in contentsOfCurrentWorkingDirectory {
do {
try content.write(to: targetFile, atomically: false, encoding: .utf8)
print("Entitlement " + targetFile.absoluteString + " generated.")
}
catch {
} catch {
print("Error writing xcent file: \(error).")
}
}
}
}