瀏覽代碼

project: add visionOS support for conditionals

osy 2 年之前
父節點
當前提交
1f496cedeb

+ 1 - 1
Configuration/QEMUConstant.swift

@@ -439,7 +439,7 @@ extension QEMUArchitecture {
     
     
     /// TSO is supported on jailbroken iOS devices with Hypervisor support
     /// TSO is supported on jailbroken iOS devices with Hypervisor support
     var hasTSOSupport: Bool {
     var hasTSOSupport: Bool {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return hasHypervisorSupport
         return hasHypervisorSupport
         #else
         #else
         return false
         return false

+ 2 - 2
Configuration/UTMQemuConfiguration+Arguments.swift

@@ -30,7 +30,7 @@ import Virtualization // for getting network interfaces
     
     
     /// Shared between helper and main process to store Unix sockets
     /// Shared between helper and main process to store Unix sockets
     var socketURL: URL {
     var socketURL: URL {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return FileManager.default.temporaryDirectory
         return FileManager.default.temporaryDirectory
         #else
         #else
         let appGroup = Bundle.main.infoDictionary?["AppGroupIdentifier"] as? String
         let appGroup = Bundle.main.infoDictionary?["AppGroupIdentifier"] as? String
@@ -429,7 +429,7 @@ import Virtualization // for getting network interfaces
     }
     }
     
     
     private var useCoreAudioBackend: Bool {
     private var useCoreAudioBackend: Bool {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return false
         return false
         #else
         #else
         // force CoreAudio backend for mac99 which only supports 44100 Hz
         // force CoreAudio backend for mac99 which only supports 44100 Hz

+ 2 - 2
Platform/Main.swift

@@ -34,7 +34,7 @@ class Main {
     static var jitAvailable = true
     static var jitAvailable = true
     
     
     static func main() {
     static func main() {
-        #if os(iOS) && !WITH_QEMU_TCI
+        #if (os(iOS) || os(visionOS)) && !WITH_QEMU_TCI
         // check if we have jailbreak
         // check if we have jailbreak
         if jb_spawn_ptrace_child(CommandLine.argc, CommandLine.unsafeArgv) {
         if jb_spawn_ptrace_child(CommandLine.argc, CommandLine.unsafeArgv) {
             logger.info("JIT: ptrace() child spawn trick")
             logger.info("JIT: ptrace() child spawn trick")
@@ -57,7 +57,7 @@ class Main {
         #endif
         #endif
         // do patches
         // do patches
         UTMPatches.patchAll()
         UTMPatches.patchAll()
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         // register defaults
         // register defaults
         registerDefaultsFromSettingsBundle()
         registerDefaultsFromSettingsBundle()
         #endif
         #endif

+ 1 - 1
Platform/Shared/BigButtonStyle.swift

@@ -44,7 +44,7 @@ struct BigButtonStyle: ButtonStyle {
             ZStack {
             ZStack {
                 RoundedRectangle(cornerRadius: 10.0)
                 RoundedRectangle(cornerRadius: 10.0)
                     .fill(configuration.isPressed ? pressedColor : defaultColor)
                     .fill(configuration.isPressed ? pressedColor : defaultColor)
-                    #if os(iOS)
+                    #if os(iOS) || os(visionOS)
                     .hoverEffect()
                     .hoverEffect()
                     .scaleEffect(configuration.isPressed ? 0.95 : 1)
                     .scaleEffect(configuration.isPressed ? 0.95 : 1)
                     #endif
                     #endif

+ 1 - 1
Platform/Shared/ContentView.swift

@@ -16,7 +16,7 @@
 
 
 import SwiftUI
 import SwiftUI
 import UniformTypeIdentifiers
 import UniformTypeIdentifiers
-#if os(iOS) && !os(visionOS)
+#if os(iOS)
 import IQKeyboardManagerSwift
 import IQKeyboardManagerSwift
 #endif
 #endif
 
 

+ 2 - 2
Platform/Shared/DestructiveButton.swift

@@ -32,7 +32,7 @@ struct DestructiveButton<Label>: View where Label : View {
     
     
     var body: some View {
     var body: some View {
         if #available(iOS 15, macOS 12, *) {
         if #available(iOS 15, macOS 12, *) {
-            #if os(iOS)
+            #if os(iOS) || os(visionOS)
             Button(role: .destructive, action: action, label: {
             Button(role: .destructive, action: action, label: {
                 label.foregroundColor(.red)
                 label.foregroundColor(.red)
             })
             })
@@ -40,7 +40,7 @@ struct DestructiveButton<Label>: View where Label : View {
             Button(role: .destructive, action: action, label: { label })
             Button(role: .destructive, action: action, label: { label })
             #endif
             #endif
         } else {
         } else {
-            #if os(iOS)
+            #if os(iOS) || os(visionOS)
             Button(action: action, label: {
             Button(action: action, label: {
                 label.foregroundColor(.red)
                 label.foregroundColor(.red)
             })
             })

+ 2 - 2
Platform/Shared/GlobalFileImporter.swift

@@ -34,12 +34,12 @@ struct GlobalFileImporterViewModifier: ViewModifier {
     @Binding var isPresented: Bool
     @Binding var isPresented: Bool
     let allowedContentTypes: [UTType]
     let allowedContentTypes: [UTType]
     let onCompletion: (Result<URL, Error>) -> Void
     let onCompletion: (Result<URL, Error>) -> Void
-    #if os(iOS)
+    #if os(iOS) || os(visionOS)
     @EnvironmentObject private var globalFileImporterShim: GlobalFileImporterShim
     @EnvironmentObject private var globalFileImporterShim: GlobalFileImporterShim
     #endif
     #endif
     
     
     func body(content: Content) -> some View {
     func body(content: Content) -> some View {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         content
         content
             .onChange(of: isPresented) { newValue in
             .onChange(of: isPresented) { newValue in
                 if newValue {
                 if newValue {

+ 1 - 1
Platform/Shared/VMConfigQEMUView.swift

@@ -73,7 +73,7 @@ struct VMConfigQEMUView: View {
                     Toggle("Use Hypervisor", isOn: $config.hasHypervisor)
                     Toggle("Use Hypervisor", isOn: $config.hasHypervisor)
                         .help("Only available if host architecture matches the target. Otherwise, TCG emulation is used.")
                         .help("Only available if host architecture matches the target. Otherwise, TCG emulation is used.")
                         .disabled(!system.architecture.hasHypervisorSupport)
                         .disabled(!system.architecture.hasHypervisorSupport)
-                    #if os(iOS)
+                    #if os(iOS) || os(visionOS)
                     if config.hasHypervisor {
                     if config.hasHypervisor {
                         Toggle("Use TSO", isOn: $config.hasTSO)
                         Toggle("Use TSO", isOn: $config.hasTSO)
                             .help("Only available when Hypervisor is used on supported hardware. TSO speeds up Intel emulation in the guest at the cost of decreased performance in general.")
                             .help("Only available when Hypervisor is used on supported hardware. TSO speeds up Intel emulation in the guest at the cost of decreased performance in general.")

+ 1 - 1
Platform/Shared/VMConfigSystemView.swift

@@ -94,7 +94,7 @@ struct VMConfigSystemView: View {
             return
             return
         }
         }
         var totalDeviceMemory = ProcessInfo.processInfo.physicalMemory
         var totalDeviceMemory = ProcessInfo.processInfo.physicalMemory
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         let availableMemory = UInt64(os_proc_available_memory())
         let availableMemory = UInt64(os_proc_available_memory())
         if availableMemory > 0 {
         if availableMemory > 0 {
             totalDeviceMemory = availableMemory
             totalDeviceMemory = availableMemory

+ 1 - 1
Platform/Shared/VMContextMenuModifier.swift

@@ -107,7 +107,7 @@ struct VMContextMenuModifier: ViewModifier {
                     }.help("Run the VM in the foreground, without saving data changes to disk.")
                     }.help("Run the VM in the foreground, without saving data changes to disk.")
                 }
                 }
                 
                 
-                #if os(iOS)
+                #if os(iOS) || os(visionOS)
                 if let qemuConfig = vm.config as? UTMQemuConfiguration {
                 if let qemuConfig = vm.config as? UTMQemuConfiguration {
                     Button {
                     Button {
                         qemuConfig.qemu.isGuestToolsInstallRequested = true
                         qemuConfig.qemu.isGuestToolsInstallRequested = true

+ 1 - 1
Platform/Shared/VMNavigationListView.swift

@@ -129,7 +129,7 @@ private struct VMListModifier: ViewModifier {
             }
             }
             #endif
             #endif
         }
         }
-        #if os(iOS) && !os(visionOS)
+        #if os(iOS)
         // SwiftUI bug on iOS 14.4 and previous versions prevents multiple .sheet from working
         // SwiftUI bug on iOS 14.4 and previous versions prevents multiple .sheet from working
         .sheet(isPresented: $sheetPresented) {
         .sheet(isPresented: $sheetPresented) {
             if data.showNewVMSheet {
             if data.showNewVMSheet {

+ 2 - 2
Platform/Shared/VMReleaseNotesView.swift

@@ -61,7 +61,7 @@ struct VMReleaseNotesView: View {
                         isShowAll = true
                         isShowAll = true
                     } label: {
                     } label: {
                         Text("Show All")
                         Text("Show All")
-                        #if os(iOS)
+                        #if os(iOS) || os(visionOS)
                             .frame(maxWidth: .infinity)
                             .frame(maxWidth: .infinity)
                         #endif
                         #endif
                     }.buttonStyle(ReleaseButtonStyle())
                     }.buttonStyle(ReleaseButtonStyle())
@@ -70,7 +70,7 @@ struct VMReleaseNotesView: View {
                     presentationMode.wrappedValue.dismiss()
                     presentationMode.wrappedValue.dismiss()
                 } label: {
                 } label: {
                     Text("Continue")
                     Text("Continue")
-                    #if os(iOS)
+                    #if os(iOS) || os(visionOS)
                         .frame(maxWidth: .infinity)
                         .frame(maxWidth: .infinity)
                     #endif
                     #endif
                 }.keyboardShortcut(.defaultAction)
                 }.keyboardShortcut(.defaultAction)

+ 1 - 1
Platform/Shared/VMRemovableDrivesView.swift

@@ -144,7 +144,7 @@ struct VMRemovableDrivesView: View {
                     Text(url.lastPathComponent)
                     Text(url.lastPathComponent)
                         .truncationMode(.head)
                         .truncationMode(.head)
                         .lineLimit(1)
                         .lineLimit(1)
-                    #if os(iOS)
+                    #if os(iOS) || os(visionOS)
                     Image(systemName: "chevron.down")
                     Image(systemName: "chevron.down")
                     #endif
                     #endif
                 }
                 }

+ 1 - 1
Platform/Shared/VMSettingsAddDeviceMenuView.swift

@@ -69,7 +69,7 @@ struct VMSettingsAddDeviceMenuView: View {
             } label: {
             } label: {
                 Label("Sound", systemImage: "speaker.wave.2")
                 Label("Sound", systemImage: "speaker.wave.2")
             }.disabled(config.system.architecture.soundDeviceType.allRawValues.isEmpty)
             }.disabled(config.system.architecture.soundDeviceType.allRawValues.isEmpty)
-            #if os(iOS)
+            #if os(iOS) || os(visionOS)
             Divider()
             Divider()
             Button {
             Button {
                 isImportDriveShown.toggle()
                 isImportDriveShown.toggle()

+ 1 - 1
Platform/Shared/VMWizardDrivesView.swift

@@ -43,7 +43,7 @@ struct VMWizardDrivesView: View {
             }
             }
             
             
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Storage"))
         .navigationTitle(Text("Storage"))
         #endif
         #endif
     }
     }

+ 1 - 1
Platform/Shared/VMWizardHardwareView.swift

@@ -120,7 +120,7 @@ struct VMWizardHardwareView: View {
                 
                 
             }
             }
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Hardware"))
         .navigationTitle(Text("Hardware"))
         #endif
         #endif
         .textFieldStyle(.roundedBorder)
         .textFieldStyle(.roundedBorder)

+ 1 - 1
Platform/Shared/VMWizardOSLinuxView.swift

@@ -144,7 +144,7 @@ struct VMWizardOSLinuxView: View {
             
             
             
             
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Linux"))
         .navigationTitle(Text("Linux"))
         #endif
         #endif
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)

+ 1 - 1
Platform/Shared/VMWizardOSOtherView.swift

@@ -43,7 +43,7 @@ struct VMWizardOSOtherView: View {
                 Text("Advanced")
                 Text("Advanced")
             }
             }
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Other"))
         .navigationTitle(Text("Other"))
         #endif
         #endif
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)

+ 1 - 1
Platform/Shared/VMWizardOSView.swift

@@ -77,7 +77,7 @@ struct VMWizardOSView: View {
             }
             }
 
 
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Operating System"))
         .navigationTitle(Text("Operating System"))
         #endif
         #endif
         .buttonStyle(.inList)
         .buttonStyle(.inList)

+ 1 - 1
Platform/Shared/VMWizardOSWindowsView.swift

@@ -121,7 +121,7 @@ struct VMWizardOSWindowsView: View {
                 }
                 }
             }
             }
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Windows"))
         .navigationTitle(Text("Windows"))
         #endif
         #endif
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)

+ 1 - 1
Platform/Shared/VMWizardSharingView.swift

@@ -38,7 +38,7 @@ struct VMWizardSharingView: View {
                 }
                 }
             }
             }
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Shared Directory"))
         .navigationTitle(Text("Shared Directory"))
         #endif
         #endif
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.folder], onCompletion: processDirectory)
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.folder], onCompletion: processDirectory)

+ 2 - 2
Platform/Shared/VMWizardStartView.swift

@@ -64,7 +64,7 @@ struct VMWizardStartView: View {
                 }
                 }
                 .buttonStyle(.inList)
                 .buttonStyle(.inList)
                 .disabled(!isVirtualizationSupported)
                 .disabled(!isVirtualizationSupported)
-                #if os(iOS)
+                #if os(iOS) || os(visionOS)
                 if #available(iOS 15, *) {
                 if #available(iOS 15, *) {
                     virtButton
                     virtButton
                 } else {
                 } else {
@@ -131,7 +131,7 @@ struct VMWizardStartView: View {
             }
             }
 
 
         }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Start"))
         .navigationTitle(Text("Start"))
         #endif
         #endif
     }
     }

+ 2 - 2
Platform/UTMData.swift

@@ -366,7 +366,7 @@ struct AlertMessage: Identifiable {
     }
     }
     
     
     func showSettingsForCurrentVM() {
     func showSettingsForCurrentVM() {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         // SwiftUI bug: cannot show modal at the same time as changing selected VM or it breaks
         // SwiftUI bug: cannot show modal at the same time as changing selected VM or it breaks
         DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
         DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
             self.showSettingsModal = true
             self.showSettingsModal = true
@@ -924,7 +924,7 @@ struct AlertMessage: Identifiable {
 
 
     // MARK - JitStreamer
     // MARK - JitStreamer
 
 
-#if os(iOS)
+#if os(iOS) || os(visionOS)
     @available(iOS 15, *)
     @available(iOS 15, *)
     func jitStreamerAttach() async throws {
     func jitStreamerAttach() async throws {
         let urlString = String(
         let urlString = String(

+ 1 - 1
Platform/UTMReleaseHelper.swift

@@ -94,7 +94,7 @@ class UTMReleaseHelper: ObservableObject {
                 let range = match.range(at: 1)
                 let range = match.range(at: 1)
                 let platform = nsString.substring(with: range)
                 let platform = nsString.substring(with: range)
                 let description = nsString.substring(from: match.range.location + match.range.length)
                 let description = nsString.substring(from: match.range.location + match.range.length)
-                #if os(iOS)
+                #if os(iOS) || os(visionOS)
                 #if WITH_QEMU_TCI
                 #if WITH_QEMU_TCI
                 if platform == "iOS SE" {
                 if platform == "iOS SE" {
                     currentSection.body.append(description)
                     currentSection.body.append(description)

+ 2 - 2
Services/UTMExtensions.swift

@@ -331,7 +331,7 @@ struct Setting<T> {
 // MARK: - Bookmark handling
 // MARK: - Bookmark handling
 extension URL {
 extension URL {
     private static var defaultCreationOptions: BookmarkCreationOptions {
     private static var defaultCreationOptions: BookmarkCreationOptions {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return .minimalBookmark
         return .minimalBookmark
         #else
         #else
         return .withSecurityScope
         return .withSecurityScope
@@ -339,7 +339,7 @@ extension URL {
     }
     }
     
     
     private static var defaultResolutionOptions: BookmarkResolutionOptions {
     private static var defaultResolutionOptions: BookmarkResolutionOptions {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return []
         return []
         #else
         #else
         return .withSecurityScope
         return .withSecurityScope

+ 5 - 5
UTM.xcodeproj/project.pbxproj

@@ -4095,10 +4095,10 @@
 /* Begin XCRemoteSwiftPackageReference section */
 /* Begin XCRemoteSwiftPackageReference section */
 		8399328E272F4A400059355F /* XCRemoteSwiftPackageReference "ZIPFoundation" */ = {
 		8399328E272F4A400059355F /* XCRemoteSwiftPackageReference "ZIPFoundation" */ = {
 			isa = XCRemoteSwiftPackageReference;
 			isa = XCRemoteSwiftPackageReference;
-			repositoryURL = "https://github.com/weichsel/ZIPFoundation.git";
+			repositoryURL = "https://github.com/osy/ZIPFoundation.git";
 			requirement = {
 			requirement = {
-				kind = upToNextMajorVersion;
-				minimumVersion = 0.9.9;
+				kind = revision;
+				revision = 6793a6e7c587503aa078ec1246d71ef8fb50733b;
 			};
 			};
 		};
 		};
 		84018693288B66370050AC51 /* XCRemoteSwiftPackageReference "swiftui-visual-effects" */ = {
 		84018693288B66370050AC51 /* XCRemoteSwiftPackageReference "swiftui-visual-effects" */ = {
@@ -4161,8 +4161,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/apple/swift-log";
 			repositoryURL = "https://github.com/apple/swift-log";
 			requirement = {
 			requirement = {
-				kind = upToNextMajorVersion;
-				minimumVersion = 1.2.0;
+				kind = revision;
+				revision = 5996c7a1b4a3bc972a43f55c78437f23a8eae465;
 			};
 			};
 		};
 		};
 		CE93759724BB821F0074066F /* XCRemoteSwiftPackageReference "IQKeyboardManager" */ = {
 		CE93759724BB821F0074066F /* XCRemoteSwiftPackageReference "IQKeyboardManager" */ = {

+ 4 - 6
UTM.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -59,8 +59,7 @@
       "kind" : "remoteSourceControl",
       "kind" : "remoteSourceControl",
       "location" : "https://github.com/apple/swift-log",
       "location" : "https://github.com/apple/swift-log",
       "state" : {
       "state" : {
-        "revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
-        "version" : "1.5.2"
+        "revision" : "5996c7a1b4a3bc972a43f55c78437f23a8eae465"
       }
       }
     },
     },
     {
     {
@@ -69,7 +68,7 @@
       "location" : "https://github.com/osy/SwiftTerm.git",
       "location" : "https://github.com/osy/SwiftTerm.git",
       "state" : {
       "state" : {
         "branch" : "visionos",
         "branch" : "visionos",
-        "revision" : "0b034bb577190785e44915ac18e5e3f0ba1c993d"
+        "revision" : "ce8e0f17196e0fafa0f150ce129a91a04a97eb85"
       }
       }
     },
     },
     {
     {
@@ -84,10 +83,9 @@
     {
     {
       "identity" : "zipfoundation",
       "identity" : "zipfoundation",
       "kind" : "remoteSourceControl",
       "kind" : "remoteSourceControl",
-      "location" : "https://github.com/weichsel/ZIPFoundation.git",
+      "location" : "https://github.com/osy/ZIPFoundation.git",
       "state" : {
       "state" : {
-        "revision" : "43ec568034b3731101dbf7670765d671c30f54f3",
-        "version" : "0.9.16"
+        "revision" : "6793a6e7c587503aa078ec1246d71ef8fb50733b"
       }
       }
     }
     }
   ],
   ],