Skip to content

Commit

Permalink
2024-08-03 - Swift 6 Concurrency (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
markbattistella authored Aug 3, 2024
1 parent 8d9342e commit 4bc9644
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 6 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
// swift-tools-version: 5.4
//
// Project: BezelKit
// Author: Mark Battistella
// Website: https://markbattistella.com
//
// swift-tools-version: 5.10

import PackageDescription

let package = Package(
name: "BezelKit",
platforms: [.iOS(.v11)],
platforms: [.iOS(.v12)],
products: [
.library(
name: "BezelKit",
Expand All @@ -21,7 +16,10 @@ let package = Package(
.target(
name: "BezelKit",
exclude: ["../../Generator"],
resources: [.process("Resources/bezel.min.json")]
resources: [.process("Resources/bezel.min.json")],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
)
]
)
9 changes: 5 additions & 4 deletions Sources/BezelKit/BezelKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import UIKit

/// `DeviceBezel` provides a mechanism to obtain the bezel radius of the current device.
@MainActor
public class DeviceBezel {

/// An enumeration of errors that can occur when attempting to obtain a device's bezel thickness.
Expand All @@ -22,18 +23,18 @@ public class DeviceBezel {
}

/// Cache to hold parsed device information.
private static var devices: Devices?
private static var devices: Devices?

/// A cache mapping device identifiers to their respective bezel thicknesses.
private static var cache: [String: CGFloat] = [:]
private static var cache: [String: CGFloat] = [:]

/// A callback to be invoked when an error occurs during bezel data fetching or processing.
public static var errorCallback: ((DeviceBezelError) -> Void)?
public static var errorCallback: ((DeviceBezelError) -> Void)?

/// Loads device data from the JSON resource, decoding and caching the relevant information.
///
/// - Throws: An error of type `DeviceBezelError` if there's an issue accessing or decoding the data.
private static func loadDeviceData() throws {
private static func loadDeviceData() throws {
guard let url = Bundle.module.url(
forResource: "bezel",
withExtension: "min.json"
Expand Down
3 changes: 2 additions & 1 deletion Sources/BezelKit/CGFloat+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import Foundation

@MainActor
public extension CGFloat {

/// A fallback value used when the device bezel radius cannot be determined.
private static var fallbackBezelValue: CGFloat = 0.0

Expand Down

0 comments on commit 4bc9644

Please sign in to comment.