Skip to content

Find the game's save on the device itself and choose an iPhone or iPad - #260

Merged
v0lumehi merged 4 commits into
mainfrom
v0lumehi/saves-discovery
Oct 30, 2026
Merged

v0lumehi merged 4 commits into
mainfrom
v0lumehi/saves-discovery

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Closes #250. Thanks @Tiomehsh for the report and for the reference patch.

Two problems in Manage > Saves:

  1. A game installed another way (the exported IPA signed with LCSign, for example) was reported as "not installed from this launcher" and transfers were off, although the Mac can read the app's data container. The sheet only trusted the launcher's own install record and the signed app it cached.
  2. With an iPhone and an iPad paired, a query to a device whose connection is not ready could hang. Refresh stayed enabled and repeated clicks left the window at "Reading…".

The change, all in frontend/:

  • Discovery on the device. devicectl device info apps (with --include-default-apps, as an app signed by another tool is not a developer app) is matched in this order: the bundle ID this launcher recorded, org.nxnative.<title ID>, any bundle ID containing the title ID, then the display name against the game's name. The app's bundle ID is the data container. No local Xcode project or cached signed app is needed.
  • Both save layouts. Documents/save and Documents/games/<title ID>/save are both read. The layout that holds a save is the one in use. With saves in both, or in neither, the per-game folder wins when it holds romfs.img or romfs (what the runtime does), else Documents. A copy to the device goes to that layout. Confirmation and backups are unchanged.
  • Device selector. With more than one paired device the sheet shows a picker and the device row names the device it asks. The default is the device picked here before, then the one the game was installed on, then the Builds target, connected ones first. A device that is not connected is not asked at all and the row says so.
  • Timeouts and no overlap. Every devicectl command gets --timeout plus a process deadline (10 s for a query, 180 s for a copy). A new SavesModel runs one query at a time, ends it with a "did not answer in time" message after 30 s, disables Refresh while it runs, lets a device choice replace a running query, and drops an answer that arrives after its query was given up or replaced. A timeout in the middle of a read is an error, never "No save yet".
  • Strings in English, Chinese and Swedish (there is no German table on main).

From @Tiomehsh's patch: the process deadline around devicectl (terminate, then SIGKILL), the Refresh disabled while reading, reading both the Documents and the per-game layout and the romfs rule for the active one, and the newer CoreDevice listing shape in parseListing (metadata.lastModDate, resources.isDirectory, without counting a directory's metadata twice). Their commit is credited with a Co-authored-by trailer.

What differs: their patch guesses the bundle ID (org.nxnative.<title ID>) and tries each paired device in turn. Here the app is looked up in the device's app list, so any bundle ID works, and the user picks the device instead of the launcher hopping between them. The timeouts and stale-result handling live in a model with a faked devicectl, so they are tested.
Mac save path follows the library folder. The Mac side used to look for a games/ folder beside the app, which is not what the host does. It now follows dm/mac/launcher.c: with the .nx2apple-library marker beside the app the save is save/<title ID> there, otherwise ~/Library/Application Support/nxnative/<title ID>/save. When both exist the one beside the app wins (the game copies the other only while it is empty), and a ~/Library save is shown only until the game has copied it across. Confirmation and backups are unchanged. The Mac row says which folder is used, also when there is no save yet. This is the gap @Tiomehsh found on the real devices, so no separate issue is needed.

Checked

  • Tests: cd frontend && swift test (490 tests, 0 failures), python3 scripts/patches.py check (ok). New SaveDiscoveryTests with a faked devicectl cover: discovery of a non-launcher install, bundle matching, two devices and the selector state, a hanging query hitting the timeout and its late answer dropped, a real hanging process stopped by the deadline, Refresh while a query runs, a device that is not connected, both save layouts with copies in each direction, and the Mac save location with temporary folders for a library folder, the default location and both at once (migration).
  • Visual QA: not captured. The sheet's visual QA test now hands in two devices, so the selector would show in NX_LAUNCHER_CAPTURE_DIR=<dir> swift test.
  • Tested by @Tiomehsh on 2026-10-30 at c331dab on a real iPhone 16 Pro and iPad Pro (P5R installed through LCSign): discovery without an install record, reading Documents/save, the device picker, Refresh disabled while reading, and a byte-identical round trip. The Mac library-folder path was not part of that test.
  • Run by us on a device or Mac: not run. The app was not launched and devicectl was never run against a real device. Still untested: devicectl's own --timeout wording, and the complete UI transfer with the library-folder layout (asked of @Tiomehsh).

