From 6c5a0869d3bc82cdf0fa665ace5a8c7fb563783a Mon Sep 17 00:00:00 2001 From: Marc N Date: Wed, 27 Sep 2023 16:53:31 +0300 Subject: [PATCH 01/10] builtInTripleCamera as default for capture --- Sources/CameraManager.swift | 352 ++++++++++++++++++++++++++++++- Sources/DeviceVersionModel.swift | 347 ++++++++++++++++++++++++++++++ 2 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 Sources/DeviceVersionModel.swift diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index a568cea..78842c5 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -348,7 +348,18 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest }() fileprivate lazy var backCameraDevice: AVCaptureDevice? = { - AVCaptureDevice.videoDevices.filter { $0.position == .back }.first + + let devices = AVCaptureDevice.videoDevices.filter { $0.position == .back } + if #available(iOS 13.0, *) { + if UIDevice().type == .iPhone15ProMax || UIDevice().type == .iPhone15Pro { + return devices.first { d in + d.deviceType == .builtInTripleCamera + } + } + } + + return devices.first + }() fileprivate lazy var mic: AVCaptureDevice? = { @@ -2137,3 +2148,342 @@ extension CameraManager: AVCaptureMetadataOutputObjectsDelegate { handler(.success(stringValue)) } } + +public enum DeviceVersionModel : String { + +//Simulator +case simulator = "simulator/sandbox", + +//iPod +iPod1 = "iPod 1", +iPod2 = "iPod 2", +iPod3 = "iPod 3", +iPod4 = "iPod 4", +iPod5 = "iPod 5", +iPod6 = "iPod 6", +iPod7 = "iPod 7", + +//iPad +iPad2 = "iPad 2", +iPad3 = "iPad 3", +iPad4 = "iPad 4", +iPadAir = "iPad Air ", +iPadAir2 = "iPad Air 2", +iPadAir3 = "iPad Air 3", +iPadAir4 = "iPad Air 4", +iPadAir5 = "iPad Air 5", +iPad5 = "iPad 5", //iPad 2017 +iPad6 = "iPad 6", //iPad 2018 +iPad7 = "iPad 7", //iPad 2019 +iPad8 = "iPad 8", //iPad 2020 +iPad9 = "iPad 9", //iPad 2021 +iPad10 = "iPad 10", //iPad 2022 + +//iPad Mini +iPadMini = "iPad Mini", +iPadMini2 = "iPad Mini 2", +iPadMini3 = "iPad Mini 3", +iPadMini4 = "iPad Mini 4", +iPadMini5 = "iPad Mini 5", +iPadMini6 = "iPad Mini 6", + +//iPad Pro +iPadPro9_7 = "iPad Pro 9.7\"", +iPadPro10_5 = "iPad Pro 10.5\"", +iPadPro11 = "iPad Pro 11\"", +iPadPro2_11 = "iPad Pro 11\" 2nd gen", +iPadPro3_11 = "iPad Pro 11\" 3rd gen", +iPadPro12_9 = "iPad Pro 12.9\"", +iPadPro2_12_9 = "iPad Pro 2 12.9\"", +iPadPro3_12_9 = "iPad Pro 3 12.9\"", +iPadPro4_12_9 = "iPad Pro 4 12.9\"", +iPadPro5_12_9 = "iPad Pro 5 12.9\"", + +//iPhone +iPhone4 = "iPhone 4", +iPhone4S = "iPhone 4S", +iPhone5 = "iPhone 5", +iPhone5S = "iPhone 5S", +iPhone5C = "iPhone 5C", +iPhone6 = "iPhone 6", +iPhone6Plus = "iPhone 6 Plus", +iPhone6S = "iPhone 6S", +iPhone6SPlus = "iPhone 6S Plus", +iPhoneSE = "iPhone SE", +iPhone7 = "iPhone 7", +iPhone7Plus = "iPhone 7 Plus", +iPhone8 = "iPhone 8", +iPhone8Plus = "iPhone 8 Plus", +iPhoneX = "iPhone X", +iPhoneXS = "iPhone XS", +iPhoneXSMax = "iPhone XS Max", +iPhoneXR = "iPhone XR", +iPhone11 = "iPhone 11", +iPhone11Pro = "iPhone 11 Pro", +iPhone11ProMax = "iPhone 11 Pro Max", +iPhoneSE2 = "iPhone SE 2nd gen", +iPhone12Mini = "iPhone 12 Mini", +iPhone12 = "iPhone 12", +iPhone12Pro = "iPhone 12 Pro", +iPhone12ProMax = "iPhone 12 Pro Max", +iPhone13Mini = "iPhone 13 Mini", +iPhone13 = "iPhone 13", +iPhone13Pro = "iPhone 13 Pro", +iPhone13ProMax = "iPhone 13 Pro Max", +iPhoneSE3 = "iPhone SE 3nd gen", +iPhone14 = "iPhone 14", +iPhone14Plus = "iPhone 14 Plus", +iPhone14Pro = "iPhone 14 Pro", +iPhone14ProMax = "iPhone 14 Pro Max", +iPhone15 = "iPhone 15", +iPhone15Plus = "iPhone 15 Plus", +iPhone15Pro = "iPhone 15 Pro", +iPhone15ProMax = "iPhone 15 Pro Max", + +// Apple Watch +AppleWatch1 = "Apple Watch 1gen", +AppleWatchS1 = "Apple Watch Series 1", +AppleWatchS2 = "Apple Watch Series 2", +AppleWatchS3 = "Apple Watch Series 3", +AppleWatchS4 = "Apple Watch Series 4", +AppleWatchS5 = "Apple Watch Series 5", +AppleWatchSE = "Apple Watch Special Edition", +AppleWatchS6 = "Apple Watch Series 6", +AppleWatchS7 = "Apple Watch Series 7", + +//Apple TV +AppleTV1 = "Apple TV 1gen", +AppleTV2 = "Apple TV 2gen", +AppleTV3 = "Apple TV 3gen", +AppleTV4 = "Apple TV 4gen", +AppleTV_4K = "Apple TV 4K", +AppleTV2_4K = "Apple TV 4K 2gen", + +unrecognized = "?unrecognized?" +} + +// #-#-#-#-#-#-#-#-#-#-#-#-# +// MARK: UIDevice extensions +// #-#-#-#-#-#-#-#-#-#-#-#-# + + public extension UIDevice { + + var type: DeviceVersionModel { + var systemInfo = utsname() + uname(&systemInfo) + let modelCode = withUnsafePointer(to: &systemInfo.machine) { + $0.withMemoryRebound(to: CChar.self, capacity: 1) { + ptr in String.init(validatingUTF8: ptr) + } + } + + let modelMap : [String: DeviceVersionModel] = [ + + //Simulator + "i386" : .simulator, + "x86_64" : .simulator, + + //iPod + "iPod1,1" : .iPod1, + "iPod2,1" : .iPod2, + "iPod3,1" : .iPod3, + "iPod4,1" : .iPod4, + "iPod5,1" : .iPod5, + "iPod7,1" : .iPod6, + "iPod9,1" : .iPod7, + + //iPad + "iPad2,1" : .iPad2, + "iPad2,2" : .iPad2, + "iPad2,3" : .iPad2, + "iPad2,4" : .iPad2, + "iPad3,1" : .iPad3, + "iPad3,2" : .iPad3, + "iPad3,3" : .iPad3, + "iPad3,4" : .iPad4, + "iPad3,5" : .iPad4, + "iPad3,6" : .iPad4, + "iPad6,11" : .iPad5, //iPad 2017 + "iPad6,12" : .iPad5, + "iPad7,5" : .iPad6, //iPad 2018 + "iPad7,6" : .iPad6, + "iPad7,11" : .iPad7, //iPad 2019 + "iPad7,12" : .iPad7, + "iPad11,6" : .iPad8, //iPad 2020 + "iPad11,7" : .iPad8, + "iPad12,1" : .iPad9, //iPad 2021 + "iPad12,2" : .iPad9, + "iPad13,18" : .iPad10, + "iPad13,19" : .iPad10, + + //iPad Mini + "iPad2,5" : .iPadMini, + "iPad2,6" : .iPadMini, + "iPad2,7" : .iPadMini, + "iPad4,4" : .iPadMini2, + "iPad4,5" : .iPadMini2, + "iPad4,6" : .iPadMini2, + "iPad4,7" : .iPadMini3, + "iPad4,8" : .iPadMini3, + "iPad4,9" : .iPadMini3, + "iPad5,1" : .iPadMini4, + "iPad5,2" : .iPadMini4, + "iPad11,1" : .iPadMini5, + "iPad11,2" : .iPadMini5, + "iPad14,1" : .iPadMini6, + "iPad14,2" : .iPadMini6, + + //iPad Pro + "iPad6,3" : .iPadPro9_7, + "iPad6,4" : .iPadPro9_7, + "iPad7,3" : .iPadPro10_5, + "iPad7,4" : .iPadPro10_5, + "iPad6,7" : .iPadPro12_9, + "iPad6,8" : .iPadPro12_9, + "iPad7,1" : .iPadPro2_12_9, + "iPad7,2" : .iPadPro2_12_9, + "iPad8,1" : .iPadPro11, + "iPad8,2" : .iPadPro11, + "iPad8,3" : .iPadPro11, + "iPad8,4" : .iPadPro11, + "iPad8,9" : .iPadPro2_11, + "iPad8,10" : .iPadPro2_11, + "iPad13,4" : .iPadPro3_11, + "iPad13,5" : .iPadPro3_11, + "iPad13,6" : .iPadPro3_11, + "iPad13,7" : .iPadPro3_11, + "iPad8,5" : .iPadPro3_12_9, + "iPad8,6" : .iPadPro3_12_9, + "iPad8,7" : .iPadPro3_12_9, + "iPad8,8" : .iPadPro3_12_9, + "iPad8,11" : .iPadPro4_12_9, + "iPad8,12" : .iPadPro4_12_9, + "iPad13,8" : .iPadPro5_12_9, + "iPad13,9" : .iPadPro5_12_9, + "iPad13,10" : .iPadPro5_12_9, + "iPad13,11" : .iPadPro5_12_9, + + //iPad Air + "iPad4,1" : .iPadAir, + "iPad4,2" : .iPadAir, + "iPad4,3" : .iPadAir, + "iPad5,3" : .iPadAir2, + "iPad5,4" : .iPadAir2, + "iPad11,3" : .iPadAir3, + "iPad11,4" : .iPadAir3, + "iPad13,1" : .iPadAir4, + "iPad13,2" : .iPadAir4, + "iPad13,16" : .iPadAir5, + "iPad13,17" : .iPadAir5, + + //iPhone + "iPhone3,1" : .iPhone4, + "iPhone3,2" : .iPhone4, + "iPhone3,3" : .iPhone4, + "iPhone4,1" : .iPhone4S, + "iPhone5,1" : .iPhone5, + "iPhone5,2" : .iPhone5, + "iPhone5,3" : .iPhone5C, + "iPhone5,4" : .iPhone5C, + "iPhone6,1" : .iPhone5S, + "iPhone6,2" : .iPhone5S, + "iPhone7,1" : .iPhone6Plus, + "iPhone7,2" : .iPhone6, + "iPhone8,1" : .iPhone6S, + "iPhone8,2" : .iPhone6SPlus, + "iPhone8,4" : .iPhoneSE, + "iPhone9,1" : .iPhone7, + "iPhone9,3" : .iPhone7, + "iPhone9,2" : .iPhone7Plus, + "iPhone9,4" : .iPhone7Plus, + "iPhone10,1" : .iPhone8, + "iPhone10,4" : .iPhone8, + "iPhone10,2" : .iPhone8Plus, + "iPhone10,5" : .iPhone8Plus, + "iPhone10,3" : .iPhoneX, + "iPhone10,6" : .iPhoneX, + "iPhone11,2" : .iPhoneXS, + "iPhone11,4" : .iPhoneXSMax, + "iPhone11,6" : .iPhoneXSMax, + "iPhone11,8" : .iPhoneXR, + "iPhone12,1" : .iPhone11, + "iPhone12,3" : .iPhone11Pro, + "iPhone12,5" : .iPhone11ProMax, + "iPhone12,8" : .iPhoneSE2, + "iPhone13,1" : .iPhone12Mini, + "iPhone13,2" : .iPhone12, + "iPhone13,3" : .iPhone12Pro, + "iPhone13,4" : .iPhone12ProMax, + "iPhone14,4" : .iPhone13Mini, + "iPhone14,5" : .iPhone13, + "iPhone14,2" : .iPhone13Pro, + "iPhone14,3" : .iPhone13ProMax, + "iPhone14,6" : .iPhoneSE3, + "iPhone14,7" : .iPhone14, + "iPhone14,8" : .iPhone14Plus, + "iPhone15,2" : .iPhone14Pro, + "iPhone15,3" : .iPhone14ProMax, + "iPhone15,4" : .iPhone15, + "iPhone15,5" : .iPhone15Plus, + "iPhone16,1" : .iPhone15Pro, + "iPhone16,2" : .iPhone15ProMax, + + // Apple Watch + "Watch1,1" : .AppleWatch1, + "Watch1,2" : .AppleWatch1, + "Watch2,6" : .AppleWatchS1, + "Watch2,7" : .AppleWatchS1, + "Watch2,3" : .AppleWatchS2, + "Watch2,4" : .AppleWatchS2, + "Watch3,1" : .AppleWatchS3, + "Watch3,2" : .AppleWatchS3, + "Watch3,3" : .AppleWatchS3, + "Watch3,4" : .AppleWatchS3, + "Watch4,1" : .AppleWatchS4, + "Watch4,2" : .AppleWatchS4, + "Watch4,3" : .AppleWatchS4, + "Watch4,4" : .AppleWatchS4, + "Watch5,1" : .AppleWatchS5, + "Watch5,2" : .AppleWatchS5, + "Watch5,3" : .AppleWatchS5, + "Watch5,4" : .AppleWatchS5, + "Watch5,9" : .AppleWatchSE, + "Watch5,10" : .AppleWatchSE, + "Watch5,11" : .AppleWatchSE, + "Watch5,12" : .AppleWatchSE, + "Watch6,1" : .AppleWatchS6, + "Watch6,2" : .AppleWatchS6, + "Watch6,3" : .AppleWatchS6, + "Watch6,4" : .AppleWatchS6, + "Watch6,6" : .AppleWatchS7, + "Watch6,7" : .AppleWatchS7, + "Watch6,8" : .AppleWatchS7, + "Watch6,9" : .AppleWatchS7, + + //Apple TV + "AppleTV1,1" : .AppleTV1, + "AppleTV2,1" : .AppleTV2, + "AppleTV3,1" : .AppleTV3, + "AppleTV3,2" : .AppleTV3, + "AppleTV5,3" : .AppleTV4, + "AppleTV6,2" : .AppleTV_4K, + "AppleTV11,1" : .AppleTV2_4K + ] + + guard let mcode = modelCode, let map = String(validatingUTF8: mcode), let model = modelMap[map] else { + return DeviceVersionModel.unrecognized + } + + if model == .simulator { + if let simModelCode = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { + if let simMap = String(validatingUTF8: simModelCode), let simModel = modelMap[simMap] { + return simModel + } + } + } + + return model + + } + +} diff --git a/Sources/DeviceVersionModel.swift b/Sources/DeviceVersionModel.swift new file mode 100644 index 0000000..cfb6d91 --- /dev/null +++ b/Sources/DeviceVersionModel.swift @@ -0,0 +1,347 @@ +//// +//// DeviceType.swift +//// +//// +//// Created by Marc Nicolae Popa on 9/27/23. +//// +// +//import UIKit +// +//public enum DeviceVersionModel : String { +// +////Simulator +//case simulator = "simulator/sandbox", +// +////iPod +//iPod1 = "iPod 1", +//iPod2 = "iPod 2", +//iPod3 = "iPod 3", +//iPod4 = "iPod 4", +//iPod5 = "iPod 5", +//iPod6 = "iPod 6", +//iPod7 = "iPod 7", +// +////iPad +//iPad2 = "iPad 2", +//iPad3 = "iPad 3", +//iPad4 = "iPad 4", +//iPadAir = "iPad Air ", +//iPadAir2 = "iPad Air 2", +//iPadAir3 = "iPad Air 3", +//iPadAir4 = "iPad Air 4", +//iPadAir5 = "iPad Air 5", +//iPad5 = "iPad 5", //iPad 2017 +//iPad6 = "iPad 6", //iPad 2018 +//iPad7 = "iPad 7", //iPad 2019 +//iPad8 = "iPad 8", //iPad 2020 +//iPad9 = "iPad 9", //iPad 2021 +//iPad10 = "iPad 10", //iPad 2022 +// +////iPad Mini +//iPadMini = "iPad Mini", +//iPadMini2 = "iPad Mini 2", +//iPadMini3 = "iPad Mini 3", +//iPadMini4 = "iPad Mini 4", +//iPadMini5 = "iPad Mini 5", +//iPadMini6 = "iPad Mini 6", +// +////iPad Pro +//iPadPro9_7 = "iPad Pro 9.7\"", +//iPadPro10_5 = "iPad Pro 10.5\"", +//iPadPro11 = "iPad Pro 11\"", +//iPadPro2_11 = "iPad Pro 11\" 2nd gen", +//iPadPro3_11 = "iPad Pro 11\" 3rd gen", +//iPadPro12_9 = "iPad Pro 12.9\"", +//iPadPro2_12_9 = "iPad Pro 2 12.9\"", +//iPadPro3_12_9 = "iPad Pro 3 12.9\"", +//iPadPro4_12_9 = "iPad Pro 4 12.9\"", +//iPadPro5_12_9 = "iPad Pro 5 12.9\"", +// +////iPhone +//iPhone4 = "iPhone 4", +//iPhone4S = "iPhone 4S", +//iPhone5 = "iPhone 5", +//iPhone5S = "iPhone 5S", +//iPhone5C = "iPhone 5C", +//iPhone6 = "iPhone 6", +//iPhone6Plus = "iPhone 6 Plus", +//iPhone6S = "iPhone 6S", +//iPhone6SPlus = "iPhone 6S Plus", +//iPhoneSE = "iPhone SE", +//iPhone7 = "iPhone 7", +//iPhone7Plus = "iPhone 7 Plus", +//iPhone8 = "iPhone 8", +//iPhone8Plus = "iPhone 8 Plus", +//iPhoneX = "iPhone X", +//iPhoneXS = "iPhone XS", +//iPhoneXSMax = "iPhone XS Max", +//iPhoneXR = "iPhone XR", +//iPhone11 = "iPhone 11", +//iPhone11Pro = "iPhone 11 Pro", +//iPhone11ProMax = "iPhone 11 Pro Max", +//iPhoneSE2 = "iPhone SE 2nd gen", +//iPhone12Mini = "iPhone 12 Mini", +//iPhone12 = "iPhone 12", +//iPhone12Pro = "iPhone 12 Pro", +//iPhone12ProMax = "iPhone 12 Pro Max", +//iPhone13Mini = "iPhone 13 Mini", +//iPhone13 = "iPhone 13", +//iPhone13Pro = "iPhone 13 Pro", +//iPhone13ProMax = "iPhone 13 Pro Max", +//iPhoneSE3 = "iPhone SE 3nd gen", +//iPhone14 = "iPhone 14", +//iPhone14Plus = "iPhone 14 Plus", +//iPhone14Pro = "iPhone 14 Pro", +//iPhone14ProMax = "iPhone 14 Pro Max", +//iPhone15 = "iPhone 15", +//iPhone15Plus = "iPhone 15 Plus", +//iPhone15Pro = "iPhone 15 Pro", +//iPhone15ProMax = "iPhone 15 Pro Max", +// +//// Apple Watch +//AppleWatch1 = "Apple Watch 1gen", +//AppleWatchS1 = "Apple Watch Series 1", +//AppleWatchS2 = "Apple Watch Series 2", +//AppleWatchS3 = "Apple Watch Series 3", +//AppleWatchS4 = "Apple Watch Series 4", +//AppleWatchS5 = "Apple Watch Series 5", +//AppleWatchSE = "Apple Watch Special Edition", +//AppleWatchS6 = "Apple Watch Series 6", +//AppleWatchS7 = "Apple Watch Series 7", +// +////Apple TV +//AppleTV1 = "Apple TV 1gen", +//AppleTV2 = "Apple TV 2gen", +//AppleTV3 = "Apple TV 3gen", +//AppleTV4 = "Apple TV 4gen", +//AppleTV_4K = "Apple TV 4K", +//AppleTV2_4K = "Apple TV 4K 2gen", +// +//unrecognized = "?unrecognized?" +//} +// +//// #-#-#-#-#-#-#-#-#-#-#-#-# +//// MARK: UIDevice extensions +//// #-#-#-#-#-#-#-#-#-#-#-#-# +// +// public extension UIDevice { +// +// var type: DeviceVersionModel { +// var systemInfo = utsname() +// uname(&systemInfo) +// let modelCode = withUnsafePointer(to: &systemInfo.machine) { +// $0.withMemoryRebound(to: CChar.self, capacity: 1) { +// ptr in String.init(validatingUTF8: ptr) +// } +// } +// +// let modelMap : [String: DeviceVersionModel] = [ +// +// //Simulator +// "i386" : .simulator, +// "x86_64" : .simulator, +// +// //iPod +// "iPod1,1" : .iPod1, +// "iPod2,1" : .iPod2, +// "iPod3,1" : .iPod3, +// "iPod4,1" : .iPod4, +// "iPod5,1" : .iPod5, +// "iPod7,1" : .iPod6, +// "iPod9,1" : .iPod7, +// +// //iPad +// "iPad2,1" : .iPad2, +// "iPad2,2" : .iPad2, +// "iPad2,3" : .iPad2, +// "iPad2,4" : .iPad2, +// "iPad3,1" : .iPad3, +// "iPad3,2" : .iPad3, +// "iPad3,3" : .iPad3, +// "iPad3,4" : .iPad4, +// "iPad3,5" : .iPad4, +// "iPad3,6" : .iPad4, +// "iPad6,11" : .iPad5, //iPad 2017 +// "iPad6,12" : .iPad5, +// "iPad7,5" : .iPad6, //iPad 2018 +// "iPad7,6" : .iPad6, +// "iPad7,11" : .iPad7, //iPad 2019 +// "iPad7,12" : .iPad7, +// "iPad11,6" : .iPad8, //iPad 2020 +// "iPad11,7" : .iPad8, +// "iPad12,1" : .iPad9, //iPad 2021 +// "iPad12,2" : .iPad9, +// "iPad13,18" : .iPad10, +// "iPad13,19" : .iPad10, +// +// //iPad Mini +// "iPad2,5" : .iPadMini, +// "iPad2,6" : .iPadMini, +// "iPad2,7" : .iPadMini, +// "iPad4,4" : .iPadMini2, +// "iPad4,5" : .iPadMini2, +// "iPad4,6" : .iPadMini2, +// "iPad4,7" : .iPadMini3, +// "iPad4,8" : .iPadMini3, +// "iPad4,9" : .iPadMini3, +// "iPad5,1" : .iPadMini4, +// "iPad5,2" : .iPadMini4, +// "iPad11,1" : .iPadMini5, +// "iPad11,2" : .iPadMini5, +// "iPad14,1" : .iPadMini6, +// "iPad14,2" : .iPadMini6, +// +// //iPad Pro +// "iPad6,3" : .iPadPro9_7, +// "iPad6,4" : .iPadPro9_7, +// "iPad7,3" : .iPadPro10_5, +// "iPad7,4" : .iPadPro10_5, +// "iPad6,7" : .iPadPro12_9, +// "iPad6,8" : .iPadPro12_9, +// "iPad7,1" : .iPadPro2_12_9, +// "iPad7,2" : .iPadPro2_12_9, +// "iPad8,1" : .iPadPro11, +// "iPad8,2" : .iPadPro11, +// "iPad8,3" : .iPadPro11, +// "iPad8,4" : .iPadPro11, +// "iPad8,9" : .iPadPro2_11, +// "iPad8,10" : .iPadPro2_11, +// "iPad13,4" : .iPadPro3_11, +// "iPad13,5" : .iPadPro3_11, +// "iPad13,6" : .iPadPro3_11, +// "iPad13,7" : .iPadPro3_11, +// "iPad8,5" : .iPadPro3_12_9, +// "iPad8,6" : .iPadPro3_12_9, +// "iPad8,7" : .iPadPro3_12_9, +// "iPad8,8" : .iPadPro3_12_9, +// "iPad8,11" : .iPadPro4_12_9, +// "iPad8,12" : .iPadPro4_12_9, +// "iPad13,8" : .iPadPro5_12_9, +// "iPad13,9" : .iPadPro5_12_9, +// "iPad13,10" : .iPadPro5_12_9, +// "iPad13,11" : .iPadPro5_12_9, +// +// //iPad Air +// "iPad4,1" : .iPadAir, +// "iPad4,2" : .iPadAir, +// "iPad4,3" : .iPadAir, +// "iPad5,3" : .iPadAir2, +// "iPad5,4" : .iPadAir2, +// "iPad11,3" : .iPadAir3, +// "iPad11,4" : .iPadAir3, +// "iPad13,1" : .iPadAir4, +// "iPad13,2" : .iPadAir4, +// "iPad13,16" : .iPadAir5, +// "iPad13,17" : .iPadAir5, +// +// //iPhone +// "iPhone3,1" : .iPhone4, +// "iPhone3,2" : .iPhone4, +// "iPhone3,3" : .iPhone4, +// "iPhone4,1" : .iPhone4S, +// "iPhone5,1" : .iPhone5, +// "iPhone5,2" : .iPhone5, +// "iPhone5,3" : .iPhone5C, +// "iPhone5,4" : .iPhone5C, +// "iPhone6,1" : .iPhone5S, +// "iPhone6,2" : .iPhone5S, +// "iPhone7,1" : .iPhone6Plus, +// "iPhone7,2" : .iPhone6, +// "iPhone8,1" : .iPhone6S, +// "iPhone8,2" : .iPhone6SPlus, +// "iPhone8,4" : .iPhoneSE, +// "iPhone9,1" : .iPhone7, +// "iPhone9,3" : .iPhone7, +// "iPhone9,2" : .iPhone7Plus, +// "iPhone9,4" : .iPhone7Plus, +// "iPhone10,1" : .iPhone8, +// "iPhone10,4" : .iPhone8, +// "iPhone10,2" : .iPhone8Plus, +// "iPhone10,5" : .iPhone8Plus, +// "iPhone10,3" : .iPhoneX, +// "iPhone10,6" : .iPhoneX, +// "iPhone11,2" : .iPhoneXS, +// "iPhone11,4" : .iPhoneXSMax, +// "iPhone11,6" : .iPhoneXSMax, +// "iPhone11,8" : .iPhoneXR, +// "iPhone12,1" : .iPhone11, +// "iPhone12,3" : .iPhone11Pro, +// "iPhone12,5" : .iPhone11ProMax, +// "iPhone12,8" : .iPhoneSE2, +// "iPhone13,1" : .iPhone12Mini, +// "iPhone13,2" : .iPhone12, +// "iPhone13,3" : .iPhone12Pro, +// "iPhone13,4" : .iPhone12ProMax, +// "iPhone14,4" : .iPhone13Mini, +// "iPhone14,5" : .iPhone13, +// "iPhone14,2" : .iPhone13Pro, +// "iPhone14,3" : .iPhone13ProMax, +// "iPhone14,6" : .iPhoneSE3, +// "iPhone14,7" : .iPhone14, +// "iPhone14,8" : .iPhone14Plus, +// "iPhone15,2" : .iPhone14Pro, +// "iPhone15,3" : .iPhone14ProMax, +// "iPhone15,4" : .iPhone15, +// "iPhone15,5" : .iPhone15Plus, +// "iPhone16,1" : .iPhone15Pro, +// "iPhone16,2" : .iPhone15ProMax, +// +// // Apple Watch +// "Watch1,1" : .AppleWatch1, +// "Watch1,2" : .AppleWatch1, +// "Watch2,6" : .AppleWatchS1, +// "Watch2,7" : .AppleWatchS1, +// "Watch2,3" : .AppleWatchS2, +// "Watch2,4" : .AppleWatchS2, +// "Watch3,1" : .AppleWatchS3, +// "Watch3,2" : .AppleWatchS3, +// "Watch3,3" : .AppleWatchS3, +// "Watch3,4" : .AppleWatchS3, +// "Watch4,1" : .AppleWatchS4, +// "Watch4,2" : .AppleWatchS4, +// "Watch4,3" : .AppleWatchS4, +// "Watch4,4" : .AppleWatchS4, +// "Watch5,1" : .AppleWatchS5, +// "Watch5,2" : .AppleWatchS5, +// "Watch5,3" : .AppleWatchS5, +// "Watch5,4" : .AppleWatchS5, +// "Watch5,9" : .AppleWatchSE, +// "Watch5,10" : .AppleWatchSE, +// "Watch5,11" : .AppleWatchSE, +// "Watch5,12" : .AppleWatchSE, +// "Watch6,1" : .AppleWatchS6, +// "Watch6,2" : .AppleWatchS6, +// "Watch6,3" : .AppleWatchS6, +// "Watch6,4" : .AppleWatchS6, +// "Watch6,6" : .AppleWatchS7, +// "Watch6,7" : .AppleWatchS7, +// "Watch6,8" : .AppleWatchS7, +// "Watch6,9" : .AppleWatchS7, +// +// //Apple TV +// "AppleTV1,1" : .AppleTV1, +// "AppleTV2,1" : .AppleTV2, +// "AppleTV3,1" : .AppleTV3, +// "AppleTV3,2" : .AppleTV3, +// "AppleTV5,3" : .AppleTV4, +// "AppleTV6,2" : .AppleTV_4K, +// "AppleTV11,1" : .AppleTV2_4K +// ] +// +// guard let mcode = modelCode, let map = String(validatingUTF8: mcode), let model = modelMap[map] else { +// return DeviceVersionModel.unrecognized +// } +// +// if model == .simulator { +// if let simModelCode = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { +// if let simMap = String(validatingUTF8: simModelCode), let simModel = modelMap[simMap] { +// return simModel +// } +// } +// } +// +// return model +// +// } +// +//} From fbcea4991ac0478fe4d630c22a88ce4123d22200 Mon Sep 17 00:00:00 2001 From: Marc N Date: Wed, 27 Sep 2023 17:35:54 +0300 Subject: [PATCH 02/10] DiscoverySession for videoDevices --- Sources/CameraManager.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index 78842c5..61f094b 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -351,11 +351,11 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest let devices = AVCaptureDevice.videoDevices.filter { $0.position == .back } if #available(iOS 13.0, *) { - if UIDevice().type == .iPhone15ProMax || UIDevice().type == .iPhone15Pro { +// if UIDevice().type == .iPhone15ProMax || UIDevice().type == .iPhone15Pro { return devices.first { d in d.deviceType == .builtInTripleCamera } - } +// } } return devices.first @@ -1962,6 +1962,18 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest private extension AVCaptureDevice { static var videoDevices: [AVCaptureDevice] { + if #available(iOS 13.0, *) { + let deviceTypes: [AVCaptureDevice.DeviceType] + deviceTypes = [.builtInTripleCamera, .builtInDualWideCamera, .builtInDualCamera, .builtInWideAngleCamera] + + let session = AVCaptureDevice.DiscoverySession( + deviceTypes: deviceTypes, + mediaType: .video, + position: .unspecified + ) + + return session.devices + } return AVCaptureDevice.devices(for: AVMediaType.video) } } From 5d5dbe0f3d65782cd18fe89a35a3a9f7cc84da01 Mon Sep 17 00:00:00 2001 From: Marc N Date: Wed, 27 Sep 2023 17:59:23 +0300 Subject: [PATCH 03/10] beginZoomScale and devices.first --- Sources/CameraManager.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index 61f094b..a5b2846 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -351,10 +351,11 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest let devices = AVCaptureDevice.videoDevices.filter { $0.position == .back } if #available(iOS 13.0, *) { + beginZoomScale = 2.0 // if UIDevice().type == .iPhone15ProMax || UIDevice().type == .iPhone15Pro { return devices.first { d in - d.deviceType == .builtInTripleCamera - } + d.deviceType == .builtInTripleCamera + } ?? devices.first // } } From 269f8107842d62ea96225c9abb2be2b7d54edd1b Mon Sep 17 00:00:00 2001 From: Marc N Date: Wed, 27 Sep 2023 18:03:07 +0300 Subject: [PATCH 04/10] _zoom(1) --- Sources/CameraManager.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index a5b2846..112149a 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -292,7 +292,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest _setupOutputMode(cameraOutputMode, oldCameraOutputMode: oldValue) } _setupMaxZoomScale() - _zoom(0) + _zoom(1) } } } @@ -351,7 +351,6 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest let devices = AVCaptureDevice.videoDevices.filter { $0.position == .back } if #available(iOS 13.0, *) { - beginZoomScale = 2.0 // if UIDevice().type == .iPhone15ProMax || UIDevice().type == .iPhone15Pro { return devices.first { d in d.deviceType == .builtInTripleCamera From bfb51a03cabc4319615911d85ee80e4db829ef44 Mon Sep 17 00:00:00 2001 From: Marc N Date: Wed, 27 Sep 2023 18:14:50 +0300 Subject: [PATCH 05/10] zoom(2) --- Sources/CameraManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index 112149a..1523036 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -260,7 +260,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest _updateCameraDevice(cameraDevice) _updateIlluminationMode(flashMode) _setupMaxZoomScale() - _zoom(0) + _zoom(2) _orientationChanged() } } From 725e4a494450e74e84cff7672b142123e3630a79 Mon Sep 17 00:00:00 2001 From: Marc N Date: Wed, 27 Sep 2023 18:21:46 +0300 Subject: [PATCH 06/10] _zoom(2) --- Sources/CameraManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index 1523036..7c0e797 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -292,7 +292,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest _setupOutputMode(cameraOutputMode, oldCameraOutputMode: oldValue) } _setupMaxZoomScale() - _zoom(1) + _zoom(2) } } } From 4680a45d34358658ac8262d9e4b5f30283a0d898 Mon Sep 17 00:00:00 2001 From: Marc N Date: Thu, 28 Sep 2023 10:00:01 +0300 Subject: [PATCH 07/10] deprecated stuff removed - needs testing --- Sources/CameraManager.swift | 120 ++++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 34 deletions(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index a568cea..f2a350d 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -107,6 +107,34 @@ public enum CaptureError: Error { case assetNotSaved } +extension CameraManager: AVCapturePhotoCaptureDelegate { + public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?, previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) { +// if let error = error { +// self?._show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) +// imageCompletion(.failure(error)) +// return +// } +// +// guard let sample = sample else { imageCompletion(.failure(CaptureError.noSampleBuffer)); return } +// if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample) { +// imageCompletion(CaptureResult(imageData)) +// } else { +// imageCompletion(.failure(CaptureError.noImageData)) +// } + + if let error = error { + _show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) + imageCompletion?(.failure(error)) + return + } + + if let sampleBuffer = photoSampleBuffer, let previewBuffer = previewPhotoSampleBuffer, let dataImage = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: sampleBuffer, previewPhotoSampleBuffer: previewBuffer) { + //print("image: \(UIImage(data: dataImage)?.size)") // Your Image + imageCompletion?(CaptureResult(dataImage)) + } + } +} + /// Class for handling iDevices custom camera usage open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGestureRecognizerDelegate { // MARK: - Public properties @@ -355,7 +383,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest AVCaptureDevice.default(for: AVMediaType.audio) }() - fileprivate var stillImageOutput: AVCaptureStillImageOutput? + fileprivate var cameraOutput: AVCapturePhotoOutput? fileprivate var movieOutput: AVCaptureMovieFileOutput? fileprivate var previewLayer: AVCaptureVideoPreviewLayer? fileprivate var library: PHPhotoLibrary? @@ -498,7 +526,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest frontCameraDevice = nil backCameraDevice = nil mic = nil - stillImageOutput = nil + cameraOutput = nil movieOutput = nil animateCameraDeviceChange = oldAnimationValue } @@ -677,7 +705,9 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest :param: imageCompletion Completion block containing the captured imageData */ + internal var imageCompletion: ((CaptureResult) -> Void)? open func capturePictureDataWithCompletion(_ imageCompletion: @escaping (CaptureResult) -> Void) { + self.imageCompletion = imageCompletion guard cameraIsSetup else { _show(NSLocalizedString("No capture session setup", comment: ""), message: NSLocalizedString("I can't take any picture", comment: "")) return @@ -691,8 +721,8 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest _updateIlluminationMode(flashMode) sessionQueue.async { - let stillImageOutput = self._getStillImageOutput() - if let connection = stillImageOutput.connection(with: AVMediaType.video), + let cameraOutput = self._getStillImageOutput() + if let connection = cameraOutput.connection(with: AVMediaType.video), connection.isEnabled { if self.cameraDevice == CameraDevice.front, connection.isVideoMirroringSupported, self.shouldFlipFrontCameraImage { @@ -701,23 +731,33 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest if connection.isVideoOrientationSupported { connection.videoOrientation = self._currentCaptureVideoOrientation() } + + // add stuff to this + let settings = AVCapturePhotoSettings() + let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first! + let previewFormat = [kCVPixelBufferPixelFormatTypeKey as String: previewPixelType, + kCVPixelBufferWidthKey as String: 160, + kCVPixelBufferHeightKey as String: 160] + settings.previewPhotoFormat = previewFormat - stillImageOutput.captureStillImageAsynchronously(from: connection, completionHandler: { [weak self] sample, error in - - if let error = error { - self?._show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) - imageCompletion(.failure(error)) - return - } - - guard let sample = sample else { imageCompletion(.failure(CaptureError.noSampleBuffer)); return } - if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample) { - imageCompletion(CaptureResult(imageData)) - } else { - imageCompletion(.failure(CaptureError.noImageData)) - } - - }) + cameraOutput.capturePhoto(with: settings, delegate: self) + +// cameraOutput.captureStillImageAsynchronously(from: connection, completionHandler: { [weak self] sample, error in +// +// if let error = error { +// self?._show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) +// imageCompletion(.failure(error)) +// return +// } +// +// guard let sample = sample else { imageCompletion(.failure(CaptureError.noSampleBuffer)); return } +// if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample) { +// imageCompletion(CaptureResult(imageData)) +// } else { +// imageCompletion(.failure(CaptureError.noImageData)) +// } +// +// }) } else { imageCompletion(.failure(CaptureError.noVideoConnection)) } @@ -1283,20 +1323,20 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest } } - fileprivate func _getStillImageOutput() -> AVCaptureStillImageOutput { - if let stillImageOutput = stillImageOutput, let connection = stillImageOutput.connection(with: AVMediaType.video), + fileprivate func _getStillImageOutput() -> AVCapturePhotoOutput { + if let cameraOutput = cameraOutput, let connection = cameraOutput.connection(with: AVMediaType.video), connection.isActive { - return stillImageOutput + return cameraOutput } - let newStillImageOutput = AVCaptureStillImageOutput() - stillImageOutput = newStillImageOutput + let newcameraOutput = AVCapturePhotoOutput() + cameraOutput = newcameraOutput if let captureSession = captureSession, - captureSession.canAddOutput(newStillImageOutput) { + captureSession.canAddOutput(newcameraOutput) { captureSession.beginConfiguration() - captureSession.addOutput(newStillImageOutput) + captureSession.addOutput(newcameraOutput) captureSession.commitConfiguration() } - return newStillImageOutput + return newcameraOutput } @objc fileprivate func _orientationChanged() { @@ -1304,7 +1344,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest switch cameraOutputMode { case .stillImage: - currentConnection = stillImageOutput?.connection(with: AVMediaType.video) + currentConnection = cameraOutput?.connection(with: AVMediaType.video) case .videoOnly, .videoWithMic: currentConnection = _getMovieOutput().connection(with: AVMediaType.video) if let location = locationManager?.latestLocation { @@ -1578,8 +1618,8 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest // remove current setting switch cameraOutputToRemove { case .stillImage: - if let validStillImageOutput = stillImageOutput { - captureSession?.removeOutput(validStillImageOutput) + if let validcameraOutput = cameraOutput { + captureSession?.removeOutput(validcameraOutput) } case .videoOnly, .videoWithMic: if let validMovieOutput = movieOutput { @@ -1619,8 +1659,8 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest } fileprivate func _setupOutputs() { - if stillImageOutput == nil { - stillImageOutput = AVCaptureStillImageOutput() + if cameraOutput == nil { + cameraOutput = AVCapturePhotoOutput() } if movieOutput == nil { movieOutput = _getMovieOutput() @@ -1951,7 +1991,19 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest private extension AVCaptureDevice { static var videoDevices: [AVCaptureDevice] { - return AVCaptureDevice.devices(for: AVMediaType.video) + if #available(iOS 13.0, *) { + let deviceTypes: [AVCaptureDevice.DeviceType] + deviceTypes = [.builtInTripleCamera, .builtInDualWideCamera, .builtInDualCamera, .builtInWideAngleCamera] + + let session = AVCaptureDevice.DiscoverySession( + deviceTypes: deviceTypes, + mediaType: .video, + position: .unspecified + ) + + return session.devices + } + return [] } } From 69d6f79ddb990127c729534737bf154b98b027ce Mon Sep 17 00:00:00 2001 From: Marc N Date: Thu, 28 Sep 2023 10:27:10 +0300 Subject: [PATCH 08/10] dsa --- .../AppIcon.appiconset/Contents.json | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/Example App/Images.xcassets/AppIcon.appiconset/Contents.json b/Example App/Images.xcassets/AppIcon.appiconset/Contents.json index 310a43b..582a751 100644 --- a/Example App/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example App/Images.xcassets/AppIcon.appiconset/Contents.json @@ -143,12 +143,6 @@ "scale" : "2x", "size" : "83.5x83.5" }, - { - "filename" : "logo.jpeg", - "idiom" : "ios-marketing", - "scale" : "1x", - "size" : "1024x1024" - }, { "filename" : "Icon-App-60x60@2x.png", "idiom" : "car", @@ -161,6 +155,12 @@ "scale" : "3x", "size" : "60x60" }, + { + "filename" : "logo.jpeg", + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + }, { "idiom" : "watch", "role" : "notificationCenter", @@ -189,6 +189,13 @@ "scale" : "3x", "size" : "29x29" }, + { + "idiom" : "watch", + "role" : "notificationCenter", + "scale" : "2x", + "size" : "33x33", + "subtype" : "45mm" + }, { "filename" : "Icon-App-40x40@2x.png", "idiom" : "watch", @@ -204,6 +211,13 @@ "size" : "44x44", "subtype" : "40mm" }, + { + "idiom" : "watch", + "role" : "appLauncher", + "scale" : "2x", + "size" : "46x46", + "subtype" : "41mm" + }, { "idiom" : "watch", "role" : "appLauncher", @@ -211,6 +225,20 @@ "size" : "50x50", "subtype" : "44mm" }, + { + "idiom" : "watch", + "role" : "appLauncher", + "scale" : "2x", + "size" : "51x51", + "subtype" : "45mm" + }, + { + "idiom" : "watch", + "role" : "appLauncher", + "scale" : "2x", + "size" : "54x54", + "subtype" : "49mm" + }, { "idiom" : "watch", "role" : "quickLook", @@ -232,6 +260,20 @@ "size" : "108x108", "subtype" : "44mm" }, + { + "idiom" : "watch", + "role" : "quickLook", + "scale" : "2x", + "size" : "117x117", + "subtype" : "45mm" + }, + { + "idiom" : "watch", + "role" : "quickLook", + "scale" : "2x", + "size" : "129x129", + "subtype" : "49mm" + }, { "idiom" : "watch-marketing", "scale" : "1x", From b593a846361f8e7846e0c5d308e686b1a70be1ee Mon Sep 17 00:00:00 2001 From: Marc N Date: Thu, 28 Sep 2023 10:51:15 +0300 Subject: [PATCH 09/10] removed commented code --- Sources/CameraManager.swift | 379 +----------------------------------- 1 file changed, 5 insertions(+), 374 deletions(-) diff --git a/Sources/CameraManager.swift b/Sources/CameraManager.swift index cb62d32..e08105a 100644 --- a/Sources/CameraManager.swift +++ b/Sources/CameraManager.swift @@ -109,18 +109,6 @@ public enum CaptureError: Error { extension CameraManager: AVCapturePhotoCaptureDelegate { public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?, previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) { -// if let error = error { -// self?._show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) -// imageCompletion(.failure(error)) -// return -// } -// -// guard let sample = sample else { imageCompletion(.failure(CaptureError.noSampleBuffer)); return } -// if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample) { -// imageCompletion(CaptureResult(imageData)) -// } else { -// imageCompletion(.failure(CaptureError.noImageData)) -// } if let error = error { _show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) @@ -129,7 +117,7 @@ extension CameraManager: AVCapturePhotoCaptureDelegate { } if let sampleBuffer = photoSampleBuffer, let previewBuffer = previewPhotoSampleBuffer, let dataImage = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: sampleBuffer, previewPhotoSampleBuffer: previewBuffer) { - //print("image: \(UIImage(data: dataImage)?.size)") // Your Image + print("image: \(UIImage(data: dataImage)?.size)") // Your Image imageCompletion?(CaptureResult(dataImage)) } } @@ -379,11 +367,9 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest let devices = AVCaptureDevice.videoDevices.filter { $0.position == .back } if #available(iOS 13.0, *) { -// if UIDevice().type == .iPhone15ProMax || UIDevice().type == .iPhone15Pro { - return devices.first { d in - d.deviceType == .builtInTripleCamera - } ?? devices.first -// } + return devices.first { d in + d.deviceType == .builtInTripleCamera + } ?? devices.first } return devices.first @@ -752,23 +738,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest settings.previewPhotoFormat = previewFormat cameraOutput.capturePhoto(with: settings, delegate: self) - -// cameraOutput.captureStillImageAsynchronously(from: connection, completionHandler: { [weak self] sample, error in -// -// if let error = error { -// self?._show(NSLocalizedString("Error", comment: ""), message: error.localizedDescription) -// imageCompletion(.failure(error)) -// return -// } -// -// guard let sample = sample else { imageCompletion(.failure(CaptureError.noSampleBuffer)); return } -// if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample) { -// imageCompletion(CaptureResult(imageData)) -// } else { -// imageCompletion(.failure(CaptureError.noImageData)) -// } -// -// }) + } else { imageCompletion(.failure(CaptureError.noVideoConnection)) } @@ -2200,342 +2170,3 @@ extension CameraManager: AVCaptureMetadataOutputObjectsDelegate { handler(.success(stringValue)) } } - -public enum DeviceVersionModel : String { - -//Simulator -case simulator = "simulator/sandbox", - -//iPod -iPod1 = "iPod 1", -iPod2 = "iPod 2", -iPod3 = "iPod 3", -iPod4 = "iPod 4", -iPod5 = "iPod 5", -iPod6 = "iPod 6", -iPod7 = "iPod 7", - -//iPad -iPad2 = "iPad 2", -iPad3 = "iPad 3", -iPad4 = "iPad 4", -iPadAir = "iPad Air ", -iPadAir2 = "iPad Air 2", -iPadAir3 = "iPad Air 3", -iPadAir4 = "iPad Air 4", -iPadAir5 = "iPad Air 5", -iPad5 = "iPad 5", //iPad 2017 -iPad6 = "iPad 6", //iPad 2018 -iPad7 = "iPad 7", //iPad 2019 -iPad8 = "iPad 8", //iPad 2020 -iPad9 = "iPad 9", //iPad 2021 -iPad10 = "iPad 10", //iPad 2022 - -//iPad Mini -iPadMini = "iPad Mini", -iPadMini2 = "iPad Mini 2", -iPadMini3 = "iPad Mini 3", -iPadMini4 = "iPad Mini 4", -iPadMini5 = "iPad Mini 5", -iPadMini6 = "iPad Mini 6", - -//iPad Pro -iPadPro9_7 = "iPad Pro 9.7\"", -iPadPro10_5 = "iPad Pro 10.5\"", -iPadPro11 = "iPad Pro 11\"", -iPadPro2_11 = "iPad Pro 11\" 2nd gen", -iPadPro3_11 = "iPad Pro 11\" 3rd gen", -iPadPro12_9 = "iPad Pro 12.9\"", -iPadPro2_12_9 = "iPad Pro 2 12.9\"", -iPadPro3_12_9 = "iPad Pro 3 12.9\"", -iPadPro4_12_9 = "iPad Pro 4 12.9\"", -iPadPro5_12_9 = "iPad Pro 5 12.9\"", - -//iPhone -iPhone4 = "iPhone 4", -iPhone4S = "iPhone 4S", -iPhone5 = "iPhone 5", -iPhone5S = "iPhone 5S", -iPhone5C = "iPhone 5C", -iPhone6 = "iPhone 6", -iPhone6Plus = "iPhone 6 Plus", -iPhone6S = "iPhone 6S", -iPhone6SPlus = "iPhone 6S Plus", -iPhoneSE = "iPhone SE", -iPhone7 = "iPhone 7", -iPhone7Plus = "iPhone 7 Plus", -iPhone8 = "iPhone 8", -iPhone8Plus = "iPhone 8 Plus", -iPhoneX = "iPhone X", -iPhoneXS = "iPhone XS", -iPhoneXSMax = "iPhone XS Max", -iPhoneXR = "iPhone XR", -iPhone11 = "iPhone 11", -iPhone11Pro = "iPhone 11 Pro", -iPhone11ProMax = "iPhone 11 Pro Max", -iPhoneSE2 = "iPhone SE 2nd gen", -iPhone12Mini = "iPhone 12 Mini", -iPhone12 = "iPhone 12", -iPhone12Pro = "iPhone 12 Pro", -iPhone12ProMax = "iPhone 12 Pro Max", -iPhone13Mini = "iPhone 13 Mini", -iPhone13 = "iPhone 13", -iPhone13Pro = "iPhone 13 Pro", -iPhone13ProMax = "iPhone 13 Pro Max", -iPhoneSE3 = "iPhone SE 3nd gen", -iPhone14 = "iPhone 14", -iPhone14Plus = "iPhone 14 Plus", -iPhone14Pro = "iPhone 14 Pro", -iPhone14ProMax = "iPhone 14 Pro Max", -iPhone15 = "iPhone 15", -iPhone15Plus = "iPhone 15 Plus", -iPhone15Pro = "iPhone 15 Pro", -iPhone15ProMax = "iPhone 15 Pro Max", - -// Apple Watch -AppleWatch1 = "Apple Watch 1gen", -AppleWatchS1 = "Apple Watch Series 1", -AppleWatchS2 = "Apple Watch Series 2", -AppleWatchS3 = "Apple Watch Series 3", -AppleWatchS4 = "Apple Watch Series 4", -AppleWatchS5 = "Apple Watch Series 5", -AppleWatchSE = "Apple Watch Special Edition", -AppleWatchS6 = "Apple Watch Series 6", -AppleWatchS7 = "Apple Watch Series 7", - -//Apple TV -AppleTV1 = "Apple TV 1gen", -AppleTV2 = "Apple TV 2gen", -AppleTV3 = "Apple TV 3gen", -AppleTV4 = "Apple TV 4gen", -AppleTV_4K = "Apple TV 4K", -AppleTV2_4K = "Apple TV 4K 2gen", - -unrecognized = "?unrecognized?" -} - -// #-#-#-#-#-#-#-#-#-#-#-#-# -// MARK: UIDevice extensions -// #-#-#-#-#-#-#-#-#-#-#-#-# - - public extension UIDevice { - - var type: DeviceVersionModel { - var systemInfo = utsname() - uname(&systemInfo) - let modelCode = withUnsafePointer(to: &systemInfo.machine) { - $0.withMemoryRebound(to: CChar.self, capacity: 1) { - ptr in String.init(validatingUTF8: ptr) - } - } - - let modelMap : [String: DeviceVersionModel] = [ - - //Simulator - "i386" : .simulator, - "x86_64" : .simulator, - - //iPod - "iPod1,1" : .iPod1, - "iPod2,1" : .iPod2, - "iPod3,1" : .iPod3, - "iPod4,1" : .iPod4, - "iPod5,1" : .iPod5, - "iPod7,1" : .iPod6, - "iPod9,1" : .iPod7, - - //iPad - "iPad2,1" : .iPad2, - "iPad2,2" : .iPad2, - "iPad2,3" : .iPad2, - "iPad2,4" : .iPad2, - "iPad3,1" : .iPad3, - "iPad3,2" : .iPad3, - "iPad3,3" : .iPad3, - "iPad3,4" : .iPad4, - "iPad3,5" : .iPad4, - "iPad3,6" : .iPad4, - "iPad6,11" : .iPad5, //iPad 2017 - "iPad6,12" : .iPad5, - "iPad7,5" : .iPad6, //iPad 2018 - "iPad7,6" : .iPad6, - "iPad7,11" : .iPad7, //iPad 2019 - "iPad7,12" : .iPad7, - "iPad11,6" : .iPad8, //iPad 2020 - "iPad11,7" : .iPad8, - "iPad12,1" : .iPad9, //iPad 2021 - "iPad12,2" : .iPad9, - "iPad13,18" : .iPad10, - "iPad13,19" : .iPad10, - - //iPad Mini - "iPad2,5" : .iPadMini, - "iPad2,6" : .iPadMini, - "iPad2,7" : .iPadMini, - "iPad4,4" : .iPadMini2, - "iPad4,5" : .iPadMini2, - "iPad4,6" : .iPadMini2, - "iPad4,7" : .iPadMini3, - "iPad4,8" : .iPadMini3, - "iPad4,9" : .iPadMini3, - "iPad5,1" : .iPadMini4, - "iPad5,2" : .iPadMini4, - "iPad11,1" : .iPadMini5, - "iPad11,2" : .iPadMini5, - "iPad14,1" : .iPadMini6, - "iPad14,2" : .iPadMini6, - - //iPad Pro - "iPad6,3" : .iPadPro9_7, - "iPad6,4" : .iPadPro9_7, - "iPad7,3" : .iPadPro10_5, - "iPad7,4" : .iPadPro10_5, - "iPad6,7" : .iPadPro12_9, - "iPad6,8" : .iPadPro12_9, - "iPad7,1" : .iPadPro2_12_9, - "iPad7,2" : .iPadPro2_12_9, - "iPad8,1" : .iPadPro11, - "iPad8,2" : .iPadPro11, - "iPad8,3" : .iPadPro11, - "iPad8,4" : .iPadPro11, - "iPad8,9" : .iPadPro2_11, - "iPad8,10" : .iPadPro2_11, - "iPad13,4" : .iPadPro3_11, - "iPad13,5" : .iPadPro3_11, - "iPad13,6" : .iPadPro3_11, - "iPad13,7" : .iPadPro3_11, - "iPad8,5" : .iPadPro3_12_9, - "iPad8,6" : .iPadPro3_12_9, - "iPad8,7" : .iPadPro3_12_9, - "iPad8,8" : .iPadPro3_12_9, - "iPad8,11" : .iPadPro4_12_9, - "iPad8,12" : .iPadPro4_12_9, - "iPad13,8" : .iPadPro5_12_9, - "iPad13,9" : .iPadPro5_12_9, - "iPad13,10" : .iPadPro5_12_9, - "iPad13,11" : .iPadPro5_12_9, - - //iPad Air - "iPad4,1" : .iPadAir, - "iPad4,2" : .iPadAir, - "iPad4,3" : .iPadAir, - "iPad5,3" : .iPadAir2, - "iPad5,4" : .iPadAir2, - "iPad11,3" : .iPadAir3, - "iPad11,4" : .iPadAir3, - "iPad13,1" : .iPadAir4, - "iPad13,2" : .iPadAir4, - "iPad13,16" : .iPadAir5, - "iPad13,17" : .iPadAir5, - - //iPhone - "iPhone3,1" : .iPhone4, - "iPhone3,2" : .iPhone4, - "iPhone3,3" : .iPhone4, - "iPhone4,1" : .iPhone4S, - "iPhone5,1" : .iPhone5, - "iPhone5,2" : .iPhone5, - "iPhone5,3" : .iPhone5C, - "iPhone5,4" : .iPhone5C, - "iPhone6,1" : .iPhone5S, - "iPhone6,2" : .iPhone5S, - "iPhone7,1" : .iPhone6Plus, - "iPhone7,2" : .iPhone6, - "iPhone8,1" : .iPhone6S, - "iPhone8,2" : .iPhone6SPlus, - "iPhone8,4" : .iPhoneSE, - "iPhone9,1" : .iPhone7, - "iPhone9,3" : .iPhone7, - "iPhone9,2" : .iPhone7Plus, - "iPhone9,4" : .iPhone7Plus, - "iPhone10,1" : .iPhone8, - "iPhone10,4" : .iPhone8, - "iPhone10,2" : .iPhone8Plus, - "iPhone10,5" : .iPhone8Plus, - "iPhone10,3" : .iPhoneX, - "iPhone10,6" : .iPhoneX, - "iPhone11,2" : .iPhoneXS, - "iPhone11,4" : .iPhoneXSMax, - "iPhone11,6" : .iPhoneXSMax, - "iPhone11,8" : .iPhoneXR, - "iPhone12,1" : .iPhone11, - "iPhone12,3" : .iPhone11Pro, - "iPhone12,5" : .iPhone11ProMax, - "iPhone12,8" : .iPhoneSE2, - "iPhone13,1" : .iPhone12Mini, - "iPhone13,2" : .iPhone12, - "iPhone13,3" : .iPhone12Pro, - "iPhone13,4" : .iPhone12ProMax, - "iPhone14,4" : .iPhone13Mini, - "iPhone14,5" : .iPhone13, - "iPhone14,2" : .iPhone13Pro, - "iPhone14,3" : .iPhone13ProMax, - "iPhone14,6" : .iPhoneSE3, - "iPhone14,7" : .iPhone14, - "iPhone14,8" : .iPhone14Plus, - "iPhone15,2" : .iPhone14Pro, - "iPhone15,3" : .iPhone14ProMax, - "iPhone15,4" : .iPhone15, - "iPhone15,5" : .iPhone15Plus, - "iPhone16,1" : .iPhone15Pro, - "iPhone16,2" : .iPhone15ProMax, - - // Apple Watch - "Watch1,1" : .AppleWatch1, - "Watch1,2" : .AppleWatch1, - "Watch2,6" : .AppleWatchS1, - "Watch2,7" : .AppleWatchS1, - "Watch2,3" : .AppleWatchS2, - "Watch2,4" : .AppleWatchS2, - "Watch3,1" : .AppleWatchS3, - "Watch3,2" : .AppleWatchS3, - "Watch3,3" : .AppleWatchS3, - "Watch3,4" : .AppleWatchS3, - "Watch4,1" : .AppleWatchS4, - "Watch4,2" : .AppleWatchS4, - "Watch4,3" : .AppleWatchS4, - "Watch4,4" : .AppleWatchS4, - "Watch5,1" : .AppleWatchS5, - "Watch5,2" : .AppleWatchS5, - "Watch5,3" : .AppleWatchS5, - "Watch5,4" : .AppleWatchS5, - "Watch5,9" : .AppleWatchSE, - "Watch5,10" : .AppleWatchSE, - "Watch5,11" : .AppleWatchSE, - "Watch5,12" : .AppleWatchSE, - "Watch6,1" : .AppleWatchS6, - "Watch6,2" : .AppleWatchS6, - "Watch6,3" : .AppleWatchS6, - "Watch6,4" : .AppleWatchS6, - "Watch6,6" : .AppleWatchS7, - "Watch6,7" : .AppleWatchS7, - "Watch6,8" : .AppleWatchS7, - "Watch6,9" : .AppleWatchS7, - - //Apple TV - "AppleTV1,1" : .AppleTV1, - "AppleTV2,1" : .AppleTV2, - "AppleTV3,1" : .AppleTV3, - "AppleTV3,2" : .AppleTV3, - "AppleTV5,3" : .AppleTV4, - "AppleTV6,2" : .AppleTV_4K, - "AppleTV11,1" : .AppleTV2_4K - ] - - guard let mcode = modelCode, let map = String(validatingUTF8: mcode), let model = modelMap[map] else { - return DeviceVersionModel.unrecognized - } - - if model == .simulator { - if let simModelCode = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { - if let simMap = String(validatingUTF8: simModelCode), let simModel = modelMap[simMap] { - return simModel - } - } - } - - return model - - } - -} From f1165a6cc5e9f7795f8d0db782f295cd77e6caf9 Mon Sep 17 00:00:00 2001 From: Marc N Date: Thu, 28 Sep 2023 11:23:34 +0300 Subject: [PATCH 10/10] removed unneeded files --- Sources/DeviceVersionModel.swift | 347 ------------------------------- 1 file changed, 347 deletions(-) delete mode 100644 Sources/DeviceVersionModel.swift diff --git a/Sources/DeviceVersionModel.swift b/Sources/DeviceVersionModel.swift deleted file mode 100644 index cfb6d91..0000000 --- a/Sources/DeviceVersionModel.swift +++ /dev/null @@ -1,347 +0,0 @@ -//// -//// DeviceType.swift -//// -//// -//// Created by Marc Nicolae Popa on 9/27/23. -//// -// -//import UIKit -// -//public enum DeviceVersionModel : String { -// -////Simulator -//case simulator = "simulator/sandbox", -// -////iPod -//iPod1 = "iPod 1", -//iPod2 = "iPod 2", -//iPod3 = "iPod 3", -//iPod4 = "iPod 4", -//iPod5 = "iPod 5", -//iPod6 = "iPod 6", -//iPod7 = "iPod 7", -// -////iPad -//iPad2 = "iPad 2", -//iPad3 = "iPad 3", -//iPad4 = "iPad 4", -//iPadAir = "iPad Air ", -//iPadAir2 = "iPad Air 2", -//iPadAir3 = "iPad Air 3", -//iPadAir4 = "iPad Air 4", -//iPadAir5 = "iPad Air 5", -//iPad5 = "iPad 5", //iPad 2017 -//iPad6 = "iPad 6", //iPad 2018 -//iPad7 = "iPad 7", //iPad 2019 -//iPad8 = "iPad 8", //iPad 2020 -//iPad9 = "iPad 9", //iPad 2021 -//iPad10 = "iPad 10", //iPad 2022 -// -////iPad Mini -//iPadMini = "iPad Mini", -//iPadMini2 = "iPad Mini 2", -//iPadMini3 = "iPad Mini 3", -//iPadMini4 = "iPad Mini 4", -//iPadMini5 = "iPad Mini 5", -//iPadMini6 = "iPad Mini 6", -// -////iPad Pro -//iPadPro9_7 = "iPad Pro 9.7\"", -//iPadPro10_5 = "iPad Pro 10.5\"", -//iPadPro11 = "iPad Pro 11\"", -//iPadPro2_11 = "iPad Pro 11\" 2nd gen", -//iPadPro3_11 = "iPad Pro 11\" 3rd gen", -//iPadPro12_9 = "iPad Pro 12.9\"", -//iPadPro2_12_9 = "iPad Pro 2 12.9\"", -//iPadPro3_12_9 = "iPad Pro 3 12.9\"", -//iPadPro4_12_9 = "iPad Pro 4 12.9\"", -//iPadPro5_12_9 = "iPad Pro 5 12.9\"", -// -////iPhone -//iPhone4 = "iPhone 4", -//iPhone4S = "iPhone 4S", -//iPhone5 = "iPhone 5", -//iPhone5S = "iPhone 5S", -//iPhone5C = "iPhone 5C", -//iPhone6 = "iPhone 6", -//iPhone6Plus = "iPhone 6 Plus", -//iPhone6S = "iPhone 6S", -//iPhone6SPlus = "iPhone 6S Plus", -//iPhoneSE = "iPhone SE", -//iPhone7 = "iPhone 7", -//iPhone7Plus = "iPhone 7 Plus", -//iPhone8 = "iPhone 8", -//iPhone8Plus = "iPhone 8 Plus", -//iPhoneX = "iPhone X", -//iPhoneXS = "iPhone XS", -//iPhoneXSMax = "iPhone XS Max", -//iPhoneXR = "iPhone XR", -//iPhone11 = "iPhone 11", -//iPhone11Pro = "iPhone 11 Pro", -//iPhone11ProMax = "iPhone 11 Pro Max", -//iPhoneSE2 = "iPhone SE 2nd gen", -//iPhone12Mini = "iPhone 12 Mini", -//iPhone12 = "iPhone 12", -//iPhone12Pro = "iPhone 12 Pro", -//iPhone12ProMax = "iPhone 12 Pro Max", -//iPhone13Mini = "iPhone 13 Mini", -//iPhone13 = "iPhone 13", -//iPhone13Pro = "iPhone 13 Pro", -//iPhone13ProMax = "iPhone 13 Pro Max", -//iPhoneSE3 = "iPhone SE 3nd gen", -//iPhone14 = "iPhone 14", -//iPhone14Plus = "iPhone 14 Plus", -//iPhone14Pro = "iPhone 14 Pro", -//iPhone14ProMax = "iPhone 14 Pro Max", -//iPhone15 = "iPhone 15", -//iPhone15Plus = "iPhone 15 Plus", -//iPhone15Pro = "iPhone 15 Pro", -//iPhone15ProMax = "iPhone 15 Pro Max", -// -//// Apple Watch -//AppleWatch1 = "Apple Watch 1gen", -//AppleWatchS1 = "Apple Watch Series 1", -//AppleWatchS2 = "Apple Watch Series 2", -//AppleWatchS3 = "Apple Watch Series 3", -//AppleWatchS4 = "Apple Watch Series 4", -//AppleWatchS5 = "Apple Watch Series 5", -//AppleWatchSE = "Apple Watch Special Edition", -//AppleWatchS6 = "Apple Watch Series 6", -//AppleWatchS7 = "Apple Watch Series 7", -// -////Apple TV -//AppleTV1 = "Apple TV 1gen", -//AppleTV2 = "Apple TV 2gen", -//AppleTV3 = "Apple TV 3gen", -//AppleTV4 = "Apple TV 4gen", -//AppleTV_4K = "Apple TV 4K", -//AppleTV2_4K = "Apple TV 4K 2gen", -// -//unrecognized = "?unrecognized?" -//} -// -//// #-#-#-#-#-#-#-#-#-#-#-#-# -//// MARK: UIDevice extensions -//// #-#-#-#-#-#-#-#-#-#-#-#-# -// -// public extension UIDevice { -// -// var type: DeviceVersionModel { -// var systemInfo = utsname() -// uname(&systemInfo) -// let modelCode = withUnsafePointer(to: &systemInfo.machine) { -// $0.withMemoryRebound(to: CChar.self, capacity: 1) { -// ptr in String.init(validatingUTF8: ptr) -// } -// } -// -// let modelMap : [String: DeviceVersionModel] = [ -// -// //Simulator -// "i386" : .simulator, -// "x86_64" : .simulator, -// -// //iPod -// "iPod1,1" : .iPod1, -// "iPod2,1" : .iPod2, -// "iPod3,1" : .iPod3, -// "iPod4,1" : .iPod4, -// "iPod5,1" : .iPod5, -// "iPod7,1" : .iPod6, -// "iPod9,1" : .iPod7, -// -// //iPad -// "iPad2,1" : .iPad2, -// "iPad2,2" : .iPad2, -// "iPad2,3" : .iPad2, -// "iPad2,4" : .iPad2, -// "iPad3,1" : .iPad3, -// "iPad3,2" : .iPad3, -// "iPad3,3" : .iPad3, -// "iPad3,4" : .iPad4, -// "iPad3,5" : .iPad4, -// "iPad3,6" : .iPad4, -// "iPad6,11" : .iPad5, //iPad 2017 -// "iPad6,12" : .iPad5, -// "iPad7,5" : .iPad6, //iPad 2018 -// "iPad7,6" : .iPad6, -// "iPad7,11" : .iPad7, //iPad 2019 -// "iPad7,12" : .iPad7, -// "iPad11,6" : .iPad8, //iPad 2020 -// "iPad11,7" : .iPad8, -// "iPad12,1" : .iPad9, //iPad 2021 -// "iPad12,2" : .iPad9, -// "iPad13,18" : .iPad10, -// "iPad13,19" : .iPad10, -// -// //iPad Mini -// "iPad2,5" : .iPadMini, -// "iPad2,6" : .iPadMini, -// "iPad2,7" : .iPadMini, -// "iPad4,4" : .iPadMini2, -// "iPad4,5" : .iPadMini2, -// "iPad4,6" : .iPadMini2, -// "iPad4,7" : .iPadMini3, -// "iPad4,8" : .iPadMini3, -// "iPad4,9" : .iPadMini3, -// "iPad5,1" : .iPadMini4, -// "iPad5,2" : .iPadMini4, -// "iPad11,1" : .iPadMini5, -// "iPad11,2" : .iPadMini5, -// "iPad14,1" : .iPadMini6, -// "iPad14,2" : .iPadMini6, -// -// //iPad Pro -// "iPad6,3" : .iPadPro9_7, -// "iPad6,4" : .iPadPro9_7, -// "iPad7,3" : .iPadPro10_5, -// "iPad7,4" : .iPadPro10_5, -// "iPad6,7" : .iPadPro12_9, -// "iPad6,8" : .iPadPro12_9, -// "iPad7,1" : .iPadPro2_12_9, -// "iPad7,2" : .iPadPro2_12_9, -// "iPad8,1" : .iPadPro11, -// "iPad8,2" : .iPadPro11, -// "iPad8,3" : .iPadPro11, -// "iPad8,4" : .iPadPro11, -// "iPad8,9" : .iPadPro2_11, -// "iPad8,10" : .iPadPro2_11, -// "iPad13,4" : .iPadPro3_11, -// "iPad13,5" : .iPadPro3_11, -// "iPad13,6" : .iPadPro3_11, -// "iPad13,7" : .iPadPro3_11, -// "iPad8,5" : .iPadPro3_12_9, -// "iPad8,6" : .iPadPro3_12_9, -// "iPad8,7" : .iPadPro3_12_9, -// "iPad8,8" : .iPadPro3_12_9, -// "iPad8,11" : .iPadPro4_12_9, -// "iPad8,12" : .iPadPro4_12_9, -// "iPad13,8" : .iPadPro5_12_9, -// "iPad13,9" : .iPadPro5_12_9, -// "iPad13,10" : .iPadPro5_12_9, -// "iPad13,11" : .iPadPro5_12_9, -// -// //iPad Air -// "iPad4,1" : .iPadAir, -// "iPad4,2" : .iPadAir, -// "iPad4,3" : .iPadAir, -// "iPad5,3" : .iPadAir2, -// "iPad5,4" : .iPadAir2, -// "iPad11,3" : .iPadAir3, -// "iPad11,4" : .iPadAir3, -// "iPad13,1" : .iPadAir4, -// "iPad13,2" : .iPadAir4, -// "iPad13,16" : .iPadAir5, -// "iPad13,17" : .iPadAir5, -// -// //iPhone -// "iPhone3,1" : .iPhone4, -// "iPhone3,2" : .iPhone4, -// "iPhone3,3" : .iPhone4, -// "iPhone4,1" : .iPhone4S, -// "iPhone5,1" : .iPhone5, -// "iPhone5,2" : .iPhone5, -// "iPhone5,3" : .iPhone5C, -// "iPhone5,4" : .iPhone5C, -// "iPhone6,1" : .iPhone5S, -// "iPhone6,2" : .iPhone5S, -// "iPhone7,1" : .iPhone6Plus, -// "iPhone7,2" : .iPhone6, -// "iPhone8,1" : .iPhone6S, -// "iPhone8,2" : .iPhone6SPlus, -// "iPhone8,4" : .iPhoneSE, -// "iPhone9,1" : .iPhone7, -// "iPhone9,3" : .iPhone7, -// "iPhone9,2" : .iPhone7Plus, -// "iPhone9,4" : .iPhone7Plus, -// "iPhone10,1" : .iPhone8, -// "iPhone10,4" : .iPhone8, -// "iPhone10,2" : .iPhone8Plus, -// "iPhone10,5" : .iPhone8Plus, -// "iPhone10,3" : .iPhoneX, -// "iPhone10,6" : .iPhoneX, -// "iPhone11,2" : .iPhoneXS, -// "iPhone11,4" : .iPhoneXSMax, -// "iPhone11,6" : .iPhoneXSMax, -// "iPhone11,8" : .iPhoneXR, -// "iPhone12,1" : .iPhone11, -// "iPhone12,3" : .iPhone11Pro, -// "iPhone12,5" : .iPhone11ProMax, -// "iPhone12,8" : .iPhoneSE2, -// "iPhone13,1" : .iPhone12Mini, -// "iPhone13,2" : .iPhone12, -// "iPhone13,3" : .iPhone12Pro, -// "iPhone13,4" : .iPhone12ProMax, -// "iPhone14,4" : .iPhone13Mini, -// "iPhone14,5" : .iPhone13, -// "iPhone14,2" : .iPhone13Pro, -// "iPhone14,3" : .iPhone13ProMax, -// "iPhone14,6" : .iPhoneSE3, -// "iPhone14,7" : .iPhone14, -// "iPhone14,8" : .iPhone14Plus, -// "iPhone15,2" : .iPhone14Pro, -// "iPhone15,3" : .iPhone14ProMax, -// "iPhone15,4" : .iPhone15, -// "iPhone15,5" : .iPhone15Plus, -// "iPhone16,1" : .iPhone15Pro, -// "iPhone16,2" : .iPhone15ProMax, -// -// // Apple Watch -// "Watch1,1" : .AppleWatch1, -// "Watch1,2" : .AppleWatch1, -// "Watch2,6" : .AppleWatchS1, -// "Watch2,7" : .AppleWatchS1, -// "Watch2,3" : .AppleWatchS2, -// "Watch2,4" : .AppleWatchS2, -// "Watch3,1" : .AppleWatchS3, -// "Watch3,2" : .AppleWatchS3, -// "Watch3,3" : .AppleWatchS3, -// "Watch3,4" : .AppleWatchS3, -// "Watch4,1" : .AppleWatchS4, -// "Watch4,2" : .AppleWatchS4, -// "Watch4,3" : .AppleWatchS4, -// "Watch4,4" : .AppleWatchS4, -// "Watch5,1" : .AppleWatchS5, -// "Watch5,2" : .AppleWatchS5, -// "Watch5,3" : .AppleWatchS5, -// "Watch5,4" : .AppleWatchS5, -// "Watch5,9" : .AppleWatchSE, -// "Watch5,10" : .AppleWatchSE, -// "Watch5,11" : .AppleWatchSE, -// "Watch5,12" : .AppleWatchSE, -// "Watch6,1" : .AppleWatchS6, -// "Watch6,2" : .AppleWatchS6, -// "Watch6,3" : .AppleWatchS6, -// "Watch6,4" : .AppleWatchS6, -// "Watch6,6" : .AppleWatchS7, -// "Watch6,7" : .AppleWatchS7, -// "Watch6,8" : .AppleWatchS7, -// "Watch6,9" : .AppleWatchS7, -// -// //Apple TV -// "AppleTV1,1" : .AppleTV1, -// "AppleTV2,1" : .AppleTV2, -// "AppleTV3,1" : .AppleTV3, -// "AppleTV3,2" : .AppleTV3, -// "AppleTV5,3" : .AppleTV4, -// "AppleTV6,2" : .AppleTV_4K, -// "AppleTV11,1" : .AppleTV2_4K -// ] -// -// guard let mcode = modelCode, let map = String(validatingUTF8: mcode), let model = modelMap[map] else { -// return DeviceVersionModel.unrecognized -// } -// -// if model == .simulator { -// if let simModelCode = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { -// if let simMap = String(validatingUTF8: simModelCode), let simModel = modelMap[simMap] { -// return simModel -// } -// } -// } -// -// return model -// -// } -// -//}