mirror of
https://github.com/utmapp/UTM.git
synced 2026-10-12 02:24:01 +00:00
Now that the deployment targets are iOS 15 and macOS 12, every guard, fallback and workaround for an older release is dead code that only obscures what the supported path is. Remove them: - Drop the `@available` attributes for iOS 15, macOS 11 and macOS 12, and unwrap the matching `#available`/`#unavailable` guards in Swift and the `@available`/`API_AVAILABLE`/`NS_AVAILABLE_IOS` ones in Objective-C. - Delete the legacy-only views and helpers left unreachable by that: NumberTextFieldOld, VMConfigNetworkPortForwardLegacyView, VMContextMenuModifier.bodyBigSur, the nonbrokenSheet, uniqued, customBadge, borderedList and legacySettingsToolbar shims, the .unsupported BootloaderSelection case, and the iOS 14 sacrificial version Section in the QEMU settings list. - jb_has_cs_execseg_allow_unsigned() has returned false for every host since iOS 14.4, so drop it along with the is_device_A12_or_newer() helper that only it used. The entitlement parser no longer needs to copy the blob either, since that copy existed only so the psychic paper needle could be blanked in place. - VMDisplayTerminalViewController tracked the keyboard frame by hand for iOS 14. `useAutoLayout` is a constant that cannot be overridden, so nothing ever registered the notification observers and only the keyboardLayoutGuide path is reachable. - VMConfigQEMUView's additionalArguments is now referenced on iOS only, which leaves its macOS branch, and the macOS 11 ForEach crash workaround inside it, unreachable. - Raise the Cydia package floor and the postinst/prerm helpers to match the new minimum. Two of the removed guards dropped an error path rather than just a branch. The shared directory `featureNotSupported` throw covered VZVirtioFileSystemDeviceConfiguration and friends being macOS 12+, which no longer applies to any supported host. The macOS guest `platformUnsupported` throw when decoding a boot config on Intel only fired on macOS 11; the Apple Silicon requirement it really guards is enforced unconditionally in UTMAppleConfigurationSystem.fillVZConfiguration, which both the start and the save path go through. Assisted-by: Claude:claude-opus-5
145 lines
6.2 KiB
Swift
145 lines
6.2 KiB
Swift
//
|
|
// Copyright © 2021 osy. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct VMWizardOSWindowsView: View {
|
|
@ObservedObject var wizardState: VMWizardState
|
|
@State private var isFileImporterPresented: Bool = false
|
|
|
|
var body: some View {
|
|
VMWizardContent("Windows") {
|
|
#if !WITH_QEMU_TCI
|
|
Section {
|
|
Toggle("Install Windows 10 or higher", isOn: $wizardState.isWindows10OrHigher)
|
|
.onChange(of: wizardState.isWindows10OrHigher) { newValue in
|
|
if newValue {
|
|
wizardState.systemBootUefi = true
|
|
wizardState.systemBootTpm = true
|
|
wizardState.isGuestToolsInstallRequested = true
|
|
} else {
|
|
wizardState.systemBootUefi = false
|
|
wizardState.systemBootTpm = false
|
|
wizardState.isGuestToolsInstallRequested = false
|
|
}
|
|
}
|
|
.disabled(wizardState.legacyHardware)
|
|
|
|
if wizardState.isWindows10OrHigher {
|
|
#if os(macOS)
|
|
Button {
|
|
let downloadCrystalFetch = URL(string: "https://mac.getutm.app/crystalfetch/")!
|
|
if let crystalFetch = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "llc.turing.CrystalFetch") {
|
|
NSWorkspace.shared.openApplication(at: crystalFetch, configuration: .init()) { _, error in
|
|
if error != nil {
|
|
NSWorkspace.shared.open(downloadCrystalFetch)
|
|
}
|
|
}
|
|
} else {
|
|
NSWorkspace.shared.open(downloadCrystalFetch)
|
|
}
|
|
} label: {
|
|
Label("Fetch latest Windows installer…", systemImage: "link")
|
|
}.buttonStyle(.link)
|
|
#endif
|
|
Link(destination: URL(string: "https://docs.getutm.app/guides/windows/")!) {
|
|
Label("Windows Install Guide", systemImage: "link")
|
|
}.buttonStyle(.borderless)
|
|
}
|
|
} header: {
|
|
Text("Image File Type")
|
|
}
|
|
#endif
|
|
|
|
Section {
|
|
if wizardState.legacyHardware {
|
|
Picker("Boot Device", selection: $wizardState.bootDevice) {
|
|
Text("CD/DVD Image").tag(VMBootDevice.cd)
|
|
Text("Floppy Image").tag(VMBootDevice.floppy)
|
|
}.pickerStyle(.inline)
|
|
.onAppear {
|
|
if !wizardState.legacyHardware && wizardState.bootDevice == .floppy {
|
|
wizardState.bootDevice = .cd
|
|
}
|
|
}
|
|
}
|
|
|
|
FileBrowseField(url: $wizardState.bootImageURL, isFileImporterPresented: $isFileImporterPresented, hasClearButton: false)
|
|
|
|
if wizardState.isBusy {
|
|
Spinner(size: .large)
|
|
}
|
|
} header: {
|
|
if wizardState.bootDevice == .cd {
|
|
Text("Boot ISO Image")
|
|
} else {
|
|
Text("Boot IMG Image")
|
|
}
|
|
}
|
|
|
|
if !wizardState.isWindows10OrHigher && !wizardState.legacyHardware {
|
|
DetailedSection("", description: "Some older systems do not support UEFI boot, such as Windows 7 and below.") {
|
|
Toggle("UEFI Boot", isOn: $wizardState.systemBootUefi)
|
|
.onChange(of: wizardState.systemBootUefi) { newValue in
|
|
if !newValue {
|
|
wizardState.systemBootTpm = false
|
|
}
|
|
}
|
|
Toggle("Secure Boot with TPM 2.0", isOn: $wizardState.systemBootTpm)
|
|
.disabled(!wizardState.systemBootUefi)
|
|
}
|
|
}
|
|
|
|
// Disabled for non-Windows 10 installs due to autounattend version
|
|
if wizardState.isWindows10OrHigher {
|
|
DetailedSection("", description: "Download and mount the guest support package for Windows. This is required for some features including dynamic resolution and clipboard sharing.") {
|
|
Toggle("Install drivers and SPICE tools", isOn: $wizardState.isGuestToolsInstallRequested)
|
|
}
|
|
}
|
|
}
|
|
.fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.data], onCompletion: processImage)
|
|
.onAppear {
|
|
wizardState.bootDevice = .cd
|
|
#if WITH_QEMU_TCI
|
|
wizardState.legacyHardware = true
|
|
#endif
|
|
if wizardState.legacyHardware {
|
|
wizardState.isWindows10OrHigher = false
|
|
wizardState.isGuestToolsInstallRequested = false
|
|
wizardState.systemBootUefi = false
|
|
wizardState.systemBootTpm = false
|
|
}
|
|
}
|
|
}
|
|
|
|
private func processImage(_ result: Result<URL, Error>) {
|
|
wizardState.busyWorkAsync {
|
|
let url = try result.get()
|
|
await MainActor.run {
|
|
wizardState.bootImageURL = url
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct VMWizardOSWindowsView_Previews: PreviewProvider {
|
|
@StateObject static var wizardState = VMWizardState()
|
|
|
|
static var previews: some View {
|
|
VMWizardOSWindowsView(wizardState: wizardState)
|
|
}
|
|
}
|