Screenshots

None yet, see above.

Scope

  • No vendored file (dm/, scripts/, docs/, ref/, AGENTS.md) is edited directly: a change there is a patch in patches/ (scripts/patches.py export, and patches.py check passes), with its Upstream-Status
  • A fix to the engine or a game profile is also (or first) a PR at seedds/nxnative: this PR's patch says forwarded seedds/nxnative#... (not applicable, launcher only)
  • No keys, game files or data extracted from a game in the change or the attachments

This is a feature, so it waits 48 hours before merging.

@v0lumehi v0lumehi added enhancement New feature or request launcher The NX2Apple launcher app ios iPhone or iPad labels Oct 30, 2026
@github-actions github-actions Bot added the windows Windows (the Qt front end) label Oct 30, 2026
@v0lumehi
v0lumehi force-pushed the v0lumehi/saves-discovery branch from 7e4d660 to fd3571b Compare October 30, 2026 16:26
v0lumehi and others added 2 commits October 30, 2026 17:59
Manage > Saves no longer needs the launcher's install record or the signed
app it cached: the game is found on the device from `devicectl device info
apps` (the launcher's bundle ID, any bundle ID holding the title ID, then
the display name), so a game installed from the exported IPA with another
signing tool works. Both save layouts are read, Documents/save and
Documents/games/<title ID>/save, and a copy goes to the one in use.

With several devices the sheet shows a selector and names the device it
asks. A device that is not connected is not asked at all. Every devicectl
command has a deadline, a query that outlives its own gets a clear message,
Refresh is off while one runs, and an answer that arrives after its query
was given up or replaced is dropped.

Closes #250

Co-authored-by: Tiomehsh <[email protected]>
@v0lumehi
v0lumehi force-pushed the v0lumehi/saves-discovery branch from fd3571b to 227534c Compare October 30, 2026 17:02
…ch folder is used

A Mac game in a library folder (.nx2apple-library beside the app) keeps its save in save/<title ID> there. The Saves window now uses the host's rule instead of the games/ folder, prefers that folder over the default location when both exist, and shows the folder under This Mac.

Co-authored-by: Tiomehsh <[email protected]>
On a real device the flag deletes the destination's siblings too, not only
its contents. A save push to Documents/games/<id>/save removed the game's
romfs.img, and a cheats push removed what sits beside Documents/games/<id>/cheats.

The copies now merge into the destination and delete nothing. A file the Mac
no longer has can stay in the device's folder, which is far safer than wiping
game data (devicectl has no command to delete a single file). The stand-in
devicectl in the tests now wipes the parent's entries when the flag is passed,
and the tests assert the flag is never passed and that game data stays.

Found and reproduced on real devices by Tiomehsh (#250).

Co-authored-by: Tiomehsh <[email protected]>
@v0lumehi

Copy link
Copy Markdown
Collaborator Author

Pushed the same fix as #266 onto this branch (cherry-picked, so it merges cleanly in either order): the launcher never passes --remove-existing-content any more, the fake devicectl models the sibling wipe, and a save push is tested to leave Documents/romfs.img, env.txt and the game folder alone. Found by @Tiomehsh.

@v0lumehi
v0lumehi merged commit 63a076a into main Oct 30, 2026
10 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/saves-discovery branch November 1, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ios iPhone or iPad launcher The NX2Apple launcher app windows Windows (the Qt front end)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve installed-game save discovery and allow choosing an iPhone or iPad

1 participant