Skip to content
Closed
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
8 changes: 6 additions & 2 deletions DeviceKit.xcodeproj/project.pbxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -389,10 +389,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 = "";
Expand DownExpand Up@@ -446,8 +448,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";
Expand Down
29 changes: 22 additions & 7 deletions Source/Device.generated.swift
Original file line numberDiff line numberDiff line change
Expand Up@@ -626,6 +626,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)
// To be completed when more information becomes available.
return unknown(identifier)
#endif
}

Expand DownExpand Up@@ -875,7 +878,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)
#endif
}
Expand DownExpand Up@@ -980,16 +983,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
Expand DownExpand Up@@ -1126,6 +1125,9 @@ public enum Device {
return allTVs
#elseif os(watchOS)
return allWatches
#elseif os(visionOS)
// To be completed when more information becomes available.
return []
#endif
}

Expand DownExpand Up@@ -1353,6 +1355,9 @@ public enum Device {
}
#elseif os(tvOS)
return nil
#elseif os(visionOS)
// To be completed when more information becomes available.
return nil
#endif
}

Expand All@@ -1371,7 +1376,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
Expand DownExpand Up@@ -1504,6 +1509,8 @@ extension Device: CustomStringConvertible {
case .simulator(let model): return "Simulator (\(model.description))"
case .unknown(let identifier): return identifier
}
#elseif os(visionOS)
return "Apple Vision Pro"
#endif
}

Expand DownExpand Up@@ -1632,6 +1639,8 @@ extension Device: CustomStringConvertible {
case .simulator(let model): return "Simulator (\(model.safeDescription))"
case .unknown(let identifier): return identifier
}
#elseif os(visionOS)
return "Apple Vision Pro"
#endif
}

Expand DownExpand Up@@ -1782,7 +1791,7 @@ extension Device.BatteryState: Comparable {
}
#endif

#if os(iOS) && !os(xrOS)
#if os(iOS)
extension Device {
// MARK: Orientation
/**
Expand DownExpand Up@@ -2266,6 +2275,9 @@ extension Device {
case .simulator(let model): return model.cpu
case .unknown: return .unknown
}
#elseif os(visionOS)
// To be completed when more information becomes available.
return .unknown
#endif
}
}
Expand DownExpand Up@@ -2315,6 +2327,9 @@ extension Device.CPU: CustomStringConvertible {
case .s9: return "S9"
case .unknown: return "unknown"
}
#elseif os(visionOS)
// To be completed when more information becomes available.
return "unknown"
#endif
}
}
29 changes: 22 additions & 7 deletions Source/Device.swift.gyb
Original file line numberDiff line numberDiff line change
Expand Up@@ -416,6 +416,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)
// To be completed when more information becomes available.
return unknown(identifier)
#endif
}

Expand DownExpand Up@@ -475,7 +478,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)
#endif
}
Expand DownExpand Up@@ -580,16 +583,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
Expand DownExpand Up@@ -726,6 +725,9 @@ public enum Device {
return allTVs
#elseif os(watchOS)
return allWatches
#elseif os(visionOS)
// To be completed when more information becomes available.
return []
#endif
}

Expand DownExpand Up@@ -858,6 +860,9 @@ public enum Device {
}
#elseif os(tvOS)
return nil
#elseif os(visionOS)
// To be completed when more information becomes available.
return nil
#endif
}

Expand All@@ -876,7 +881,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
Expand DownExpand Up@@ -913,6 +918,8 @@ extension Device: CustomStringConvertible {
case .simulator(let model): return "Simulator (\(model.description))"
case .unknown(let identifier): return identifier
}
#elseif os(visionOS)
return "Apple Vision Pro"
#endif
}

Expand DownExpand Up@@ -945,6 +952,8 @@ extension Device: CustomStringConvertible {
case .simulator(let model): return "Simulator (\(model.safeDescription))"
case .unknown(let identifier): return identifier
}
#elseif os(visionOS)
return "Apple Vision Pro"
#endif
}

Expand DownExpand Up@@ -1095,7 +1104,7 @@ extension Device.BatteryState: Comparable {
}
#endif

#if os(iOS) && !os(xrOS)
#if os(iOS)
extension Device {
// MARK: Orientation
/**
Expand DownExpand Up@@ -1433,6 +1442,9 @@ extension Device {
case .simulator(let model): return model.cpu
case .unknown: return .unknown
}
#elseif os(visionOS)
// To be completed when more information becomes available.
return .unknown
#endif
}
}
Expand All@@ -1455,6 +1467,9 @@ extension Device.CPU: CustomStringConvertible {
% end
case .unknown: return "unknown"
}
#elseif os(visionOS)
// To be completed when more information becomes available.
return "unknown"
#endif
}
}