Skip to content

Commit 51912b3

Browse files
authored
Merge pull request #777 from svenopdehipt/master
Add support for vision os and fix warnings & errors
2 parents 692c222 + 37c7e46 commit 51912b3

File tree

11 files changed

+31
-18
lines changed

11 files changed

+31
-18
lines changed

templates/apple/Sources/Client.swift.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ extension Client {
542542
return "tvos"
543543
#elseif os(macOS)
544544
return "macos"
545+
#elseif os(visionOS)
546+
return "visionos"
545547
#elseif os(Linux)
546548
return "linux"
547549
#elseif os(Windows)

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: 8 additions & 4 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

@@ -82,7 +82,7 @@ public extension UIDevice {
8282
case "iPad8,5", "iPad8,6", "iPad8,7", "iPad8,8": return "iPad Pro (12.9-inch) (3rd generation)"
8383
case "iPad8,11", "iPad8,12": return "iPad Pro (12.9-inch) (4th generation)"
8484
case "iPad13,8", "iPad13,9", "iPad13,10", "iPad13,11":return "iPad Pro (12.9-inch) (5th generation)"
85-
case "i386", "x86_64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS"))"
85+
case "i386", "x86_64", "arm64": return "Simulator \(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS"))"
8686
default: return identifier
8787
#elseif os(tvOS)
8888
case "AppleTV1,1": return "Apple TV (1st generation)"
@@ -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", "arm64": 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", "arm64": 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/Sources/WebSockets/WebSocketClient.swift.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ public class WebSocketClient {
246246

247247
let basicUpgrader = NIOWebSocketClientUpgrader(
248248
requestKey: self.frameKey,
249-
upgradePipelineHandler: self.upgradePipelineHandler
249+
upgradePipelineHandler: { channel, response in
250+
self.upgradePipelineHandler(channel: channel, response: response)
251+
}
250252
)
251253

252254
let config: NIOHTTPClientUpgradeConfiguration = (upgraders: [basicUpgrader], completionHandler: { context in

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
}

0 commit comments

Comments
 (0)