diff --git a/src/SDK/Language/Apple.php b/src/SDK/Language/Apple.php index 7bbffae32..e3515de48 100644 --- a/src/SDK/Language/Apple.php +++ b/src/SDK/Language/Apple.php @@ -136,6 +136,31 @@ public function getFiles(): array 'destination' => '/example-swiftui/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist', 'template' => '/swift/example-swiftui/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist', ], + [ + 'scope' => 'default', + 'destination' => '/example-uikit/UIKitExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved', + 'template' => '/swift/example-uikit/UIKitExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved', + ], + [ + 'scope' => 'default', + 'destination' => '/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (iOS).xcscheme', + 'template' => '/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (iOS).xcscheme', + ], + [ + 'scope' => 'default', + 'destination' => '/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (macOS).xcscheme', + 'template' => '/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (macOS).xcscheme', + ], + [ + 'scope' => 'default', + 'destination' => '/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (tvOS).xcscheme', + 'template' => '/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (tvOS).xcscheme', + ], + [ + 'scope' => 'default', + 'destination' => '/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (watchOS).xcscheme', + 'template' => '/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (watchOS).xcscheme', + ], [ 'scope' => 'default', 'destination' => '/example-swiftui/Example.xcodeproj/project.pbxproj', diff --git a/src/SDK/Language/Swift.php b/src/SDK/Language/Swift.php index 33e34f598..9b2e08798 100644 --- a/src/SDK/Language/Swift.php +++ b/src/SDK/Language/Swift.php @@ -206,8 +206,8 @@ public function getFiles(): array ], [ 'scope' => 'default', - 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/iOS/iOSDeviceInfo.swift', - 'template' => 'swift/Sources/DeviceInfo/iOS/iOSDeviceInfo.swift', + 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/iOS/IOSDeviceInfo.swift', + 'template' => 'swift/Sources/DeviceInfo/iOS/IOSDeviceInfo.swift', ], [ 'scope' => 'default', @@ -221,13 +221,23 @@ public function getFiles(): array ], [ 'scope' => 'default', - 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/MacOS/MacOSDeviceInfo.swift', - 'template' => 'swift/Sources/DeviceInfo/MacOS/MacOSDeviceInfo.swift', + 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/macOS/MacOSDeviceInfo.swift', + 'template' => 'swift/Sources/DeviceInfo/macOS/MacOSDeviceInfo.swift', ], [ 'scope' => 'default', - 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/MacOS/CwlSysCtl.swift', - 'template' => 'swift/Sources/DeviceInfo/MacOS/CwlSysCtl.swift', + 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/watchOS/WatchOSDeviceInfo.swift', + 'template' => 'swift/Sources/DeviceInfo/watchOS/WatchOSDeviceInfo.swift', + ], + [ + 'scope' => 'default', + 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/watchOS/WKInterfaceDevice+ModelName.swift', + 'template' => 'swift/Sources/DeviceInfo/watchOS/WKInterfaceDevice+ModelName.swift', + ], + [ + 'scope' => 'default', + 'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/macOS/CwlSysCtl.swift', + 'template' => 'swift/Sources/DeviceInfo/macOS/CwlSysCtl.swift', ], [ 'scope' => 'default', diff --git a/templates/swift/Package.swift.twig b/templates/swift/Package.swift.twig index abc81243c..0204ec6f2 100644 --- a/templates/swift/Package.swift.twig +++ b/templates/swift/Package.swift.twig @@ -7,7 +7,7 @@ let package = Package( platforms: [ .iOS("15.0"), .macOS("11.0"), - .watchOS("6.0"), + .watchOS("7.0"), .tvOS("13.0"), ], products: [ diff --git a/templates/swift/Sources/Client.swift.twig b/templates/swift/Sources/Client.swift.twig index 00beb34f4..db36c208f 100644 --- a/templates/swift/Sources/Client.swift.twig +++ b/templates/swift/Sources/Client.swift.twig @@ -562,10 +562,10 @@ extension Client { device = "\(info!.modelIdentifier) iOS/\(info!.systemVersion)" #elseif os(watchOS) let info = deviceInfo.watchOSInfo - device = "\(info!.systemInfo.machine) watchOS/\(info!.systemVersion)" + device = "\(info!.modelIdentifier) watchOS/\(info!.systemVersion)" #elseif os(tvOS) - let info = deviceInfo.tvOSInfo - device = "\(info!.systemInfo.machine) tvOS/\(info!.systemVersion)" + let info = deviceInfo.iOSInfo + device = "\(info!.modelIdentifier) tvOS/\(info!.systemVersion)" #elseif os(macOS) let info = deviceInfo.macOSInfo device = "(Macintosh; \(info!.model))" diff --git a/templates/swift/Sources/DeviceInfo/Linux/LinuxDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/Linux/LinuxDeviceInfo.swift index cd29eae69..bc03292fd 100644 --- a/templates/swift/Sources/DeviceInfo/Linux/LinuxDeviceInfo.swift +++ b/templates/swift/Sources/DeviceInfo/Linux/LinuxDeviceInfo.swift @@ -1,7 +1,7 @@ #if os(Linux) import Foundation -class LinuxDeviceInfo : DeviceInfo { +class LinuxDeviceInfo { let name: String let version: String @@ -14,53 +14,24 @@ class LinuxDeviceInfo : DeviceInfo { let variant: String let variantId: String let machineId: String - - internal init( - name: String, - version: String, - id: String, - idLike: [String], - versionCodename: String, - versionId: String, - prettyName: String, - buildId: String, - variant: String, - variantId: String, - machineId: String - ) { - self.name = name - self.version = version - self.id = id - self.idLike = idLike - self.versionCodename = versionCodename - self.versionId = versionId - self.prettyName = prettyName - self.buildId = buildId - self.variant = variant - self.variantId = variantId - self.machineId = machineId - } - - public static func get() -> LinuxDeviceInfo { - let os = getOsRelease() - let lsb = getLsbRelease() - let machineId = getMachineId() - - return LinuxDeviceInfo( - name: os["NAME"] ?? "Linux", - version: os["VERSION"] ?? lsb["LSB_VERSION"] ?? "", - id: os["ID"] ?? lsb["DISTRIB_ID"] ?? "linux", - idLike: os["ID_LIKE"]?.split(separator: " ").map { String($0) } ?? [], - versionCodename: os["VERSION_CODENAME"] ?? lsb["DISTRIB_CODENAME"] ?? "", - versionId: os["VERSION_ID"] ?? lsb["DISTRIB_RELEASE"] ?? "", - prettyName: os["PRETTY_NAME"] ?? lsb["DISTRIB_DESCRIPTION"] ?? "Linux", - buildId: os["BUILD_ID"] ?? "", - variant: os["VARIANT"] ?? "", - variantId: os["VARIANT_ID"] ?? "", - machineId: machineId - ) + + public init() { + let os = LinuxDeviceInfo.getOsRelease() + let lsb = LinuxDeviceInfo.getLsbRelease() + + name = os["NAME"] ?? "Linux" + version = os["VERSION"] ?? lsb["LSB_VERSION"] ?? "" + id = os["ID"] ?? lsb["DISTRIB_ID"] ?? "linux" + idLike = os["ID_LIKE"]?.split(separator: " ").map { String($0) } ?? [] + versionCodename = os["VERSION_CODENAME"] ?? lsb["DISTRIB_CODENAME"] ?? "" + versionId = os["VERSION_ID"] ?? lsb["DISTRIB_RELEASE"] ?? "" + prettyName = os["PRETTY_NAME"] ?? lsb["DISTRIB_DESCRIPTION"] ?? "Linux" + buildId = os["BUILD_ID"] ?? "" + variant = os["VARIANT"] ?? "" + variantId = os["VARIANT_ID"] ?? "" + machineId = LinuxDeviceInfo.getMachineId() } - + private static func getOsRelease() -> [String: String] { return tryReadKeyValues(path: "/etc/os-release") } @@ -82,19 +53,19 @@ class LinuxDeviceInfo : DeviceInfo { let url = URL(fileURLWithPath: path) let string = try! String(contentsOf: url, encoding: .utf8) let lines = string.components(separatedBy: .newlines) - + var dict = [String: String]() for line in lines { let splits = line.split(separator: "=") if splits.count > 1 { let key = String(splits[0]) let value = String(splits[1]) - + dict[key] = value } } - + return dict } } -#endif \ No newline at end of file +#endif diff --git a/templates/swift/Sources/DeviceInfo/MacOS/MacOSDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/MacOS/MacOSDeviceInfo.swift deleted file mode 100644 index fe9610a12..000000000 --- a/templates/swift/Sources/DeviceInfo/MacOS/MacOSDeviceInfo.swift +++ /dev/null @@ -1,17 +0,0 @@ -#if os(macOS) -import Foundation - -class MacOSDeviceInfo : DeviceInfo { - let computerName = Sysctl.hostName - let hostName = Sysctl.osType - let arch = Sysctl.machine - let model = Sysctl.model - let kernelVersion = Sysctl.version - let osRelease = Sysctl.osRelease - let activeCPUs = Sysctl.activeCPUs - - public static func get() -> MacOSDeviceInfo { - return MacOSDeviceInfo() - } -} -#endif diff --git a/templates/swift/Sources/DeviceInfo/OSDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/OSDeviceInfo.swift index 09509e110..9b7d51d93 100644 --- a/templates/swift/Sources/DeviceInfo/OSDeviceInfo.swift +++ b/templates/swift/Sources/DeviceInfo/OSDeviceInfo.swift @@ -1,11 +1,11 @@ import Foundation -protocol DeviceInfo {} - class OSDeviceInfo { - #if os(iOS) || os(watchOS) || os(tvOS) - var iOSInfo: iOSDeviceInfo? + #if os(iOS) || os(tvOS) + var iOSInfo: IOSDeviceInfo? + #elseif os(watchOS) + var watchOSInfo: WatchOSDeviceInfo? #elseif os(macOS) var macOSInfo: MacOSDeviceInfo? #elseif os(Linux) @@ -15,14 +15,16 @@ class OSDeviceInfo { #endif init() { - #if os(iOS) || os(watchOS) || os(tvOS) - self.iOSInfo = iOSDeviceInfo.get() + #if os(iOS) || os(tvOS) + self.iOSInfo = IOSDeviceInfo() + #elseif os(watchOS) + self.watchOSInfo = WatchOSDeviceInfo() #elseif os(macOS) - self.macOSInfo = MacOSDeviceInfo.get() + self.macOSInfo = MacOSDeviceInfo() #elseif os(Linux) - self.linuxInfo = LinuxDeviceInfo.get() + self.linuxInfo = LinuxDeviceInfo() #elseif os(Windows) - self.windowsInfo = LinuxDeviceInfo.get() + self.windowsInfo = LinuxDeviceInfo() #endif } } diff --git a/templates/swift/Sources/DeviceInfo/Windows/WindowsDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/Windows/WindowsDeviceInfo.swift index d43b8a9fc..435def8b8 100644 --- a/templates/swift/Sources/DeviceInfo/Windows/WindowsDeviceInfo.swift +++ b/templates/swift/Sources/DeviceInfo/Windows/WindowsDeviceInfo.swift @@ -1,31 +1,16 @@ #if os(Windows) import Foundation -class WindowsDeviceInfo : DeviceInfo { - +class WindowsDeviceInfo { + let numberOfCores: String let computerName: String let systemMemoryInMegabytes: UInt64 - - public init( - numberOfCores: String, - computerName: String, - systemMemoryInMegabytes: UInt64 - ) { - self.numberOfCores = numberOfCores - self.computerName = computerName - self.systemMemoryInMegabytes = systemMemoryInMegabytes - } - public static func get() -> WindowsDeviceInfo { - let memory = ProcessInfo.processInfo.physicalMemory / 1000 / 1000 // Bytes to MB - - return WindowsDeviceInfo( - numberOfCores: ProcessInfo.processInfo.processorCount.description, - computerName: Host.current().localizedName ?? "", - systemMemoryInMegabytes: memory - ) + public init() { + numberOfCores = ProcessInfo.processInfo.processorCount.description + computerName = Host.current().localizedName ?? "" + systemMemoryInMegabytes = ProcessInfo.processInfo.physicalMemory / 1000 / 1000 // Bytes to MB } } -#endif - +#endif \ No newline at end of file diff --git a/templates/swift/Sources/DeviceInfo/iOS/IOSDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/iOS/IOSDeviceInfo.swift new file mode 100644 index 000000000..b9d9534d4 --- /dev/null +++ b/templates/swift/Sources/DeviceInfo/iOS/IOSDeviceInfo.swift @@ -0,0 +1,27 @@ +#if os(iOS) || os(tvOS) +import Foundation +import UIKit + +class IOSDeviceInfo { + + let name: String + let systemName: String + let systemVersion: String + let model: String + let localizedModel: String + let identifierForVendor: String + let modelIdentifier: String + + public init() { + let device = UIDevice.current + + name = device.name + systemName = device.systemName + systemVersion = device.systemVersion + model = device.model + localizedModel = device.localizedModel + identifierForVendor = device.identifierForVendor?.uuidString ?? "" + modelIdentifier = UIDevice.modelName + } +} +#endif diff --git a/templates/swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift b/templates/swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift index 18c8e41bd..38d7618a3 100644 --- a/templates/swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift +++ b/templates/swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift @@ -1,4 +1,4 @@ -#if os(iOS) || os(tvOS) || os(watchOS) +#if os(iOS) || os(tvOS) import Foundation import UIKit @@ -14,8 +14,8 @@ public extension UIDevice { } func mapToDevice(identifier: String) -> String { // swiftlint:disable:this cyclomatic_complexity - #if os(iOS) switch identifier { + #if os(iOS) case "iPod5,1": return "iPod touch (5th generation)" case "iPod7,1": return "iPod touch (6th generation)" case "iPod9,1": return "iPod touch (7th generation)" @@ -49,6 +49,11 @@ public extension UIDevice { case "iPhone14,5": return "iPhone 13" case "iPhone14,2": return "iPhone 13 Pro" case "iPhone14,3": return "iPhone 13 Pro Max" + case "iPhone14,6": return "iPhone SE (3rd generation)" + case "iPhone14,7": return "iPhone 14" + case "iPhone14,8": return "iPhone 14 Plus" + case "iPhone15,2": return "iPhone 14 Pro" + case "iPhone15,3": return "iPhone 14 Pro Max" case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4": return "iPad 2" case "iPad3,1", "iPad3,2", "iPad3,3": return "iPad (3rd generation)" case "iPad3,4", "iPad3,5", "iPad3,6": return "iPad (4th generation)" @@ -77,21 +82,19 @@ public extension UIDevice { case "iPad8,5", "iPad8,6", "iPad8,7", "iPad8,8": return "iPad Pro (12.9-inch) (3rd generation)" case "iPad8,11", "iPad8,12": return "iPad Pro (12.9-inch) (4th generation)" case "iPad13,8", "iPad13,9", "iPad13,10", "iPad13,11":return "iPad Pro (12.9-inch) (5th generation)" - case "AppleTV5,3": return "Apple TV" - case "AppleTV6,2": return "Apple TV 4K" - case "AudioAccessory1,1": return "HomePod" - case "AudioAccessory5,1": return "HomePod mini" case "i386", "x86_64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS"))" default: return identifier - } #elseif os(tvOS) - switch identifier { - case "AppleTV5,3": return "Apple TV 4" - case "AppleTV6,2": return "Apple TV 4K" + case "AppleTV1,1": return "Apple TV (1st generation)" + case "AppleTV2,1": return "Apple TV (2nd generation)" + case "AppleTV3,1", "AppleTV3,2": return "Apple TV (3rd generation)" + case "AppleTV5,3": return "Apple TV (4th generation)" + case "AppleTV6,2": return "Apple TV 4K (1st generation)" + case "AppleTV11,1": return "Apple TV 4K (2nd generation)" case "i386", "x86_64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "tvOS"))" default: return identifier - } #endif + } } return mapToDevice(identifier: identifier) diff --git a/templates/swift/Sources/DeviceInfo/iOS/iOSDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/iOS/iOSDeviceInfo.swift deleted file mode 100644 index c091e8d74..000000000 --- a/templates/swift/Sources/DeviceInfo/iOS/iOSDeviceInfo.swift +++ /dev/null @@ -1,47 +0,0 @@ -#if os(iOS) || os(tvOS) || os(watchOS) -import Foundation -import UIKit - -class iOSDeviceInfo : DeviceInfo { - - let name: String - let systemName: String - let systemVersion: String - let model: String - let localizedModel: String - let identifierForVendor: String - let modelIdentifier: String - - internal init( - name: String, - systemName: String, - systemVersion: String, - model: String, - localizedModel: String, - identifierForVendor: String, - modelIdentifier: String - ) { - self.name = name - self.systemName = systemName - self.systemVersion = systemVersion - self.model = model - self.localizedModel = localizedModel - self.identifierForVendor = identifierForVendor - self.modelIdentifier = modelIdentifier - } - - public static func get() -> iOSDeviceInfo { - let device = UIDevice.current - - return iOSDeviceInfo( - name: device.name, - systemName: device.systemName, - systemVersion: device.systemVersion, - model: device.model, - localizedModel: device.localizedModel, - identifierForVendor: device.identifierForVendor?.uuidString ?? "", - modelIdentifier: UIDevice.modelName - ) - } -} -#endif diff --git a/templates/swift/Sources/DeviceInfo/MacOS/CwlSysCtl.swift b/templates/swift/Sources/DeviceInfo/macOS/CwlSysCtl.swift similarity index 100% rename from templates/swift/Sources/DeviceInfo/MacOS/CwlSysCtl.swift rename to templates/swift/Sources/DeviceInfo/macOS/CwlSysCtl.swift diff --git a/templates/swift/Sources/DeviceInfo/macOS/MacOSDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/macOS/MacOSDeviceInfo.swift new file mode 100644 index 000000000..3f42abd09 --- /dev/null +++ b/templates/swift/Sources/DeviceInfo/macOS/MacOSDeviceInfo.swift @@ -0,0 +1,23 @@ +#if os(macOS) +import Foundation + +class MacOSDeviceInfo { + let computerName: String + let hostName: String + let arch: String + let model: String + let kernelVersion: String + let osRelease: String + let activeCPUs: Int + + public init() { + computerName = Sysctl.hostName + hostName = Sysctl.osType + arch = Sysctl.machine + model = Sysctl.model + kernelVersion = Sysctl.version + osRelease = Sysctl.osRelease + activeCPUs = Int(Sysctl.activeCPUs) + } +} +#endif diff --git a/templates/swift/Sources/DeviceInfo/watchOS/WKInterfaceDevice+ModelName.swift b/templates/swift/Sources/DeviceInfo/watchOS/WKInterfaceDevice+ModelName.swift new file mode 100644 index 000000000..bf047bd13 --- /dev/null +++ b/templates/swift/Sources/DeviceInfo/watchOS/WKInterfaceDevice+ModelName.swift @@ -0,0 +1,65 @@ +#if os(watchOS) +import Foundation +import WatchKit + +public extension WKInterfaceDevice { + + static let modelName: String = { + var systemInfo = utsname() + uname(&systemInfo) + let machineMirror = Mirror(reflecting: systemInfo.machine) + let identifier = machineMirror.children.reduce("") { identifier, element in + guard let value = element.value as? Int8, value != 0 else { return identifier } + return identifier + String(UnicodeScalar(UInt8(value))) + } + + func mapToDevice(identifier: String) -> String { + switch identifier { + case "Watch1,1": return "Apple Watch Series 0 38mm" + case "Watch1,2": return"Apple Watch Series 0 42mm" + case "Watch2,3": return "Apple Watch Series 2 38mm" + case "Watch2,4": return "Apple Watch Series 2 42mmm" + case "Watch2,6": return "Apple Watch Series 1 38mm" + case "Watch2,7": return "Apple Watch Series 1 42mm" + case "Watch3,1": return "Apple Watch Series 3 38mm Cellular" + case "Watch3,2": return "Apple Watch Series 3 42mm Cellular" + case "Watch3,3": return "Apple Watch Series 3 38mm" + case "Watch3,4": return "Apple Watch Series 3 42mm" + case "Watch4,1": return "Apple Watch Series 4 40mm" + case "Watch4,2": return "Apple Watch Series 4 44mm" + case "Watch4,3": return "Apple Watch Series 4 40mm Cellular" + case "Watch4,4": return "Apple Watch Series 4 44mm Cellular" + case "Watch5,1": return "Apple Watch Series 5 40mm" + case "Watch5,2": return "Apple Watch Series 5 44mm" + case "Watch5,3": return "Apple Watch Series 5 40mm Cellular" + case "Watch5,4": return "Apple Watch Series 5 44mm Cellular" + case "Watch5,9": return "Apple Watch SE 40mm" + case "Watch5,10": return "Apple Watch SE 44mm" + case "Watch5,11": return "Apple Watch SE 40mm Cellular" + case "Watch5,12": return "Apple Watch SE 44mm Cellular" + case "Watch6,1": return "Apple Watch Series 6 40mm" + case "Watch6,2": return "Apple Watch Series 6 44mm" + case "Watch6.3": return "Apple Watch Series 6 40mm Cellular" + case "Watch6,4": return "Apple Watch Series 6 44mm Cellular" + case "Watch6,6": return "Apple Watch Series 7 41mm" + case "Watch6,7": return "Apple Watch Series 7 45mm" + case "Watch6,8": return "Apple Watch Series 7 41mm Cellular" + case "Watch6,9": return "Apple Watch Series 7 45mm Cellular" + case "Watch6,10": return "Apple Watch SE (2nd generation) 41mm" + case "Watch6,11": return "Apple Watch SE (2nd generation) 45mm" + case "Watch6,12": return "Apple Watch SE (2nd generation) 41mm Cellular" + case "Watch6,13": return "Apple Watch SE (2nd generation) 45mm Cellular" + case "Watch6,14": return "Apple Watch Series 8 41mm" + case "Watch6,15": return "Apple Watch Series 8 45mm" + case "Watch6,16": return "Apple Watch Series 8 41mm Cellular" + case "Watch6,17": return "Apple Watch Series 8 45mm Cellular" + case "Watch6,18": return "Apple Watch Ultra" + default: return "unknown" + } + } + + return mapToDevice(identifier: identifier) + }() + +} +#endif diff --git a/templates/swift/Sources/DeviceInfo/watchOS/WatchOSDeviceInfo.swift b/templates/swift/Sources/DeviceInfo/watchOS/WatchOSDeviceInfo.swift new file mode 100644 index 000000000..0e88af9c6 --- /dev/null +++ b/templates/swift/Sources/DeviceInfo/watchOS/WatchOSDeviceInfo.swift @@ -0,0 +1,27 @@ +#if os(watchOS) +import Foundation +import WatchKit + +class WatchOSDeviceInfo { + + let name: String + let systemName: String + let systemVersion: String + let model: String + let localizedModel: String + let identifierForVendor: String + let modelIdentifier: String + + public init() { + let device = WKInterfaceDevice.current() + + name = device.name + systemName = device.systemName + systemVersion = device.systemVersion + model = device.model + localizedModel = device.localizedModel + identifierForVendor = device.identifierForVendor?.uuidString ?? "" + modelIdentifier = WKInterfaceDevice.modelName + } +} +#endif diff --git a/templates/swift/Sources/OAuth/View+OAuth.swift.twig b/templates/swift/Sources/OAuth/View+OAuth.swift.twig index 7d6686364..6285df048 100644 --- a/templates/swift/Sources/OAuth/View+OAuth.swift.twig +++ b/templates/swift/Sources/OAuth/View+OAuth.swift.twig @@ -2,10 +2,14 @@ typealias OSApplication = NSApplication typealias OSViewController = NSViewController let notificationType = NSApplication.willBecomeActiveNotification -#elseif os(iOS) || os(tvOS) || os(watchOS) +#elseif os(iOS) || os(tvOS) typealias OSApplication = UIApplication typealias OSViewController = UIViewController let notificationType = UIApplication.willEnterForegroundNotification +#elseif os(watchOS) +typealias OSApplication = WKApplication +typealias OSViewController = WKInterfaceController +let notificationType = WKApplication.willEnterForegroundNotification #endif #if canImport(SwiftUI) diff --git a/templates/swift/example-swiftui/Example.xcodeproj/project.pbxproj b/templates/swift/example-swiftui/Example.xcodeproj/project.pbxproj index d951b81fa..c9bf53166 100644 --- a/templates/swift/example-swiftui/Example.xcodeproj/project.pbxproj +++ b/templates/swift/example-swiftui/Example.xcodeproj/project.pbxproj @@ -7,11 +7,25 @@ objects = { /* Begin PBXBuildFile section */ + 1D0647F32991E0CC00ADFADC /* OSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23DDF597270AC2DA006EFAFA /* OSImage.swift */; }; + 1D0647F42991E0CC00ADFADC /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E30BB26B9430D002ECB40 /* ExampleApp.swift */; }; + 1D0647F52991E0CC00ADFADC /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43900726FC8B2500C71E3E /* ImagePicker.swift */; }; + 1D0647F62991E0CC00ADFADC /* ExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2522702E4A000D1DA8D /* ExampleViewModel.swift */; }; + 1D0647F72991E0CC00ADFADC /* ExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2542702E4B500D1DA8D /* ExampleView.swift */; }; + 1D0647F92991E16D00ADFADC /* Appwrite in Frameworks */ = {isa = PBXBuildFile; productRef = 1D0647F82991E16D00ADFADC /* Appwrite */; }; + 1D0647FA2991E17900ADFADC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B115883E8645C18835765B2 /* Assets.xcassets */; }; 1D0E30BC26B9430D002ECB40 /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E30BB26B9430D002ECB40 /* ExampleApp.swift */; }; 1D0E30BD26B9430D002ECB40 /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E30BB26B9430D002ECB40 /* ExampleApp.swift */; }; 1D34C2532702E4A000D1DA8D /* ExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2522702E4A000D1DA8D /* ExampleViewModel.swift */; }; 1D34C2552702E4B500D1DA8D /* ExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2542702E4B500D1DA8D /* ExampleView.swift */; }; 1D43900826FC8B2500C71E3E /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43900726FC8B2500C71E3E /* ImagePicker.swift */; }; + 1D54698A29932D9100AAB591 /* Appwrite in Frameworks */ = {isa = PBXBuildFile; productRef = 1D54698929932D9100AAB591 /* Appwrite */; }; + 1D54698D29932DF900AAB591 /* OSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23DDF597270AC2DA006EFAFA /* OSImage.swift */; }; + 1D54698E29932DF900AAB591 /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E30BB26B9430D002ECB40 /* ExampleApp.swift */; }; + 1D54698F29932DF900AAB591 /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43900726FC8B2500C71E3E /* ImagePicker.swift */; }; + 1D54699029932DF900AAB591 /* ExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2522702E4A000D1DA8D /* ExampleViewModel.swift */; }; + 1D54699129932DF900AAB591 /* ExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2542702E4B500D1DA8D /* ExampleView.swift */; }; + 1D54699229932E0500AAB591 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B115883E8645C18835765B2 /* Assets.xcassets */; }; 1DBB414827E87CA000ECF86F /* Appwrite in Frameworks */ = {isa = PBXBuildFile; productRef = 1DBB414727E87CA000ECF86F /* Appwrite */; }; 1DBB414A27E87CA800ECF86F /* Appwrite in Frameworks */ = {isa = PBXBuildFile; productRef = 1DBB414927E87CA800ECF86F /* Appwrite */; }; 2358B1EE270AC9DC0016EFBA /* ExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D34C2522702E4A000D1DA8D /* ExampleViewModel.swift */; }; @@ -29,6 +43,20 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 1D0647D72991E01D00ADFADC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4B115A97BA5CA0A597279577 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1D0647BC2991E01C00ADFADC; + remoteInfo = Test; + }; + 1D54697529932D3700AAB591 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4B115A97BA5CA0A597279577 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1D54695729932D3500AAB591; + remoteInfo = "test Watch App"; + }; 4B11523A6CB24B030BAD7AC4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4B115A97BA5CA0A597279577 /* Project object */; @@ -46,11 +74,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1D0647BD2991E01C00ADFADC /* test (tvOS).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "test (tvOS).app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D0647D62991E01D00ADFADC /* Tests tvOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Tests tvOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 1D0E30BB26B9430D002ECB40 /* ExampleApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = ""; }; 1D34C2522702E4A000D1DA8D /* ExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewModel.swift; sourceTree = ""; }; 1D34C2542702E4B500D1DA8D /* ExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleView.swift; sourceTree = ""; }; 1D43900726FC8B2500C71E3E /* ImagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePicker.swift; sourceTree = ""; }; - 1DBB414627E87BDB00ECF86F /* apple */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "apple"; path = "../../../examples/apple"; sourceTree = ""; }; + 1D54695829932D3500AAB591 /* test (watchOS).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "test (watchOS).app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D54697429932D3700AAB591 /* Test watchOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Test watchOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1DBB414627E87BDB00ECF86F /* apple */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = apple; path = ../../../examples/apple; sourceTree = ""; }; 23DDF5922709A457006EFAFA /* ImagePicker+iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ImagePicker+iOS.swift"; sourceTree = ""; }; 23DDF5942709A46A006EFAFA /* ImagePicker+macOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ImagePicker+macOS.swift"; sourceTree = ""; }; 23DDF597270AC2DA006EFAFA /* OSImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSImage.swift; sourceTree = ""; }; @@ -70,6 +102,36 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 1D0647BA2991E01C00ADFADC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D0647F92991E16D00ADFADC /* Appwrite in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D0647D32991E01D00ADFADC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D54695529932D3500AAB591 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D54698A29932D9100AAB591 /* Appwrite in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D54697129932D3700AAB591 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 4B11576DE1A4F215102AF056 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -103,6 +165,20 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1D0647F22991E06E00ADFADC /* tvOS */ = { + isa = PBXGroup; + children = ( + ); + path = tvOS; + sourceTree = ""; + }; + 1D54698C29932DD300AAB591 /* watchOS */ = { + isa = PBXGroup; + children = ( + ); + path = watchOS; + sourceTree = ""; + }; 1DBB414527E87BDB00ECF86F /* Packages */ = { isa = PBXGroup; children = ( @@ -134,6 +210,8 @@ 4B11566FD1E1FA1ABD88E438 /* Shared */, 4B115E925CD74030DFF6498C /* iOS */, 4B115909955A1ABEA1A8A456 /* macOS */, + 1D0647F22991E06E00ADFADC /* tvOS */, + 1D54698C29932DD300AAB591 /* watchOS */, 4B115C8820DA716164AC3081 /* Tests iOS */, 4B11573D106E5B7B7D944C97 /* Tests macOS */, 1DC4093526BA6E7A0025A85C /* Frameworks */, @@ -179,6 +257,10 @@ 4B11505C9899942E695B59FF /* test.app */, 4B115D7F73BEBBFC0952D71E /* Tests iOS.xctest */, 4B115D8A84F1369173AA102E /* Tests macOS.xctest */, + 1D0647BD2991E01C00ADFADC /* test (tvOS).app */, + 1D0647D62991E01D00ADFADC /* Tests tvOS.xctest */, + 1D54695829932D3500AAB591 /* test (watchOS).app */, + 1D54697429932D3700AAB591 /* Test watchOS.xctest */, ); name = Products; sourceTree = ""; @@ -205,6 +287,82 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 1D0647BC2991E01C00ADFADC /* test (tvOS) */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D0647E42991E01D00ADFADC /* Build configuration list for PBXNativeTarget "test (tvOS)" */; + buildPhases = ( + 1D0647B92991E01C00ADFADC /* Sources */, + 1D0647BA2991E01C00ADFADC /* Frameworks */, + 1D0647BB2991E01C00ADFADC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "test (tvOS)"; + packageProductDependencies = ( + 1D0647F82991E16D00ADFADC /* Appwrite */, + ); + productName = Test; + productReference = 1D0647BD2991E01C00ADFADC /* test (tvOS).app */; + productType = "com.apple.product-type.application"; + }; + 1D0647D52991E01D00ADFADC /* Tests tvOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D0647E62991E01D00ADFADC /* Build configuration list for PBXNativeTarget "Tests tvOS" */; + buildPhases = ( + 1D0647D22991E01D00ADFADC /* Sources */, + 1D0647D32991E01D00ADFADC /* Frameworks */, + 1D0647D42991E01D00ADFADC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 1D0647D82991E01D00ADFADC /* PBXTargetDependency */, + ); + name = "Tests tvOS"; + productName = TestUITests; + productReference = 1D0647D62991E01D00ADFADC /* Tests tvOS.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; + 1D54695729932D3500AAB591 /* test (watchOS) */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D54697C29932D3700AAB591 /* Build configuration list for PBXNativeTarget "test (watchOS)" */; + buildPhases = ( + 1D54695429932D3500AAB591 /* Sources */, + 1D54695529932D3500AAB591 /* Frameworks */, + 1D54695629932D3500AAB591 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "test (watchOS)"; + packageProductDependencies = ( + 1D54698929932D9100AAB591 /* Appwrite */, + ); + productName = "test Watch App"; + productReference = 1D54695829932D3500AAB591 /* test (watchOS).app */; + productType = "com.apple.product-type.application"; + }; + 1D54697329932D3700AAB591 /* Test watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D54698629932D3700AAB591 /* Build configuration list for PBXNativeTarget "Test watchOS" */; + buildPhases = ( + 1D54697029932D3700AAB591 /* Sources */, + 1D54697129932D3700AAB591 /* Frameworks */, + 1D54697229932D3700AAB591 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 1D54697629932D3700AAB591 /* PBXTargetDependency */, + ); + name = "Test watchOS"; + productName = "test Watch AppUITests"; + productReference = 1D54697429932D3700AAB591 /* Test watchOS.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; 4B1155899FD4139AFC990F38 /* test (iOS) */ = { isa = PBXNativeTarget; buildConfigurationList = 4B11590F5ECAF18BA0C4D004 /* Build configuration list for PBXNativeTarget "test (iOS)" */; @@ -287,7 +445,22 @@ 4B115A97BA5CA0A597279577 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 1410; TargetAttributes = { + 1D0647BC2991E01C00ADFADC = { + CreatedOnToolsVersion = 14.1; + }; + 1D0647D52991E01D00ADFADC = { + CreatedOnToolsVersion = 14.1; + TestTargetID = 1D0647BC2991E01C00ADFADC; + }; + 1D54695729932D3500AAB591 = { + CreatedOnToolsVersion = 14.1; + }; + 1D54697329932D3700AAB591 = { + CreatedOnToolsVersion = 14.1; + TestTargetID = 1D54695729932D3500AAB591; + }; 4B115DB67D85396641A5CF4E = { TestTargetID = 4B115947BBA7BA3BBD6D5A40; }; @@ -311,13 +484,47 @@ targets = ( 4B1155899FD4139AFC990F38 /* test (iOS) */, 4B115947BBA7BA3BBD6D5A40 /* test (macOS) */, + 1D0647BC2991E01C00ADFADC /* test (tvOS) */, + 1D54695729932D3500AAB591 /* test (watchOS) */, 4B115F7D5C1CD078034D7A09 /* Tests iOS */, 4B115DB67D85396641A5CF4E /* Tests macOS */, + 1D0647D52991E01D00ADFADC /* Tests tvOS */, + 1D54697329932D3700AAB591 /* Test watchOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 1D0647BB2991E01C00ADFADC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D0647FA2991E17900ADFADC /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D0647D42991E01D00ADFADC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D54695629932D3500AAB591 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D54699229932E0500AAB591 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D54697229932D3700AAB591 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 4B1156C121304167FFE7C362 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -351,6 +558,44 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 1D0647B92991E01C00ADFADC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D0647F32991E0CC00ADFADC /* OSImage.swift in Sources */, + 1D0647F42991E0CC00ADFADC /* ExampleApp.swift in Sources */, + 1D0647F52991E0CC00ADFADC /* ImagePicker.swift in Sources */, + 1D0647F62991E0CC00ADFADC /* ExampleViewModel.swift in Sources */, + 1D0647F72991E0CC00ADFADC /* ExampleView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D0647D22991E01D00ADFADC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D54695429932D3500AAB591 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D54698D29932DF900AAB591 /* OSImage.swift in Sources */, + 1D54698E29932DF900AAB591 /* ExampleApp.swift in Sources */, + 1D54698F29932DF900AAB591 /* ImagePicker.swift in Sources */, + 1D54699029932DF900AAB591 /* ExampleViewModel.swift in Sources */, + 1D54699129932DF900AAB591 /* ExampleView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1D54697029932D3700AAB591 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 4B1151AF07540208EF7F3E5C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -397,6 +642,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 1D0647D82991E01D00ADFADC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1D0647BC2991E01C00ADFADC /* test (tvOS) */; + targetProxy = 1D0647D72991E01D00ADFADC /* PBXContainerItemProxy */; + }; + 1D54697629932D3700AAB591 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1D54695729932D3500AAB591 /* test (watchOS) */; + targetProxy = 1D54697529932D3700AAB591 /* PBXContainerItemProxy */; + }; 4B11572E06C4F4CE6D776194 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4B1155899FD4139AFC990F38 /* test (iOS) */; @@ -410,6 +665,202 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + 1D0647DE2991E01D00ADFADC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.appwrite.tvos; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 16.1; + }; + name = Debug; + }; + 1D0647DF2991E01D00ADFADC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.appwrite.tvos; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 16.1; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1D0647E22991E01D00ADFADC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.appwrite.tvos.TestUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + TEST_TARGET_NAME = Test; + TVOS_DEPLOYMENT_TARGET = 16.1; + }; + name = Debug; + }; + 1D0647E32991E01D00ADFADC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.appwrite.tvos.TestUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + TEST_TARGET_NAME = Test; + TVOS_DEPLOYMENT_TARGET = 16.1; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1D54697D29932D3700AAB591 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_CFBundleDisplayName = test; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_WKWatchOnly = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.appwrite.watchos; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 9.1; + }; + name = Debug; + }; + 1D54697E29932D3700AAB591 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_CFBundleDisplayName = test; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_WKWatchOnly = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.appwrite.watchos; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + VALIDATE_PRODUCT = YES; + WATCHOS_DEPLOYMENT_TARGET = 9.1; + }; + name = Release; + }; + 1D54698729932D3700AAB591 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "io.appwrite.watchos.test-Watch-AppUITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + TEST_TARGET_NAME = "test Watch App"; + WATCHOS_DEPLOYMENT_TARGET = 9.1; + }; + name = Debug; + }; + 1D54698829932D3700AAB591 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "io.appwrite.watchos.test-Watch-AppUITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + TEST_TARGET_NAME = "test Watch App"; + VALIDATE_PRODUCT = YES; + WATCHOS_DEPLOYMENT_TARGET = 9.1; + }; + name = Release; + }; 4B1152AEF1E176405C2195FF /* Release */ = { isa = XCBuildConfiguration; buildSettings = { @@ -675,6 +1126,42 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 1D0647E42991E01D00ADFADC /* Build configuration list for PBXNativeTarget "test (tvOS)" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D0647DE2991E01D00ADFADC /* Debug */, + 1D0647DF2991E01D00ADFADC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1D0647E62991E01D00ADFADC /* Build configuration list for PBXNativeTarget "Tests tvOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D0647E22991E01D00ADFADC /* Debug */, + 1D0647E32991E01D00ADFADC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1D54697C29932D3700AAB591 /* Build configuration list for PBXNativeTarget "test (watchOS)" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D54697D29932D3700AAB591 /* Debug */, + 1D54697E29932D3700AAB591 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1D54698629932D3700AAB591 /* Build configuration list for PBXNativeTarget "Test watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D54698729932D3700AAB591 /* Debug */, + 1D54698829932D3700AAB591 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 4B1150C5B56EC2962831BA91 /* Build configuration list for PBXNativeTarget "test (macOS)" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -723,6 +1210,14 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ + 1D0647F82991E16D00ADFADC /* Appwrite */ = { + isa = XCSwiftPackageProductDependency; + productName = Appwrite; + }; + 1D54698929932D9100AAB591 /* Appwrite */ = { + isa = XCSwiftPackageProductDependency; + productName = Appwrite; + }; 1DBB414727E87CA000ECF86F /* Appwrite */ = { isa = XCSwiftPackageProductDependency; productName = Appwrite; diff --git a/templates/swift/example-swiftui/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/templates/swift/example-swiftui/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5f053b9e3..9634ad4be 100644 --- a/templates/swift/example-swiftui/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/templates/swift/example-swiftui/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,26 @@ "repositoryURL": "https://github.com/swift-server/async-http-client.git", "state": { "branch": null, - "revision": "7a4dfe026f6ee0f8ad741b58df74c60af296365d", - "version": "1.9.0" + "revision": "7f05a8da46cc2a4ab43218722298b81ac7a08031", + "version": "1.13.2" + } + }, + { + "package": "swift-atomics", + "repositoryURL": "https://github.com/apple/swift-atomics.git", + "state": { + "branch": null, + "revision": "ff3d2212b6b093db7f177d0855adbc4ef9c5f036", + "version": "1.0.3" + } + }, + { + "package": "swift-collections", + "repositoryURL": "https://github.com/apple/swift-collections.git", + "state": { + "branch": null, + "revision": "937e904258d22af6e447a0b72c0bc67583ef64a2", + "version": "1.0.4" } }, { @@ -15,8 +33,8 @@ "repositoryURL": "https://github.com/apple/swift-log.git", "state": { "branch": null, - "revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", - "version": "1.4.2" + "revision": "32e8d724467f8fe623624570367e3d50c5638e46", + "version": "1.5.2" } }, { @@ -24,8 +42,8 @@ "repositoryURL": "https://github.com/apple/swift-nio.git", "state": { "branch": null, - "revision": "154f1d32366449dcccf6375a173adf4ed2a74429", - "version": "2.38.0" + "revision": "45167b8006448c79dda4b7bd604e07a034c15c49", + "version": "2.48.0" } }, { @@ -33,8 +51,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-extras.git", "state": { "branch": null, - "revision": "f72c4688f89c28502105509186eadc49a49cb922", - "version": "1.10.0" + "revision": "91dd2d61fb772e1311bb5f13b59266b579d77e42", + "version": "1.15.0" } }, { @@ -42,8 +60,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-http2.git", "state": { "branch": null, - "revision": "ac2a5afce3dbb6795b4f78ec3f19726dc28f5617", - "version": "1.20.0" + "revision": "d6656967f33ed8b368b38e4b198631fc7c484a40", + "version": "1.23.1" } }, { @@ -51,8 +69,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-ssl.git", "state": { "branch": null, - "revision": "044f90dfa0a7015446b40f5e578b06343ae1affe", - "version": "2.16.0" + "revision": "4fb7ead803e38949eb1d6fabb849206a72c580f3", + "version": "2.23.0" } }, { @@ -60,8 +78,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-transport-services.git", "state": { "branch": null, - "revision": "8ab824b140d0ebcd87e9149266ddc353e3705a3e", - "version": "1.11.4" + "revision": "c0d9a144cfaec8d3d596aadde3039286a266c15c", + "version": "1.15.0" } } ] diff --git a/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (iOS).xcscheme b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (iOS).xcscheme new file mode 100644 index 000000000..1559be1ac --- /dev/null +++ b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (iOS).xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (macOS).xcscheme b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (macOS).xcscheme new file mode 100644 index 000000000..ae4642390 --- /dev/null +++ b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (macOS).xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (tvOS).xcscheme b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (tvOS).xcscheme new file mode 100644 index 000000000..320c686e0 --- /dev/null +++ b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (tvOS).xcscheme @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (watchOS).xcscheme b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (watchOS).xcscheme new file mode 100644 index 000000000..c96ddb6a3 --- /dev/null +++ b/templates/swift/example-swiftui/Example.xcodeproj/xcshareddata/xcschemes/test (watchOS).xcscheme @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/swift/example-swiftui/Shared/ExampleView.swift b/templates/swift/example-swiftui/Shared/ExampleView.swift index f46be5515..c1a93e75e 100644 --- a/templates/swift/example-swiftui/Shared/ExampleView.swift +++ b/templates/swift/example-swiftui/Shared/ExampleView.swift @@ -17,7 +17,7 @@ struct ExampleView: View { .aspectRatio(contentMode: .fit) .frame(height: 200) - TextEditor(text: $viewModel.response) + TextField("", text: $viewModel.response) .padding() Button("Login") { @@ -44,16 +44,16 @@ struct ExampleView: View { viewModel.subscribe() } } + #if os(macOS) .onChange(of: viewModel.isShowPhotoLibrary) { showing in - #if os(macOS) ImagePicker.present() - #endif } + #endif + #if os(iOS) .sheet(isPresented: $viewModel.isShowPhotoLibrary) { - #if !os(macOS) ImagePicker(selectedImage: $imageToUpload) - #endif } + #endif .onChange(of: imageToUpload) { img in Task { await viewModel.upload(image: img) } } diff --git a/templates/swift/example-swiftui/Shared/ExampleViewModel.swift b/templates/swift/example-swiftui/Shared/ExampleViewModel.swift index 134938054..d3c0c1f02 100644 --- a/templates/swift/example-swiftui/Shared/ExampleViewModel.swift +++ b/templates/swift/example-swiftui/Shared/ExampleViewModel.swift @@ -25,6 +25,7 @@ extension ExampleView { @Published public var userId: String = "unique()" @Published public var bucketId: String = "test" @Published public var fileId: String = "test" + @Published public var databaseId: String = "test" @Published public var collectionId: String = "test" @Published public var isShowPhotoLibrary = false @Published public var response: String = "" @@ -105,7 +106,7 @@ extension ExampleView { } func subscribe() { - _ = realtime.subscribe(channels: ["collections.\(collectionId).documents"]) { event in + _ = realtime.subscribe(channels: ["databases.\(databaseId).collections.\(collectionId).documents"]) { event in DispatchQueue.main.async { self.response = String(describing: event.payload!) }