Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-08-03 - Swift 6 Concurrency #36

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading