Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Sync: bring the upstream files the first sync missed; restore the memory-limit guide
v0lumehi4c37dcc59313
diff --git a/dm/ios/ENTITLEMENTS.md b/dm/ios/ENTITLEMENTS.mdnew file mode 100644index 00000000..de284eb2--- /dev/null+++ b/dm/ios/ENTITLEMENTS.md@@ -0,0 +1,100 @@+# Increased Memory Limit++The app asks for `com.apple.developer.kernel.increased-memory-limit`. `build_ipa.sh` writes the+entitlements file itself (`DM_ENTITLEMENTS=<plist>` gives another one, an empty value none): into the+unsigned IPA's placeholder signature (below), and for a prepared Xcode project as `Gen/DmIOS.entitlements`+through `CODE_SIGN_ENTITLEMENTS` in its `Gen/dm.xcconfig`.++## Why it matters++iOS gives an app a per-process physical-memory budget and kills it (jetsam, SIGKILL, no crash+report) when it goes over. On current iPhones that budget is about **3.3 GB** without the+entitlement and **6–8 GB** with it, depending on the device.++Measured here, both on a 12 GB iPhone:++| Game | Peak resident | Headroom | Result |+|---|---|---|---|+| Tears of the Kingdom | 3,342 MB | 33 MB | killed entering the world map |+| Hades II | — | — | asks for a 3.10 GB heap; at the budget limit |++Lowering the render scale to 0.5 did not change the Tears of the Kingdom outcome, so the limit is+the guest heap rather than the GPU. The only way past it is a higher budget.++## What the entitlement needs++Two conditions, both required:++1. **The signature carries it.** `build_ipa.sh` builds unsigned (the sideloader re-signs), so what+ matters is whether the sideloader copies unknown entitlements from the IPA into its own signature+ instead of dropping them.+2. **The App ID has it enabled.** The provisioning profile a sideloader generates only includes+ entitlements the App ID is registered for. The sideloader has to ask Apple for it.++## Which sideloaders keep it++Reported by [playport.dev](https://playport.dev/) (a different project with the same requirement):++| Sideloader | Keeps the entitlement |+|---|---|+| AltStore Classic 2.2 or later | Yes |+| Impactor (from a computer) | Yes |+| Xcode with a Personal Team | Yes |+| SideStore 0.7.0, free Apple ID | Not by default — see below |+| Sideloadly and others | Check the tool; Sideloadly does not enable it |++## SideStore with a free Apple ID++The entitlement attaches to the App ID, so it survives the weekly refresh once set. One-time fix:++1. Install this app through SideStore, so its App ID has been created with Apple.+2. Sideload **GetMoreRam** and sign in with the same Apple ID SideStore uses.+3. In GetMoreRam open **App IDs**, tap **Refresh**, select this app's App ID, then+ **Add Increased Memory Limit**.+4. Reinstall the app from SideStore (it upgrades in place; `Documents/` — the RomFS archive and the+ saves — is preserved).+5. Confirm: `Documents/log.txt` should now show a much larger `headroom to the system memory limit`+ in the `memory up to frame N` lines. GetMoreRam uses one of a free Apple ID's three app slots, so+ delete it afterwards if you need the slot back.++## Checking whether it took effect++Launch the game, let it run a few hundred frames, then read the memory line in `Documents/log.txt`:++```+memory up to frame 600: resident 3342 MB, ... headroom to the system memory limit 33 MB+```++`resident + headroom` is the budget the kernel enforces:++- ≈ 3,375 MB → the entitlement is not in effect.+- ≈ 6,000–8,000 MB → it is.++`os_proc_available_memory()` is what produces that number (`dm/gfx/nvn/nvn_mtl.m`), and it reports+the distance to the budget the kernel enforces.++## Why the placeholder signature matters++`build_ipa.sh` builds unsigned. A sideloader decides which entitlements to carry by reading them+from the signature it is replacing — an unsigned binary has none, so the request would be lost no+matter what sits in the bundle. The script therefore embeds the entitlement with an+ad-hoc signature (`codesign --force --sign - --entitlements …`, no certificate needed): the+sideloader strips that signature and swaps in the user's own, but it now sees the entitlement and+carries it over. Check any built IPA with:++```bash+codesign -d --entitlements :- Payload/DmIOS.app/DmIOS | grep increased-memory-limit+```++Measured here (12 GB iPhone, AltStore Classic 2.3): before the placeholder signature the budget was+3,375 MB and Hades II died entering a larger scene; after it the game runs. If the budget stays at+3,375 MB with a signed IPA, the remaining step is on the App ID — enable the capability with a tool+like GetMoreRam (same Apple ID as the sideloader, App IDs → Refresh → select the app → Add+Increased Memory Limit), then reinstall so the profile picks it up.++## Xcode route++A project prepared with `--prepare-xcode` already carries the entitlement (`Gen/DmIOS.entitlements`);+with a Personal Team and a real device, build from there. That is the one route where the app is+signed at build time, so no re-signing step can drop the entitlement. The Mac launcher's+**Install on** uses this route.diff --git a/scripts/sync_upstream.py b/scripts/sync_upstream.pyindex eafa1e75..c0e19050 100644--- a/scripts/sync_upstream.py+++ b/scripts/sync_upstream.py@@ -7,7 +7,8 @@ re-apply the fork's features, verify the result builds — and this script is thprocedure, so a scheduled CI job can run it unattended.What it does:- 1. diffs the two upstream refs over the vendored paths (dm/ scripts/ docs/ AGENTS.md ref/)+ 1. diffs the two upstream refs over the vendored paths (dm/ scripts/ docs/ AGENTS.md ref/), and+ adds any vendored file upstream has that the fork's tree lacks2. applies adds and modifications file by file, and deletions — except the fork's ownfiles (the RomFS archive layer), which upstream must not delete3. re-applies the fork's patches to the four files that carry them@@ -44,7 +45,12 @@ OURS = {'dm/host/romfs_arc.c', 'dm/host/romfs_arc.h', 'dm/tools/romfs_arc.py',# writes the runtime profile; both are fork-only, so the file is never taken from upstream# (a verify-only patcher was not enough: the sync replaced it first and then complained).'dm/games/game.py',- 'dm/gfx/tex/tests/t_bcdec.c'}+ 'dm/gfx/tex/tests/t_bcdec.c',+ # The Increased Memory Limit guide the README links to; upstream has no such file, and the+ # first wholesale sync deleted it.+ 'dm/ios/ENTITLEMENTS.md',+ # This script: fork-only, so a PR that changes it is not a vendored edit (pr-scope reads OURS)+ 'scripts/sync_upstream.py'}# Vendored files that carry fork patches: taken fresh from upstream, then patched below.PATCHED = ('dm/host/hle_fs.c', 'dm/host/Makefile', 'dm/host/tests/Makefile', 'dm/ios/tools/build_ipa.sh','scripts/build_ipa_from_nsp.py', 'dm/gfx/tools/shader_split.py',@@ -60,13 +66,20 @@ def blob(rev, path):return r.stdout if r.returncode == 0 else Nonedef upstream_changes(old, new):- """(kind, path) for every vendored file that differs, kind in AM D."""+ """(kind, path) for every vendored file that differs, kind in AM D; plus an A for every vendored+ file upstream has that the fork's tree lacks. The diff alone only sees files that changed between+ the two refs, so a file the first sync missed never arrived: docs/geometry-metal-research.md (which+ game notes link to) and 34 of docs/images, until test_docs.py found the dead links."""out = git('diff', '--name-status', old, new, '--', *VENDORED).splitlines()changes = []for line in out:parts = line.split('\t')kind, path = parts[0][0], parts[-1]changes.append((kind, path))+ named = {p for _, p in changes}+ for path in git('ls-tree', '-r', '--name-only', new, '--', *VENDORED).splitlines():+ if path not in named and path not in OURS and not (REPO / path).exists():+ changes.append(('A', path))return changes# ---- the fork's patches. Each is (name, already-marker, [(old, new), ...]); a patch whose