diff --git a/CHANGELOG.md b/CHANGELOG.md index 09804786..8c511e1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### New features + +- Add `allDevicesWithVariableAperture` and `hasVariableAperture` for iPhone 18 Pro and iPhone 18 Pro Max. The instance property also supports their simulators. ([#516](https://github.com/devicekit/DeviceKit/issues/516)) + ## Version 5.10.0 Releasedate: 2026-11-01 diff --git a/Source/Device.generated.swift b/Source/Device.generated.swift index b10138c7..32194fce 100644 --- a/Source/Device.generated.swift +++ b/Source/Device.generated.swift @@ -2489,6 +2489,17 @@ extension Device { return [.iPhone11, .iPhone11Pro, .iPhone11ProMax, .iPhone12, .iPhone12Mini, .iPhone12Pro, .iPhone12ProMax, .iPhone13, .iPhone13Mini, .iPhone13Pro, .iPhone13ProMax, .iPhone14, .iPhone14Plus, .iPhone14Pro, .iPhone14ProMax, .iPhone15, .iPhone15Plus, .iPhone15Pro, .iPhone15ProMax, .iPhone16, .iPhone16Plus, .iPhone16Pro, .iPhone16ProMax, .iPhone17, .iPhone17Pro, .iPhone17ProMax, .iPhone18Pro, .iPhone18ProMax, .iPhoneDuo, .iPadPro11Inch2, .iPadPro12Inch4, .iPadPro11Inch3, .iPadPro12Inch5, .iPadPro11Inch4, .iPadPro12Inch6] } + /// All device models that feature a camera with a variable aperture, excluding simulators. + public static var allDevicesWithVariableAperture: [Device] { + return [.iPhone18Pro, .iPhone18ProMax] + } + + /// Returns whether the device model has a camera with a variable aperture. + /// Simulators use their simulated model's capability. + public var hasVariableAperture: Bool { + return isOneOf(Device.allDevicesWithVariableAperture) || isOneOf(Device.allDevicesWithVariableAperture.map(Device.simulator)) + } + /// Returns whether or not the current device has a camera public var hasCamera: Bool { return !self.cameras.isEmpty diff --git a/Source/Device.swift.gyb b/Source/Device.swift.gyb index af7f2821..524bb861 100644 --- a/Source/Device.swift.gyb +++ b/Source/Device.swift.gyb @@ -27,6 +27,7 @@ class Device: applePencilSupport=0, hasForce3dTouchSupport=False, cameras=0, + hasVariableAperture=False, hasLidarSensor=False, hasUSBCConnectivity=False, has5gSupport=False, @@ -56,6 +57,7 @@ class Device: self.applePencilSupport = applePencilSupport self.hasForce3dTouchSupport = hasForce3dTouchSupport self.cameras = cameras + self.hasVariableAperture = hasVariableAperture self.hasLidarSensor = hasLidarSensor self.cpu = cpu self.hasUSBCConnectivity = hasUSBCConnectivity @@ -277,11 +279,13 @@ iPhones = [ # iPhone19,3 and iPhone19,7 are regional variants of iPhone 18 Pro Max. Device("iPhone18Pro", "Device is an [iPhone 18 Pro](https://support.apple.com/en-us/148590)", "", ["iPhone19,2"], 6.3, (9, 19.5), "iPhone 18 Pro", "iPhone 18 Pro", 460, cpu="a20Pro", isPro=True, isXSeries=True, hasFaceID=True, + hasVariableAperture=True, hasSensorHousing=True, supportsWirelessCharging=True, hasRoundedDisplayCorners=True, hasDynamicIsland=True, cameras=123, hasLidarSensor=True, hasUSBCConnectivity=True, has5gSupport=True, hasEsimSupport=True, hasDualEsimSupport=True), Device("iPhone18ProMax", "Device is an [iPhone 18 Pro Max](https://support.apple.com/en-us/148591)", "", ["iPhone19,3", "iPhone19,7"], 6.9, (9, 19.5), "iPhone 18 Pro Max", "iPhone 18 Pro Max", 460, cpu="a20Pro", isPlusFormFactor=True, isPro=True, isXSeries=True, + hasVariableAperture=True, hasFaceID=True, hasSensorHousing=True, supportsWirelessCharging=True, hasRoundedDisplayCorners=True, hasDynamicIsland=True, cameras=123, hasLidarSensor=True, hasUSBCConnectivity=True, has5gSupport=True, @@ -1844,6 +1848,17 @@ extension Device { return [${', '.join(list(map(lambda device: "." + device.caseName, list(filter(lambda device: device.cameras == 3 or device.cameras == 13 or device.cameras == 123, iOSDevices)))))}] } + /// All device models that feature a camera with a variable aperture, excluding simulators. + public static var allDevicesWithVariableAperture: [Device] { + return [${', '.join(list(map(lambda device: "." + device.caseName, list(filter(lambda device: device.hasVariableAperture == True, iOSDevices)))))}] + } + + /// Returns whether the device model has a camera with a variable aperture. + /// Simulators use their simulated model's capability. + public var hasVariableAperture: Bool { + return isOneOf(Device.allDevicesWithVariableAperture) || isOneOf(Device.allDevicesWithVariableAperture.map(Device.simulator)) + } + /// Returns whether or not the current device has a camera public var hasCamera: Bool { return !self.cameras.isEmpty diff --git a/Tests/Tests.swift b/Tests/Tests.swift index 2809633a..cd834d14 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -865,6 +865,20 @@ class DeviceKitTests: XCTestCase { } } + func testVariableAperture() { + let expectedDevices: [Device] = [.iPhone18Pro, .iPhone18ProMax] + XCTAssertEqual(Device.allDevicesWithVariableAperture, expectedDevices) + + for model in Device.allRealDevices { + let expected = expectedDevices.contains(model) + XCTAssertEqual(model.hasVariableAperture, expected, model.description) + XCTAssertEqual(Device.simulator(model).hasVariableAperture, expected, model.description) + } + + XCTAssertFalse(Device.unknown("unrecognized").hasVariableAperture) + XCTAssertFalse(Device.simulator(.unknown("unrecognized")).hasVariableAperture) + } + func testLidarValues() { let lidarDevices: [Device] = [ .iPhone12Pro,