mirror of
https://github.com/devicekit/DeviceKit.git
synced 2026-05-17 10:20:34 +00:00
Fix building for visionOS. (#390)
* Fix compile errors on visionOS. # Conflicts: # Source/Device.generated.swift # Source/Device.swift.gyb * Remove references to xrOS that are no longer applicable. * Add TODO comments in code about visionOS proper implementation. * Update changelog. --------- Co-authored-by: Chris Vasselli <clindsay@gmail.com>
This commit is contained in:
@@ -11,11 +11,13 @@ pod 'DeviceKit', '~> 5.2'
|
||||
### Bugfixes
|
||||
|
||||
- Fix building SwiftUI previews on macOS properly. ([#389](https://github.com/devicekit/DeviceKit/pull/389))
|
||||
- Fix building for visionOS. ([#390](https://github.com/devicekit/DeviceKit/pull/390))
|
||||
|
||||
### Contributors
|
||||
|
||||
Thanks to all the contributers of this release!
|
||||
- [honghaoz](https://github.com/honghaoz)
|
||||
- [chrisvasselli](https://github.com/chrisvasselli)
|
||||
|
||||
## Version 5.2.1
|
||||
|
||||
|
||||
@@ -391,10 +391,12 @@
|
||||
RUN_CLANG_STATIC_ANALYZER = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator watchos watchsimulator xros xrsimulator";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
|
||||
TVOS_DEPLOYMENT_TARGET = 11.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
@@ -448,8 +450,10 @@
|
||||
RUN_CLANG_STATIC_ANALYZER = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator watchos watchsimulator xros xrsimulator";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
|
||||
TVOS_DEPLOYMENT_TARGET = 11.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
|
||||
@@ -628,6 +628,9 @@ public enum Device {
|
||||
case "i386", "x86_64", "arm64": return simulator(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "watchOS"))
|
||||
default: return unknown(identifier)
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return unknown(identifier)
|
||||
#else
|
||||
return unknown(identifier)
|
||||
#endif
|
||||
@@ -879,7 +882,7 @@ public enum Device {
|
||||
case .simulator(let model): return model.screenRatio
|
||||
case .unknown: return (width: -1, height: -1)
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
#elseif os(tvOS) || os(visionOS)
|
||||
return (width: -1, height: -1)
|
||||
#else
|
||||
return (width: -1, height: -1)
|
||||
@@ -986,16 +989,12 @@ public enum Device {
|
||||
|
||||
public var isZoomed: Bool? {
|
||||
guard isCurrent else { return nil }
|
||||
#if os(xrOS)
|
||||
return nil
|
||||
#else
|
||||
if Int(UIScreen.main.scale.rounded()) == 3 {
|
||||
// Plus-sized
|
||||
return UIScreen.main.nativeScale > 2.7 && UIScreen.main.nativeScale < 3
|
||||
} else {
|
||||
return UIScreen.main.nativeScale > UIScreen.main.scale
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// All Touch ID Capable Devices
|
||||
@@ -1162,6 +1161,9 @@ public enum Device {
|
||||
return allTVs
|
||||
#elseif os(watchOS)
|
||||
return allWatches
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return []
|
||||
#else
|
||||
return []
|
||||
#endif
|
||||
@@ -1401,6 +1403,9 @@ public enum Device {
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
return nil
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return nil
|
||||
#else
|
||||
return nil
|
||||
#endif
|
||||
@@ -1421,7 +1426,7 @@ public enum Device {
|
||||
|
||||
/// The brightness level of the screen.
|
||||
public var screenBrightness: Int {
|
||||
#if os(iOS) && !os(xrOS)
|
||||
#if os(iOS)
|
||||
return Int(UIScreen.main.brightness * 100)
|
||||
#else
|
||||
return 100
|
||||
@@ -1554,6 +1559,9 @@ extension Device: CustomStringConvertible {
|
||||
case .simulator(let model): return "Simulator (\(model.description))"
|
||||
case .unknown(let identifier): return identifier
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return "Apple Vision Pro"
|
||||
#else
|
||||
switch self {
|
||||
case .simulator(let model): return "Simulator (\(model.description))"
|
||||
@@ -1687,6 +1695,9 @@ extension Device: CustomStringConvertible {
|
||||
case .simulator(let model): return "Simulator (\(model.safeDescription))"
|
||||
case .unknown(let identifier): return identifier
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return "Apple Vision Pro"
|
||||
#else
|
||||
switch self {
|
||||
case .simulator(let model): return "Simulator (\(model.safeDescription))"
|
||||
@@ -1842,7 +1853,7 @@ extension Device.BatteryState: Comparable {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && !os(xrOS)
|
||||
#if os(iOS)
|
||||
extension Device {
|
||||
// MARK: Orientation
|
||||
/**
|
||||
@@ -2326,6 +2337,9 @@ extension Device {
|
||||
case .simulator(let model): return model.cpu
|
||||
case .unknown: return .unknown
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return .unknown
|
||||
#else
|
||||
return .unknown
|
||||
#endif
|
||||
@@ -2377,6 +2391,9 @@ extension Device.CPU: CustomStringConvertible {
|
||||
case .s9: return "S9"
|
||||
case .unknown: return "unknown"
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return "unknown"
|
||||
#else
|
||||
return "unknown"
|
||||
#endif
|
||||
|
||||
+24
-7
@@ -421,6 +421,9 @@ public enum Device {
|
||||
case "i386", "x86_64", "arm64": return simulator(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "watchOS"))
|
||||
default: return unknown(identifier)
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return unknown(identifier)
|
||||
#else
|
||||
return unknown(identifier)
|
||||
#endif
|
||||
@@ -482,7 +485,7 @@ public enum Device {
|
||||
case .simulator(let model): return model.screenRatio
|
||||
case .unknown: return (width: -1, height: -1)
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
#elseif os(tvOS) || os(visionOS)
|
||||
return (width: -1, height: -1)
|
||||
#else
|
||||
return (width: -1, height: -1)
|
||||
@@ -589,16 +592,12 @@ public enum Device {
|
||||
|
||||
public var isZoomed: Bool? {
|
||||
guard isCurrent else { return nil }
|
||||
#if os(xrOS)
|
||||
return nil
|
||||
#else
|
||||
if Int(UIScreen.main.scale.rounded()) == 3 {
|
||||
// Plus-sized
|
||||
return UIScreen.main.nativeScale > 2.7 && UIScreen.main.nativeScale < 3
|
||||
} else {
|
||||
return UIScreen.main.nativeScale > UIScreen.main.scale
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// All Touch ID Capable Devices
|
||||
@@ -765,6 +764,9 @@ public enum Device {
|
||||
return allTVs
|
||||
#elseif os(watchOS)
|
||||
return allWatches
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return []
|
||||
#else
|
||||
return []
|
||||
#endif
|
||||
@@ -909,6 +911,9 @@ public enum Device {
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
return nil
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return nil
|
||||
#else
|
||||
return nil
|
||||
#endif
|
||||
@@ -929,7 +934,7 @@ public enum Device {
|
||||
|
||||
/// The brightness level of the screen.
|
||||
public var screenBrightness: Int {
|
||||
#if os(iOS) && !os(xrOS)
|
||||
#if os(iOS)
|
||||
return Int(UIScreen.main.brightness * 100)
|
||||
#else
|
||||
return 100
|
||||
@@ -966,6 +971,9 @@ extension Device: CustomStringConvertible {
|
||||
case .simulator(let model): return "Simulator (\(model.description))"
|
||||
case .unknown(let identifier): return identifier
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return "Apple Vision Pro"
|
||||
#else
|
||||
switch self {
|
||||
case .simulator(let model): return "Simulator (\(model.description))"
|
||||
@@ -1003,6 +1011,9 @@ extension Device: CustomStringConvertible {
|
||||
case .simulator(let model): return "Simulator (\(model.safeDescription))"
|
||||
case .unknown(let identifier): return identifier
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return "Apple Vision Pro"
|
||||
#else
|
||||
switch self {
|
||||
case .simulator(let model): return "Simulator (\(model.safeDescription))"
|
||||
@@ -1158,7 +1169,7 @@ extension Device.BatteryState: Comparable {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && !os(xrOS)
|
||||
#if os(iOS)
|
||||
extension Device {
|
||||
// MARK: Orientation
|
||||
/**
|
||||
@@ -1496,6 +1507,9 @@ extension Device {
|
||||
case .simulator(let model): return model.cpu
|
||||
case .unknown: return .unknown
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return .unknown
|
||||
#else
|
||||
return .unknown
|
||||
#endif
|
||||
@@ -1520,6 +1534,9 @@ extension Device.CPU: CustomStringConvertible {
|
||||
% end
|
||||
case .unknown: return "unknown"
|
||||
}
|
||||
#elseif os(visionOS)
|
||||
// TODO: Replace with proper implementation for visionOS.
|
||||
return "unknown"
|
||||
#else
|
||||
return "unknown"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user