Skip to content

Commit e03038b

Browse files
committed
add vision os support
1 parent 68c9adb commit e03038b

File tree

9 files changed

+25
-16
lines changed

9 files changed

+25
-16
lines changed

templates/swift/Sources/Client.swift.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ extension Client {
578578
return "tvos"
579579
#elseif os(macOS)
580580
return "macos"
581+
#elseif os(visionOS)
582+
return "visionos"
581583
#elseif os(Linux)
582584
return "linux"
583585
#elseif os(Windows)
@@ -601,6 +603,9 @@ extension Client {
601603
#elseif os(macOS)
602604
let info = deviceInfo.macOSInfo
603605
device = "(Macintosh; \(info!.model))"
606+
#elseif os(visionOS)
607+
let info = deviceInfo.iOSInfo
608+
device = "\(info!.modelIdentifier) visionOS/\(info!.systemVersion)"
604609
#elseif os(Linux)
605610
let info = deviceInfo.linuxInfo
606611
device = "(Linux; U; \(info!.id) \(info!.version))"

templates/swift/Sources/DeviceInfo/OSDeviceInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
class OSDeviceInfo {
44

5-
#if os(iOS) || os(tvOS)
5+
#if os(iOS) || os(tvOS) || os(visionOS)
66
var iOSInfo: IOSDeviceInfo?
77
#elseif os(watchOS)
88
var watchOSInfo: WatchOSDeviceInfo?
@@ -15,7 +15,7 @@ class OSDeviceInfo {
1515
#endif
1616

1717
init() {
18-
#if os(iOS) || os(tvOS)
18+
#if os(iOS) || os(tvOS) || os(visionOS)
1919
self.iOSInfo = IOSDeviceInfo()
2020
#elseif os(watchOS)
2121
self.watchOSInfo = WatchOSDeviceInfo()

templates/swift/Sources/DeviceInfo/iOS/IOSDeviceInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if os(iOS) || os(tvOS)
1+
#if os(iOS) || os(tvOS) || os(visionOS)
22
import Foundation
33
import UIKit
44

templates/swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if os(iOS) || os(tvOS)
1+
#if os(iOS) || os(tvOS) || os(visionOS)
22
import Foundation
33
import UIKit
44

@@ -91,8 +91,12 @@ public extension UIDevice {
9191
case "AppleTV5,3": return "Apple TV (4th generation)"
9292
case "AppleTV6,2": return "Apple TV 4K (1st generation)"
9393
case "AppleTV11,1": return "Apple TV 4K (2nd generation)"
94-
case "i386", "x86_64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "tvOS"))"
95-
default: return identifier
94+
case "i386", "x86_64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "tvOS"))"
95+
default: return identifier
96+
#elseif os(visionOS)
97+
case "RealityDevice14,1": return "Apple Vision Pro"
98+
case "i386", "x86_64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "visionOS"))"
99+
default: return identifier
96100
#endif
97101
}
98102
}

templates/swift/Sources/OAuth/View+OAuth.swift.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
typealias OSApplication = NSApplication
33
typealias OSViewController = NSViewController
44
let notificationType = NSApplication.willBecomeActiveNotification
5-
#elseif os(iOS) || os(tvOS)
5+
#elseif os(iOS) || os(tvOS) || os(visionOS)
66
typealias OSApplication = UIApplication
77
typealias OSViewController = UIViewController
88
let notificationType = UIApplication.willEnterForegroundNotification
@@ -14,7 +14,7 @@ let notificationType = WKApplication.willEnterForegroundNotification
1414

1515
#if canImport(SwiftUI)
1616
import SwiftUI
17-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
17+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, visionOS 1.0, *)
1818
extension View {
1919
public func registerOAuthHandler() -> some View {
2020
onOpenURL { url in
@@ -27,12 +27,12 @@ extension View {
2727
#endif
2828

2929
#if canImport(OSViewController)
30-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
30+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, visionOS 1.0, *)
3131
extension OSViewController {
3232
public func registerOAuthHandler() {
3333
#if os(macOS)
3434
typealias OSHostingController = NSHostingController
35-
#elseif os(iOS) || os(tvOS) || os(watchOS)
35+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
3636
typealias OSHostingController = UIHostingController
3737
#endif
3838
self.addChild(OSHostingController(rootView: EmptyView().registerOAuthHandler()))

templates/swift/Sources/OAuth/WebAuthComponent.swift.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SwiftUI
1010
/// Used to authenticate with external OAuth2 providers. Launches browser windows and handles
1111
/// suspension until the user completes the process or otherwise returns to the app.
1212
///
13-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
13+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, visionOS 1.0, *)
1414
public class WebAuthComponent {
1515

1616
#if canImport(SwiftUI)

templates/swift/Sources/PackageInfo/OSPackageInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Foundation
33
class OSPackageInfo {
44

55
public static func get() -> PackageInfo {
6-
#if os(iOS) || os(watchOS) || os(tvOS) || os(macOS)
6+
#if os(iOS) || os(watchOS) || os(tvOS) || os(macOS) || os(visionOS)
77
return PackageInfo.getApplePackage()
88
#elseif os(Linux)
99
return PackageInfo.getLinuxPackage()

templates/swift/example-swiftui/Shared/ExampleView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct ExampleView: View {
4949
ImagePicker.present()
5050
}
5151
#endif
52-
#if os(iOS)
52+
#if os(iOS) || os(visionOS)
5353
.sheet(isPresented: $viewModel.isShowPhotoLibrary) {
5454
ImagePicker(selectedImage: $imageToUpload)
5555
}

templates/swift/example-swiftui/Shared/Image/OSImage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SwiftUI
99
#if os(macOS)
1010
import AppKit
1111
public typealias OSImage = NSImage
12-
#elseif os(iOS) || os(tvOS) || os(watchOS)
12+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
1313
import UIKit
1414
public typealias OSImage = UIImage
1515
#endif
@@ -18,7 +18,7 @@ extension Image {
1818
public init(data: Data) {
1919
#if os(macOS)
2020
self.init(nsImage: NSImage(data: data)!)
21-
#elseif os(iOS) || os(tvOS) || os(watchOS)
21+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
2222
self.init(uiImage: UIImage(data: data)!)
2323
#endif
2424
}
@@ -28,7 +28,7 @@ extension OSImage {
2828
public var data: Data {
2929
#if os(macOS)
3030
return self.tiffRepresentation!
31-
#elseif os(iOS) || os(tvOS) || os(watchOS)
31+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
3232
return self.pngData()!
3333
#endif
3434
}

0 commit comments

Comments
 (0)