@@ -48,7 +48,7 @@ import Foundation
4848/// showError()
4949/// }
5050///
51- public enum Device {
51+ public enum Device : Sendable {
5252 #if os(iOS)
5353 /// Device is an [iPod touch (5th generation)](https://support.apple.com/kb/SP657)
5454 ///
@@ -550,7 +550,7 @@ public enum Device {
550550 }
551551
552552 /// Gets the identifier from the system, such as "iPhone7,1".
553- public static var identifier : String = {
553+ public static let identifier : String = {
554554 var systemInfo = utsname ( )
555555 uname ( & systemInfo)
556556 let mirror = Mirror ( reflecting: systemInfo. machine)
@@ -1073,13 +1073,15 @@ public enum Device {
10731073 }
10741074
10751075 /// Returns whether the device is an iPhone (real or simulator)
1076+ @MainActor
10761077 public var isPhone : Bool {
10771078 return ( isOneOf ( Device . allPhones)
10781079 || isOneOf ( Device . allSimulatorPhones)
10791080 || ( UIDevice . current. userInterfaceIdiom == . phone && isCurrent) ) && !isPod
10801081 }
10811082
10821083 /// Returns whether the device is an iPad (real or simulator)
1084+ @MainActor
10831085 public var isPad : Bool {
10841086 return isOneOf ( Device . allPads)
10851087 || isOneOf ( Device . allSimulatorPads)
@@ -1092,6 +1094,7 @@ public enum Device {
10921094 return Device . realDevice ( from: self )
10931095 }
10941096
1097+ @MainActor
10951098 public var isZoomed : Bool ? {
10961099 guard isCurrent else { return nil }
10971100 if Int ( UIScreen . main. scale. rounded ( ) ) == 3 {
@@ -1328,6 +1331,9 @@ public enum Device {
13281331 /// The name identifying the device (e.g. "Dennis' iPhone").
13291332 /// As of iOS 16, this will return a generic String like "iPhone", unless your app has additional entitlements.
13301333 /// See the follwing link for more information: https://developer.apple.com/documentation/uikit/uidevice/1620015-name
1334+ #if !os(watchOS) && canImport(UIKit)
1335+ @MainActor
1336+ #endif
13311337 public var name : String ? {
13321338 guard isCurrent else { return nil }
13331339 #if os(watchOS)
@@ -1340,6 +1346,9 @@ public enum Device {
13401346 }
13411347
13421348 /// The name of the operating system running on the device represented by the receiver (e.g. "iOS" or "tvOS").
1349+ #if !os(watchOS) && (os(iOS) || canImport(UIKit))
1350+ @MainActor
1351+ #endif
13431352 public var systemName : String ? {
13441353 guard isCurrent else { return nil }
13451354 #if os(watchOS)
@@ -1358,6 +1367,9 @@ public enum Device {
13581367 }
13591368
13601369 /// The current version of the operating system (e.g. 8.4 or 9.2).
1370+ #if !os(watchOS) && canImport(UIKit)
1371+ @MainActor
1372+ #endif
13611373 public var systemVersion : String ? {
13621374 guard isCurrent else { return nil }
13631375 #if os(watchOS)
@@ -1370,6 +1382,9 @@ public enum Device {
13701382 }
13711383
13721384 /// The model of the device (e.g. "iPhone" or "iPod Touch").
1385+ #if !os(watchOS) && canImport(UIKit)
1386+ @MainActor
1387+ #endif
13731388 public var model : String ? {
13741389 guard isCurrent else { return nil }
13751390 #if os(watchOS)
@@ -1382,6 +1397,9 @@ public enum Device {
13821397 }
13831398
13841399 /// The model of the device as a localized string.
1400+ #if !os(watchOS) && canImport(UIKit)
1401+ @MainActor
1402+ #endif
13851403 public var localizedModel : String ? {
13861404 guard isCurrent else { return nil }
13871405 #if os(watchOS)
@@ -1532,6 +1550,9 @@ public enum Device {
15321550 }
15331551
15341552 /// True when a Guided Access session is currently active; otherwise, false.
1553+ #if os(iOS)
1554+ @MainActor
1555+ #endif
15351556 public var isGuidedAccessSessionActive : Bool {
15361557 #if os(iOS)
15371558 #if swift(>=4.2)
@@ -1545,6 +1566,9 @@ public enum Device {
15451566 }
15461567
15471568 /// The brightness level of the screen.
1569+ #if os(iOS)
1570+ @MainActor
1571+ #endif
15481572 public var screenBrightness : Int {
15491573 #if os(iOS)
15501574 return Int ( UIScreen . main. brightness * 100 )
@@ -1884,7 +1908,7 @@ extension Device {
18841908 - Charging: The device is plugged into power and the battery is less than 100% charged.
18851909 - Unplugged: The device is not plugged into power; the battery is discharging.
18861910 */
1887- public enum BatteryState : CustomStringConvertible , Equatable {
1911+ public enum BatteryState : CustomStringConvertible , Equatable , Sendable {
18881912 /// The device is plugged into power and the battery is 100% charged or the device is the iOS Simulator.
18891913 case full
18901914 /// The device is plugged into power and the battery is less than 100% charged.
@@ -1895,6 +1919,7 @@ extension Device {
18951919 case unplugged( Int )
18961920
18971921 #if os(iOS)
1922+ @MainActor
18981923 fileprivate init ( ) {
18991924 let wasBatteryMonitoringEnabled = UIDevice . current. isBatteryMonitoringEnabled
19001925 UIDevice . current. isBatteryMonitoringEnabled = true
@@ -1951,12 +1976,18 @@ extension Device {
19511976 }
19521977
19531978 /// The state of the battery
1979+ #if os(iOS)
1980+ @MainActor
1981+ #endif
19541982 public var batteryState : BatteryState ? {
19551983 guard isCurrent else { return nil }
19561984 return BatteryState ( )
19571985 }
19581986
19591987 /// Battery level ranges from 0 (fully discharged) to 100 (100% charged).
1988+ #if os(iOS)
1989+ @MainActor
1990+ #endif
19601991 public var batteryLevel : Int ? {
19611992 guard isCurrent else { return nil }
19621993 switch BatteryState ( ) {
@@ -2012,16 +2043,18 @@ extension Device {
20122043 - Portrait: The device is in Portrait Orientation
20132044 - Unknown: The device orientation is unknown.
20142045 */
2015- public enum Orientation {
2046+ public enum Orientation : Sendable {
20162047 case landscape
20172048 case portrait
20182049 case unknown
20192050 }
20202051
2052+ @MainActor
20212053 public var orientation : Orientation {
2022- if UIDevice . current. orientation. isLandscape {
2054+ let orientation = UIDevice . current. orientation
2055+ if orientation. isLandscape {
20232056 return . landscape
2024- } else if UIDevice . current . orientation. isPortrait {
2057+ } else if orientation. isPortrait {
20252058 return . portrait
20262059 } else {
20272060 return . unknown
@@ -2097,7 +2130,7 @@ extension Device {
20972130 - firstGenerationUsbC: 1st Generation Apple Pencil (USB-C)
20982131 - pro: Apple Pencil Pro
20992132 */
2100- public struct ApplePencilSupport : OptionSet {
2133+ public struct ApplePencilSupport : OptionSet , Sendable {
21012134
21022135 public var rawValue : UInt
21032136
@@ -2160,7 +2193,7 @@ extension Device {
21602193// MARK: Cameras
21612194extension Device {
21622195
2163- public enum CameraType {
2196+ public enum CameraType : Sendable {
21642197 @available ( * , deprecated, renamed: " wide " )
21652198 case normal
21662199
@@ -2317,7 +2350,7 @@ extension Device {
23172350}
23182351#endif
23192352
2320- // MARK: ThermalState
2353+ // MARK: ThermalState: Sendable
23212354@available ( iOS 11 . 0 , watchOS 4 . 0 , macOS 10 . 10 . 3 , tvOS 11 . 0 , * )
23222355extension Device {
23232356 /// The thermal state of the system.
@@ -2354,7 +2387,7 @@ extension Device {
23542387
23552388extension Device {
23562389
2357- public enum CPU : Comparable {
2390+ public enum CPU : Comparable , Sendable {
23582391 #if os(iOS) || os(tvOS)
23592392 case a4
23602393 case a5
0 commit comments