Skip to content

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

Patch queue: carry #171's xcode_projects.py change as a patch

v0lumehib8ca7ee4206a
diff --git a/dm/fork_patches.txt b/dm/fork_patches.txt
index 89b4b693..13033f43 100644
--- a/dm/fork_patches.txt
+++ b/dm/fork_patches.txt
@@ -17,3 +17,4 @@ ref-hle-hid-d2r
fork-patches-stamp
nsp-dotnet-root-verify
games-md-gallery
+ios-xcode-projects-prune
diff --git a/patches/0025-ios-xcode-projects-prune.patch b/patches/0025-ios-xcode-projects-prune.patch
new file mode 100644
index 00000000..d69b22d4
--- /dev/null
+++ b/patches/0025-ios-xcode-projects-prune.patch
@@ -0,0 +1,69 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: LNPANDY <[email protected]>
+Date: Thu, 29 Oct 2026 04:42:13 +0800
+Subject: [PATCH] Xcode projects: a bundle-ID check must not crash on a project
+ another macOS user owns
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The workspace records absolute paths, and the launcher's saved state crosses accounts on a shared Mac. A new user running the same build hits PermissionError when check_bundle_id stats a project registered by the first user — the build dies with a Python traceback instead of a message. Skip unreadable projects: if this user cannot read them, they cannot be using the bundle ID either.
+
+The report: a new macOS user building Hades II hit PermissionError on /Users/hejie/... paths inside xcode_projects.py:38 — the workspace file inherited the first user's absolute paths.
+
+Upstream-Status: pending
+Reason: General fix for a PermissionError on a workspace shared between macOS users (#171), belongs upstream at seedds/nxnative
+Issue: LNPANDY/NX2Apple#171
+
+---
+ dm/ios/tools/xcode_projects.py | 34 +++++++++++++++++++++++++++++++++-
+ 1 file changed, 33 insertions(+), 1 deletion(-)
+
+diff --git a/dm/ios/tools/xcode_projects.py b/dm/ios/tools/xcode_projects.py
+index a832ad5a..0f5485df 100644
+--- a/dm/ios/tools/xcode_projects.py
++++ b/dm/ios/tools/xcode_projects.py
+@@ -33,10 +33,42 @@ def workspace_projects(workspace):
+ if kind == 'absolute': yield Path(path).resolve()
+
+
++def prune_unreadable(workspace):
++ """Remove workspace entries the current user cannot access, and save the file.
++
++ The workspace records absolute paths, and the launcher's saved state crosses accounts on a
++ shared Mac: a new user's build inherits the first user's entries and dies with PermissionError
++ when it stats them. A project this user cannot read is not this user's project — removing the
++ entry is the fix, not a message telling them to edit XML."""
++ path = Path(workspace) / 'contents.xcworkspacedata'
++ if not path.exists(): return 0
++ tree = workspace_tree(workspace)
++ removed = 0
++ for group in tree.iter('Group'):
++ for ref in list(group.findall('FileRef')):
++ kind, _, loc = ref.get('location', '').partition(':')
++ if kind != 'absolute': continue
++ try:
++ Path(loc).exists()
++ continue # the current user can read it: a real project, not a stale entry
++ except (PermissionError, OSError):
++ pass
++ group.remove(ref)
++ removed += 1
++ if removed:
++ tree.write(str(path), xml_declaration=True, encoding='unicode')
++ print(f'[NOTE] removed {removed} workspace entr{"y" if removed == 1 else "ies"} the current user cannot read (registered by another macOS user)')
++ return removed
++
++
+ def check_bundle_id(workspace, project, bundle_id):
++ prune_unreadable(workspace)
+ for other in workspace_projects(workspace):
+ if other == Path(project).resolve() or not other.exists(): continue
+- used = signing_settings(other).get('PRODUCT_BUNDLE_IDENTIFIER', '')
++ try:
++ used = signing_settings(other).get('PRODUCT_BUNDLE_IDENTIFIER', '')
++ except (PermissionError, OSError):
++ continue
+ if used.lower() == bundle_id.lower():
+ raise ValueError(f'bundle ID {bundle_id} is already used by {other}; choose a different --bundle-id for this game')
+
diff --git a/patches/series b/patches/series
index 01b3b121..45287381 100644
--- a/patches/series
+++ b/patches/series
@@ -18,3 +18,4 @@
0017-fork-patches-stamp.patch
0018-nsp-dotnet-root-verify.patch
0024-games-md-gallery.patch
+0025-ios-xcode-projects-prune.patch