Skip to content

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

3.6 KB
Raw Blame
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: fork-only (the Cloud saves hunk landed upstream in 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. Upstream has the Cloud saves hunk (seedds/nxnative#800). What is left is the Game data hunk, which is fork-only because that section comes from patch 0003
Issue: LNPANDY/NX2Apple#315
---
 dm/ios/Sources/Launcher.swift | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/dm/ios/Sources/Launcher.swift b/dm/ios/Sources/Launcher.swift
index 6013b30..011a893 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)
     }