Przeglądaj źródła

project: add visionOS support for conditionals

osy 2 lat temu
rodzic
commit
1f496cedeb

+ 1 - 1
Configuration/QEMUConstant.swift

@@ -439,7 +439,7 @@ extension QEMUArchitecture {
     
     /// TSO is supported on jailbroken iOS devices with Hypervisor support
     var hasTSOSupport: Bool {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return hasHypervisorSupport
         #else
         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
     var socketURL: URL {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return FileManager.default.temporaryDirectory
         #else
         let appGroup = Bundle.main.infoDictionary?["AppGroupIdentifier"] as? String
@@ -429,7 +429,7 @@ import Virtualization // for getting network interfaces
     }
     
     private var useCoreAudioBackend: Bool {
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         return false
         #else
         // 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 func main() {
-        #if os(iOS) && !WITH_QEMU_TCI
+        #if (os(iOS) || os(visionOS)) && !WITH_QEMU_TCI
         // check if we have jailbreak
         if jb_spawn_ptrace_child(CommandLine.argc, CommandLine.unsafeArgv) {
             logger.info("JIT: ptrace() child spawn trick")
@@ -57,7 +57,7 @@ class Main {
         #endif
         // do patches
         UTMPatches.patchAll()
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         // register defaults
         registerDefaultsFromSettingsBundle()
         #endif

+ 1 - 1
Platform/Shared/BigButtonStyle.swift

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

+ 1 - 1
Platform/Shared/ContentView.swift

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

+ 2 - 2
Platform/Shared/DestructiveButton.swift

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

+ 2 - 2
Platform/Shared/GlobalFileImporter.swift

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

+ 1 - 1
Platform/Shared/VMConfigQEMUView.swift

@@ -73,7 +73,7 @@ struct VMConfigQEMUView: View {
                     Toggle("Use Hypervisor", isOn: $config.hasHypervisor)
                         .help("Only available if host architecture matches the target. Otherwise, TCG emulation is used.")
                         .disabled(!system.architecture.hasHypervisorSupport)
-                    #if os(iOS)
+                    #if os(iOS) || os(visionOS)
                     if config.hasHypervisor {
                         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.")

+ 1 - 1
Platform/Shared/VMConfigSystemView.swift

@@ -94,7 +94,7 @@ struct VMConfigSystemView: View {
             return
         }
         var totalDeviceMemory = ProcessInfo.processInfo.physicalMemory
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         let availableMemory = UInt64(os_proc_available_memory())
         if availableMemory > 0 {
             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.")
                 }
                 
-                #if os(iOS)
+                #if os(iOS) || os(visionOS)
                 if let qemuConfig = vm.config as? UTMQemuConfiguration {
                     Button {
                         qemuConfig.qemu.isGuestToolsInstallRequested = true

+ 1 - 1
Platform/Shared/VMNavigationListView.swift

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

+ 2 - 2
Platform/Shared/VMReleaseNotesView.swift

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

+ 1 - 1
Platform/Shared/VMRemovableDrivesView.swift

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

+ 1 - 1
Platform/Shared/VMSettingsAddDeviceMenuView.swift

@@ -69,7 +69,7 @@ struct VMSettingsAddDeviceMenuView: View {
             } label: {
                 Label("Sound", systemImage: "speaker.wave.2")
             }.disabled(config.system.architecture.soundDeviceType.allRawValues.isEmpty)
-            #if os(iOS)
+            #if os(iOS) || os(visionOS)
             Divider()
             Button {
                 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"))
         #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"))
         #endif
         .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"))
         #endif
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)

+ 1 - 1
Platform/Shared/VMWizardOSOtherView.swift

@@ -43,7 +43,7 @@ struct VMWizardOSOtherView: View {
                 Text("Advanced")
             }
         }
-        #if os(iOS)
+        #if os(iOS) || os(visionOS)
         .navigationTitle(Text("Other"))
         #endif
         .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"))
         #endif
         .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"))
         #endif
         .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"))
         #endif
         .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.folder], onCompletion: processDirectory)

+ 2 - 2
Platform/Shared/VMWizardStartView.swift

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

+ 2 - 2
Platform/UTMData.swift

@@ -366,7 +366,7 @@ struct AlertMessage: Identifiable {
     }
     
     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
         DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
             self.showSettingsModal = true
@@ -924,7 +924,7 @@ struct AlertMessage: Identifiable {
 
     // MARK - JitStreamer
 
-#if os(iOS)
+#if os(iOS) || os(visionOS)
     @available(iOS 15, *)
     func jitStreamerAttach() async throws {
         let urlString = String(

+ 1 - 1
Platform/UTMReleaseHelper.swift

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

+ 2 - 2
Services/UTMExtensions.swift

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

+ 5 - 5
UTM.xcodeproj/project.pbxproj

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

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

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