Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Allow creating new folders in the Build tab's Save to dialog

v0lumehic581ba1ee0b0
diff --git a/frontend/Sources/NX2Apple/LauncherStores.swift b/frontend/Sources/NX2Apple/LauncherStores.swift
index 0f015e87..7dca2dad 100644
--- a/frontend/Sources/NX2Apple/LauncherStores.swift
+++ b/frontend/Sources/NX2Apple/LauncherStores.swift
@@ -98,7 +98,7 @@ import NXModel
return p.urls.map(\.path)
}
build.chooseFolder = {
- let d = NSOpenPanel(); d.canChooseDirectories = true; d.canChooseFiles = false
+ let d = Self.buildFolderPanel()
guard d.runModal() == .OK, let u = d.url else { return nil }
return u.path
}
@@ -122,6 +122,13 @@ import NXModel
build.openApp = { NSWorkspace.shared.openApplication(at: $0, configuration: NSWorkspace.OpenConfiguration()) }
}
+ /// The panel of the Build tab's Save to folder. It can make a folder, because the folder for the IPA often does not exist yet.
+ static func buildFolderPanel() -> NSOpenPanel {
+ let d = NSOpenPanel()
+ d.canChooseDirectories = true; d.canChooseFiles = false; d.canCreateDirectories = true
+ return d
+ }
+
/// Whether the xcode row asks for the iOS SDK. Always, as before, unless the guided setup stored a Mac-only choice
/// and builds are for the Mac: upstream no longer needs the iOS SDK for a Mac build (c464cb24).
nonisolated static func needsIOSPlatform(defaults: UserDefaults = .standard) -> Bool {
diff --git a/frontend/Tests/NX2AppleTests/BuildFolderPanelTests.swift b/frontend/Tests/NX2AppleTests/BuildFolderPanelTests.swift
new file mode 100644
index 00000000..0d4e5a45
--- /dev/null
+++ b/frontend/Tests/NX2AppleTests/BuildFolderPanelTests.swift
@@ -0,0 +1,13 @@
+import AppKit
+import XCTest
+@testable import NX2Apple
+
+/// The Build tab's Save to dialog must offer "New Folder": the folder for the IPA often does not exist yet (#477).
+@MainActor final class BuildFolderPanelTests: XCTestCase {
+ func testTheSaveToPanelCanCreateFolders() {
+ let panel = LauncherStores.buildFolderPanel()
+ XCTAssertTrue(panel.canCreateDirectories)
+ XCTAssertTrue(panel.canChooseDirectories)
+ XCTAssertFalse(panel.canChooseFiles)
+ }
+}