Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Mar 12, 2024
1 parent c4cce04 commit 5a37c3f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Sources/DeviceInformation/DeviceInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@ public struct DeviceInfo: Sendable, Equatable, Identifiable {
#if canImport(WatchKit) // os(watchOS)
return WKInterfaceDevice.current().systemName
#elseif canImport(UIKit) && !targetEnvironment(macCatalyst) // os(iOS) os(tvOS) os(visionOS)
return UIDevice.current.systemName
@MainActor
func _access() -> String { UIDevice.current.systemName }
func _assumeIsolated<T>(_ work: @MainActor () -> T) -> T {
if #available(iOS 13, tvOS 13, *) {
return MainActor.assumeIsolated(work)
} else {
return withoutActuallyEscaping(work) {
unsafeBitCast($0, to: (() -> T).self)()
}
}
}
if Thread.isMainThread {
return _assumeIsolated(_access)
} else {
return DispatchQueue.main.sync { _assumeIsolated(_access) }
}
#elseif os(macOS) || targetEnvironment(macCatalyst)
return "macOS"
#elseif os(Linux)
Expand Down

0 comments on commit 5a37c3f

Please sign in to comment.