Skip to content

Commit

Permalink
Remove outdated availability attributes (#2409)
Browse files Browse the repository at this point in the history
  • Loading branch information
OdNairy authored Jan 17, 2025
1 parent 12f6598 commit ee0465d
Show file tree
Hide file tree
Showing 138 changed files with 186 additions and 629 deletions.
4 changes: 2 additions & 2 deletions Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_GENERATE_MAP_FILE = YES;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -1216,7 +1216,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_GENERATE_MAP_FILE = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
name: "MapboxMaps",
defaultLocalization: "en",
// Maps SDK doesn't support macOS but declared the minimum macOS requirement with downstream deps to enable `swift run` cli tools
platforms: [.iOS(.v12), .macOS(.v10_15), .custom("visionos", versionString: "1.0")],
platforms: [.iOS(.v14), .macOS(.v10_15), .custom("visionos", versionString: "1.0")],
products: [
.library(
name: "MapboxMaps",
Expand Down
42 changes: 2 additions & 40 deletions Sources/Examples/All Examples/BasicLocationPulsingExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,8 @@ final class BasicLocationPulsingExample: UIViewController, ExampleProtocol {
mapView.mapboxMap.setCamera(to: .init(center: location.coordinate, zoom: 18))
}.store(in: &cancelables)

if #available(iOS 14.0, *) {
navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .action)
updateMenu()
} else {
navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .action,
target: self,
action: #selector(showOptions)
)
}
navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .action)
updateMenu()
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -75,36 +67,6 @@ final class BasicLocationPulsingExample: UIViewController, ExampleProtocol {
mapView.location.options.puckType = .puck2D(.makeDefault())
}

@objc private func showOptions() {
let constantPulseAction = UIAlertAction(title: "Pulse with constant radius", style: .default) { _ in
self.enablePulsingWithConstantRadius()
}
let accuracyPulseAction = UIAlertAction(title: "Pulse with accuracy radius", style: .default) { _ in
self.enablePulsingWithAccuracyRadius()
}
let stopPulseAction = UIAlertAction(title: "None", style: .default) { _ in
self.disablePulsing()
}

let staticAccuracyRingAction = UIAlertAction(title: "Static with accuracy radius", style: .default) { _ in
self.enableStaticAccuracyCircle()
}

let cancelAction = UIAlertAction(title: "Dismiss", style: .cancel)

let controller = UIAlertController(title: "Puck circle", message: nil, preferredStyle: .actionSheet)
controller.modalPresentationStyle = .popover
if #available(iOS 16.0, *) {
controller.popoverPresentationController?.sourceItem = navigationItem.rightBarButtonItem
} else {
controller.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
}
[constantPulseAction, accuracyPulseAction, staticAccuracyRingAction, stopPulseAction, cancelAction]
.forEach(controller.addAction)

present(controller, animated: true)
}

