Skip to content

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

patches: the iOS launcher presents the document picker once per tap (#315)

v0lumehi3e37907d238d
diff --git a/patches/0042-ios-launcher-present-the-document-picker-once-pe.patch b/patches/0042-ios-launcher-present-the-document-picker-once-pe.patch
new file mode 100644
index 00000000..78bc0411
--- /dev/null
+++ b/patches/0042-ios-launcher-present-the-document-picker-once-pe.patch
@@ -0,0 +1,101 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: v0lumehi <[email protected]>
+Date: Sat, 31 Oct 2026 15:16:13 +0100
+Subject: [PATCH] iOS launcher: present the document picker once per tap
+
+The Cloud saves and Game data sections put .sheet(isPresented:) on the Section.
+SwiftUI hands a Section's modifiers to each of its rows, so one tap on "Choose a
+folder in iCloud Drive..." presented one DocumentPicker per row. UIKit logged
+"Attempt to present ... which is already presenting", three DocumentManager
+remote view controllers started, and they invalidated each other's scene. The
+launcher dimmed without a picker, or a picker showed whose Open did nothing.
+The sheet now sits on the button that sets the flag, so one tap presents one
+picker. In the iOS 27 simulator Open then dismisses the picker and stores the
+bookmark ("launcher: cloud-save folder set to ...").
+
+Upstream-Status: forwarded seedds/nxnative#800
+Reason: One tap on Choose a folder in iCloud Drive presented a document picker per Section row. The pickers invalidated each other and Open did nothing. The Game data hunk is fork-only, because that section comes from patch 0003
+Issue: LNPANDY/NX2Apple#315
+
+---
+ dm/ios/Sources/Launcher.swift | 46 ++++++++++++++++++-----------------
+ 1 file changed, 24 insertions(+), 22 deletions(-)
+
+diff --git a/dm/ios/Sources/Launcher.swift b/dm/ios/Sources/Launcher.swift
+index 44af3cc..f20e403 100644
+--- a/dm/ios/Sources/Launcher.swift
++++ b/dm/ios/Sources/Launcher.swift
+@@ -30,6 +30,18 @@ private struct GameDataSection: View {
+ .foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle)
+ }
+ Button(picked.isEmpty ? "Choose game data…" : "Choose a different location…") { picking = true }
++ // The sheet sits on the button, not on the Section: SwiftUI hands a Section's modifiers to every row, so one tap presented a picker per row and they invalidated each other (LNPANDY/NX2Apple#315).
++ .sheet(isPresented: $picking) {
++ DocumentPicker(types: [.item]) { url in
++ picking = false
++ if dm_store_picked_data(url) {
++ note = "Saved. The game uses this location when you press Play."
++ refresh()
++ } else {
++ note = "That location could not be remembered — try a different one."
++ }
++ } onCancel: { picking = false }
++ }
+ if !picked.isEmpty {
+ Button("Use the app's own data again", role: .destructive) {
+ dm_clear_picked_data(); refresh(); note = ""
+@@ -40,17 +52,6 @@ private struct GameDataSection: View {
+ ? "Pick the game's romfs.img or its RomFS folder — an external drive or iCloud Drive works. The app remembers the choice; a re-signed build asks once more."
+ : note)
+ }
+- .sheet(isPresented: $picking) {
+- DocumentPicker(types: [.item]) { url in
+- picking = false
+- if dm_store_picked_data(url) {
+- note = "Saved. The game uses this location when you press Play."
+- refresh()
+- } else {
+- note = "That location could not be remembered — try a different one."
+- }
+- } onCancel: { picking = false }
+- }
+ .onAppear(perform: refresh)
+ }
+
+@@ -85,6 +86,18 @@ private struct CloudSavesSection: View {
+ .foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle)
+ }
+ Button(folder.isEmpty ? "Choose a folder in iCloud Drive…" : "Choose a different folder…") { picking = true }
++ // The sheet sits on the button, not on the Section: SwiftUI hands a Section's modifiers to every row, so one tap presented a picker per row and they invalidated each other (LNPANDY/NX2Apple#315).
++ .sheet(isPresented: $picking) {
++ DocumentPicker(types: [.folder]) { url in
++ picking = false
++ if dm_store_cloud_saves(url) {
++ note = "Saved. The game uses this folder when you press Play."
++ refresh()
++ } else {
++ note = "That folder could not be remembered — try a different one."
++ }
++ } onCancel: { picking = false }
++ }
+ if !folder.isEmpty {
+ Button("Turn off cloud saves", role: .destructive) {
+ dm_clear_cloud_saves(); refresh(); note = ""
+@@ -95,17 +108,6 @@ private struct CloudSavesSection: View {
+ ? "Choose a folder in iCloud Drive, and the same one in the Mac app's Cloud saves. The save comes in when the game starts and goes out after each save; a save that is replaced is kept in save-backups."
+ : note)
+ }
+- .sheet(isPresented: $picking) {
+- DocumentPicker(types: [.folder]) { url in
+- picking = false
+- if dm_store_cloud_saves(url) {
+- note = "Saved. The game uses this folder when you press Play."
+- refresh()
+- } else {
+- note = "That folder could not be remembered — try a different one."
+- }
+- } onCancel: { picking = false }
+- }
+ .onAppear(perform: refresh)
+ }
+
diff --git a/patches/series b/patches/series
index 1308f11d..bd54ab70 100644
--- a/patches/series
+++ b/patches/series
@@ -25,3 +25,4 @@
0039-patch-nso-a-zero-extending-and-of-the-index-is-a.patch
0040-nsp-derived-profile-without-frame-step.patch
0041-shared-fonts-a-compact-stand-in-for-a-font-engin.patch
+0042-ios-launcher-present-the-document-picker-once-pe.patch