private func updateMenu() {
let state = mapView.location.options.puckType.map { type -> PuckCircle? in
if case PuckType.puck2D(let config) = type {
Expand Down
36 changes: 8 additions & 28 deletions Sources/Examples/All Examples/BuildingExtrusionsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,40 @@ final class BuildingExtrusionsExample: UIViewController, ExampleProtocol {

private lazy var lightPositionButton: UIButton = {
let button = UIButton.exampleActionButton()
if #available(iOS 13.1, *) {
button.setImage(UIImage(systemName: "flashlight.on.fill"), for: .normal)
} else {
button.setTitle("Position", for: .normal)
}
button.setImage(UIImage(systemName: "flashlight.on.fill"), for: .normal)
button.addTarget(self, action: #selector(lightPositionButtonTapped(_:)), for: .primaryActionTriggered)
return button
}()

private lazy var lightColorButton: UIButton = {
let button = UIButton.exampleActionButton()
if #available(iOS 13.0, *) {
button.setImage(UIImage(systemName: "paintbrush.fill"), for: .normal)
} else {
button.setTitle("Color", for: .normal)
}
button.setImage(UIImage(systemName: "paintbrush.fill"), for: .normal)
button.addTarget(self, action: #selector(lightColorButtonTapped(_:)), for: .primaryActionTriggered)
return button
}()

private lazy var heightAlignmentButton: UIButton = {
let button = UIButton.exampleActionButton()

if #available(iOS 15.0, *) {
button.setImage(UIImage(systemName: "align.vertical.top"), for: .normal)
button.setImage(UIImage(systemName: "align.vertical.top.fill"), for: .selected)
} else {
button.setTitle("Height Alignment", for: .normal)
}
button.setImage(UIImage(systemName: "align.vertical.top"), for: .normal)
button.setImage(UIImage(systemName: "align.vertical.top.fill"), for: .selected)
button.addTarget(self, action: #selector(heightAlignmentButtonTapped(_:)), for: .primaryActionTriggered)
return button
}()

private lazy var baseAlignmentButton: UIButton = {
let button = UIButton.exampleActionButton()

if #available(iOS 15.0, *) {
button.setImage(UIImage(systemName: "align.vertical.bottom"), for: .normal)
button.setImage(UIImage(systemName: "align.vertical.bottom.fill"), for: .selected)
} else {
button.setTitle("Height Alignment", for: .normal)
}
button.setImage(UIImage(systemName: "align.vertical.bottom"), for: .normal)
button.setImage(UIImage(systemName: "align.vertical.bottom.fill"), for: .selected)
button.addTarget(self, action: #selector(baseAlignmentButtonTapped(_:)), for: .primaryActionTriggered)
return button
}()

private lazy var terrainSwitchButton: UIButton = {
let button = UIButton.exampleActionButton()
if #available(iOS 15.0, *) {
button.setImage(UIImage(systemName: "mountain.2"), for: .normal)
button.setImage(UIImage(systemName: "mountain.2.fill"), for: .selected)
} else {
button.setTitle("Terrain", for: .normal)
}
button.setImage(UIImage(systemName: "mountain.2"), for: .normal)
button.setImage(UIImage(systemName: "mountain.2.fill"), for: .selected)

button.addTarget(self, action: #selector(terrainButtonTapped(_:)), for: .primaryActionTriggered)
return button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ class ApplicationCarPlaySceneDelegage: NSObject, CPTemplateApplicationSceneDeleg
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController, to window: CPWindow) {
window.rootViewController = applicationVC
let mapTemplate = CPMapTemplate()
if #available(iOS 14.0, *) {
mapTemplate.leadingNavigationBarButtons = [
CPBarButton(title: "Start") { _ in
CarPlayViewController.shared.play()
}
]
mapTemplate.trailingNavigationBarButtons = [
CPBarButton(title: "Stop") { _ in
CarPlayViewController.shared.stop()
}
]
}
mapTemplate.leadingNavigationBarButtons = [
CPBarButton(title: "Start") { _ in
CarPlayViewController.shared.play()
}
]
mapTemplate.trailingNavigationBarButtons = [
CPBarButton(title: "Stop") { _ in
CarPlayViewController.shared.stop()
}
]
interfaceController.setRootTemplate(mapTemplate, animated: false, completion: nil)
}

Expand Down
10 changes: 4 additions & 6 deletions Sources/Examples/All Examples/CustomLayerExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ final class CustomLayerExample: UIViewController, ExampleProtocol {

mapView = MapView(frame: view.bounds, mapInitOptions: MapInitOptions(cameraOptions: cameraOptions))
mapView.mapboxMap.mapStyle = .streets
if #available(iOS 13.0, *) {
mapView.mapboxMap.setMapStyleContent {
StyleProjection(name: .mercator)
CustomLayer(id: "custom-layer-example", renderer: renderer)
.position(.below("waterway"))
}
mapView.mapboxMap.setMapStyleContent {
StyleProjection(name: .mercator)
CustomLayer(id: "custom-layer-example", renderer: renderer)
.position(.below("waterway"))
}

mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
Expand Down
6 changes: 2 additions & 4 deletions Sources/Examples/All Examples/DebugMapExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ final class DebugMapExample: UIViewController, ExampleProtocol {
super.viewDidLoad()

mapView = MapView(frame: view.bounds)
if #available(iOS 15.0, *) {
let maxFPS = Float(UIScreen.main.maximumFramesPerSecond)
mapView.preferredFrameRateRange = CAFrameRateRange(minimum: 1, maximum: maxFPS, preferred: maxFPS)
}
let maxFPS = Float(UIScreen.main.maximumFramesPerSecond)
mapView.preferredFrameRateRange = CAFrameRateRange(minimum: 1, maximum: maxFPS, preferred: maxFPS)

view.addSubview(mapView)
view.backgroundColor = .skyBlue
Expand Down
10 changes: 2 additions & 8 deletions Sources/Examples/All Examples/Lab/CombineExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ private extension UILabel {
static func makeCameraLabel() -> UILabel {
let label = UILabel()
label.numberOfLines = 0
if #available(iOS 13.0, *) {
label.backgroundColor = UIColor.systemBackground
} else {
label.backgroundColor = .white
}
label.backgroundColor = UIColor.systemBackground
label.layer.cornerRadius = 5
label.layer.masksToBounds = true
return label
Expand All @@ -57,9 +53,7 @@ private extension UILabel {
private extension NSAttributedString {
static func logString(_ text: String, bold: Bool = false) -> NSAttributedString {
var attributes = [NSAttributedString.Key: Any]()
if #available(iOS 13.0, *) {
attributes[.font] = UIFont.monospacedSystemFont(ofSize: 13, weight: bold ? .bold : .regular)
}
attributes[.font] = UIFont.monospacedSystemFont(ofSize: 13, weight: bold ? .bold : .regular)
return NSAttributedString(string: text, attributes: attributes)
}

Expand Down
44 changes: 19 additions & 25 deletions Sources/Examples/All Examples/Lab/Lights3DExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,28 @@ final class Lights3DExample: UIViewController, ExampleProtocol {
}

func sunAnimationButton() -> UIBarButtonItem {
if #available(iOS 13, *) {
return UIBarButtonItem(image: UIImage(systemName: "sunrise"), style: .plain, target: self, action: #selector(startSunAnimation))
} else {
return UIBarButtonItem(title: "Sun", style: .plain, target: self, action: #selector(startSunAnimation))
}
return UIBarButtonItem(image: UIImage(systemName: "sunrise"), style: .plain, target: self, action: #selector(startSunAnimation))
}

func updateMapState(azimuth: Double = 210, polarAngle: Double = 30, ambientColor: UIColor = .lightGray) {
if #available(iOS 13.0, *) {
/// We use the new experimental style content feature to set the lights.
mapView.mapboxMap.setMapStyleContent {
Atmosphere()
.range(start: 0, end: 12)
.horizonBlend(0.1)
.starIntensity(0.2)
.color(StyleColor(red: 240, green: 196, blue: 152, alpha: 1)!)
.highColor(StyleColor(red: 221, green: 209, blue: 197, alpha: 1)!)
.spaceColor(StyleColor(red: 153, green: 180, blue: 197, alpha: 1)!)
DirectionalLight(id: directionalLightId)
.intensity(0.5)
.direction(azimuthal: azimuth, polar: polarAngle)
.directionTransition(.zero)
.castShadows(true)
.shadowIntensity(1)
AmbientLight(id: ambientLightId)
.color(ambientColor)
.intensity(0.5)
}
/// We use the new experimental style content feature to set the lights.
mapView.mapboxMap.setMapStyleContent {
Atmosphere()
.range(start: 0, end: 12)
.horizonBlend(0.1)
.starIntensity(0.2)
.color(StyleColor(red: 240, green: 196, blue: 152, alpha: 1)!)
.highColor(StyleColor(red: 221, green: 209, blue: 197, alpha: 1)!)
.spaceColor(StyleColor(red: 153, green: 180, blue: 197, alpha: 1)!)
DirectionalLight(id: directionalLightId)
.intensity(0.5)
.direction(azimuthal: azimuth, polar: polarAngle)
.directionTransition(.zero)
.castShadows(true)
.shadowIntensity(1)
AmbientLight(id: ambientLightId)
.color(ambientColor)
.intensity(0.5)
}
}

Expand Down
16 changes: 3 additions & 13 deletions Sources/Examples/All Examples/Lab/MapEventsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ final class MapEventsExample: UIViewController, ExampleProtocol {
override func viewDidLoad() {
super.viewDidLoad()

if #available(iOS 13, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
view.backgroundColor = .systemBackground

mapView = MapView(frame: view.bounds)
mapView.ornaments.options.scaleBar.visibility = .visible
Expand Down Expand Up @@ -145,9 +141,7 @@ extension LogableEvent {
private extension NSAttributedString {
static func logString(_ text: String, bold: Bool = false) -> NSAttributedString {
var attributes = [NSAttributedString.Key: Any]()
if #available(iOS 13.0, *) {
attributes[.font] = UIFont.monospacedSystemFont(ofSize: 13, weight: bold ? .bold : .regular)
}
attributes[.font] = UIFont.monospacedSystemFont(ofSize: 13, weight: bold ? .bold : .regular)
return NSAttributedString(string: text, attributes: attributes)
}

Expand Down Expand Up @@ -306,11 +300,7 @@ private extension UILabel {
static func makeCameraLabel() -> UILabel {
let label = UILabel()
label.numberOfLines = 0
if #available(iOS 13.0, *) {
label.backgroundColor = UIColor.systemBackground
} else {
label.backgroundColor = .white
}
label.backgroundColor = UIColor.systemBackground
label.layer.cornerRadius = 5
label.layer.masksToBounds = true
return label
Expand Down
8 changes: 2 additions & 6 deletions Sources/Examples/All Examples/Lab/ResizeMapViewExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,10 @@ final class ResizeMapViewExample: UIViewController, ExampleProtocol {
private func syncAnimationBehaviourButton(_ button: UIBarButtonItem) {
switch animationBehaviour {
case .automatic:
if #available(iOS 13.0, *) {
button.image = UIImage(systemName: "arrow.up.arrow.down.circle.fill")
}
button.image = UIImage(systemName: "arrow.up.arrow.down.circle.fill")
button.title = "Automatic"
case .none:
if #available(iOS 13.0, *) {
button.image = UIImage(systemName: "arrow.up.arrow.down.circle")
}
button.image = UIImage(systemName: "arrow.up.arrow.down.circle")
button.title = "None"
}
}
Expand Down
32 changes: 15 additions & 17 deletions Sources/Examples/All Examples/ModelLayerExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,23 @@ final class ModelLayerExample: UIViewController, ExampleProtocol {
var carFeature = Feature(geometry: Constants.mapboxHelsinki)
carFeature.properties = [Constants.modelIdKey: .string(Constants.carModelId)]

if #available(iOS 13, *) {
mapView.mapboxMap.setMapStyleContent {
/// Add Models for both the duck and car using an id and a URL to the resource
Model(id: Constants.duckModelId, uri: Constants.duck)
Model(id: Constants.carModelId, uri: Constants.car)
mapView.mapboxMap.setMapStyleContent {
/// Add Models for both the duck and car using an id and a URL to the resource
Model(id: Constants.duckModelId, uri: Constants.duck)
Model(id: Constants.carModelId, uri: Constants.car)

/// Add a GeoJSONSource to the map and add the two features with geometry information
GeoJSONSource(id: Constants.sourceId)
.data(.featureCollection(FeatureCollection(features: [duckFeature, carFeature])))
/// Add a GeoJSONSource to the map and add the two features with geometry information
GeoJSONSource(id: Constants.sourceId)
.data(.featureCollection(FeatureCollection(features: [duckFeature, carFeature])))

/// Add a Model visualization layer which displays the two models stored in the GeoJSONSource according to the set properties
ModelLayer(id: "model-layer-id", source: Constants.sourceId)
.modelId(Exp(.get) { Constants.modelIdKey })
.modelType(.common3d)
.modelScale(x: 40, y: 40, z: 40)
.modelTranslation(x: 0, y: 0, z: 0)
.modelRotation(x: 0, y: 0, z: 90)
.modelOpacity(0.7)
}
/// Add a Model visualization layer which displays the two models stored in the GeoJSONSource according to the set properties
ModelLayer(id: "model-layer-id", source: Constants.sourceId)
.modelId(Exp(.get) { Constants.modelIdKey })
.modelType(.common3d)
.modelScale(x: 40, y: 40, z: 40)
.modelTranslation(x: 0, y: 0, z: 0)
.modelRotation(x: 0, y: 0, z: 90)
.modelOpacity(0.7)
}

view.addSubview(mapView)
Expand Down
Loading

0 comments on commit ee0465d

Please sign in to comment.