Repository navigation
Conversation
3 tasks done
…through an iCloud Drive folder Until now a save moved between the Mac and an iPhone only by hand (the Mac front end's Saves sheet, over the cable). The apps are signed ad hoc or with a free/personal team, so CloudKit and iCloud entitlements are out; a folder the player picks in iCloud Drive is not. dm/host/save_sync.c packs the committed save (DM_SAVE and DM_SAVE_device) into one file, <folder>/<title ID>/save.dmsync (a folder named after the title ID is taken as the game's own), because iCloud replaces a file as a whole but syncs a folder file by file. The cloud's copy comes in at the game's first save mount, before the work directory is cloned; the committed save goes out a few seconds after a Commit on a thread of its own, when the iPhone app goes to the background, and from the Mac launcher once the host has exited. <DM_SAVE>.sync keeps the hash of the save last known to be the same on both sides: only the cloud's changed, it comes in; only this one changed, it goes out; both changed, the newer wins. Every save this replaces, here or in the cloud, is kept first in <DM_SAVE>-backups/<date> local|cloud. The folder is chosen in each app's launcher: Cloud saves in the Mac settings window (dm/mac/Launcher.swift, defaults key cloudSaves.folder, read by launcher.c) and on the iPhone (a security-scoped bookmark, CloudSaves.m). DM_SAVE_SYNC (a folder, icloud, or 0) overrides both. On the iPhone the copies go through NSFileCoordinator (SaveSync.m), which downloads a file iCloud has only listed. Tested: dm/host/tests/t_save_sync.c (47 checks, also under TSan and ASan/UBSan), and TOTK 1.4.3 between an iPhone and a Mac in both directions on the NX2Apple fork. There the iPhone bookmark shared code with the fork's game-data picker. Here CloudSaves.m holds it on its own, and that iPhone part is not yet tested on a device.
LNPANDY
pushed a commit
to LNPANDY/NX2Apple
that referenced
this pull request
Oct 29, 2026
The same change is open upstream as seedds/nxnative#617. The patch goes when it merges.
LNPANDY
added a commit
to LNPANDY/NX2Apple
that referenced
this pull request
Oct 29, 2026
Mark the cloud-saves patch as forwarded to seedds/nxnative#617
seedds
added a commit
that referenced
this pull request
Oct 29, 2026
…Cloud Drive folder (PR #617) A save moved between the Mac app and the iPhone app only by hand. The apps are signed ad hoc or with a free team, so CloudKit and iCloud entitlements are out; a folder the player picks in iCloud Drive is not. dm/host/save_sync.c packs the committed save (DM_SAVE and DM_SAVE_device) into one file, <folder>/<title ID>/save.dmsync, because iCloud replaces a file as a whole but syncs a folder file by file. The cloud's copy comes in at the game's first save mount, before the work directory is cloned; the committed save goes out a few seconds after a Commit on a thread of its own, when the iPhone app goes to the background, and from the Mac launcher once the host has exited. <DM_SAVE>.sync keeps the hash of the save last known to be the same on both sides: only the cloud's changed, it comes in; only this one changed, it goes out; both changed, the newer wins. Every save this replaces, here or in the cloud, is kept first in <DM_SAVE>-backups/<date> local|cloud; the newest 10 of each side stay. The folder is chosen in each app's launcher: Cloud saves in the Mac settings window (dm/mac/Launcher.swift, cloudSaves.folder, read by launcher.c) and on the iPhone (a security-scoped bookmark, CloudSaves.m; copies through NSFileCoordinator, SaveSync.m). DM_SAVE_SYNC (a folder, icloud for iCloud Drive/nxnative Saves, or 0) overrides both. On top of the PR: the Mac launcher sends the DM_SAVE the host used (an env file may set another folder than the app's own), with trailing slashes stripped as the host strips them; backups are pruned to the newest 10 per side; the fork's names (NX2Apple Saves, the front end's Saves sheet) are gone; docs/frontends.md makes the Mac folder (cloudSaves.folder in the app's preferences, DM_SAVE_SYNC at launch) part of the front-end contract, so a front end can set or change it for every game; impact_map.tsv maps save_sync.* and the Mac Launcher.swift. Tested: t_save_sync (54 checks, also under TSan), the host tests, test_nsp_mac_app, test_launcher_settings; regress.py not run; TOTK 1.4.3 between an iPhone and a Mac on the NX2Apple fork. The iPhone part of this split is not yet tested on a device. Co-authored-by: mindw0rk <[email protected]> Co-authored-by: v0lumehi <[email protected]>
Owner
|
Thanks! This landed on Changes on top of the PR:
The iPhone part of this split is still untested on a device. |
1 of 3 tasks
3 tasks done
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
…Cloud Drive folder (PR seedds#617) A save moved between the Mac app and the iPhone app only by hand. The apps are signed ad hoc or with a free team, so CloudKit and iCloud entitlements are out; a folder the player picks in iCloud Drive is not. dm/host/save_sync.c packs the committed save (DM_SAVE and DM_SAVE_device) into one file, <folder>/<title ID>/save.dmsync, because iCloud replaces a file as a whole but syncs a folder file by file. The cloud's copy comes in at the game's first save mount, before the work directory is cloned; the committed save goes out a few seconds after a Commit on a thread of its own, when the iPhone app goes to the background, and from the Mac launcher once the host has exited. <DM_SAVE>.sync keeps the hash of the save last known to be the same on both sides: only the cloud's changed, it comes in; only this one changed, it goes out; both changed, the newer wins. Every save this replaces, here or in the cloud, is kept first in <DM_SAVE>-backups/<date> local|cloud; the newest 10 of each side stay. The folder is chosen in each app's launcher: Cloud saves in the Mac settings window (dm/mac/Launcher.swift, cloudSaves.folder, read by launcher.c) and on the iPhone (a security-scoped bookmark, CloudSaves.m; copies through NSFileCoordinator, SaveSync.m). DM_SAVE_SYNC (a folder, icloud for iCloud Drive/nxnative Saves, or 0) overrides both. On top of the PR: the Mac launcher sends the DM_SAVE the host used (an env file may set another folder than the app's own), with trailing slashes stripped as the host strips them; backups are pruned to the newest 10 per side; the fork's names (NX2Apple Saves, the front end's Saves sheet) are gone; docs/frontends.md makes the Mac folder (cloudSaves.folder in the app's preferences, DM_SAVE_SYNC at launch) part of the front-end contract, so a front end can set or change it for every game; impact_map.tsv maps save_sync.* and the Mac Launcher.swift. Tested: t_save_sync (54 checks, also under TSan), the host tests, test_nsp_mac_app, test_launcher_settings; regress.py not run; TOTK 1.4.3 between an iPhone and a Mac on the NX2Apple fork. The iPhone part of this split is not yet tested on a device. Co-authored-by: mindw0rk <[email protected]> Co-authored-by: v0lumehi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
A save moves between a game's Mac app and its iPhone app only by hand. These apps are signed ad hoc or with a free team, so CloudKit and iCloud entitlements are not available. A folder the player picks in iCloud Drive is.
dm/host/save_sync.cpacks the committed save (DM_SAVEandDM_SAVE_device) into one file,<folder>/<title ID>/save.dmsync. iCloud replaces a single file as a whole, but syncs a folder file by file. The cloud copy comes in at the game's first save mount. The committed save goes out a few seconds after a Commit, when the iPhone app goes to the background, and from the Mac launcher after the host exits.<DM_SAVE>.syncholds the hash of the last save both sides agreed on, so the host knows which side changed. When both changed, the newer save wins. Every replaced save is first copied to<DM_SAVE>-backups/<date> local|cloud.The folder is chosen in each app's launcher:
dm/mac/Launcher.swift, defaults keycloudSaves.folder, passed on bylauncher.c).dm/ios/Sources/Launcher.swift. The folder is a security-scoped bookmark inCloudSaves.m. Swift reaches it throughDmIOS-Bridging-Header.h. The copies go throughNSFileCoordinatorinSaveSync.m, which downloads a file iCloud has only listed.DM_SAVE_SYNC(a folder,icloud, or0) overrides both. The switch is indocs/env_switches.tsvanddocs/settings.md.The feature was written by @dreamw0rk for the NX2Apple fork (LNPANDY/NX2Apple#185). The commit keeps him as the author. There the iPhone bookmark shared code with a game-data picker that nxnative does not have. I moved the cloud-save part into
CloudSaves.h/.mand the Cloud saves section of the iPhone launcher.hle_fs.cusesDM_GAME_IDfor the title ID.Checked
make -C dm/host GAME=010015100B514000make -C dm/host/tests GAME=010015100B514000 run, including the newt_save_syncwith 47 checksmake -C dm/host/tests GAME=010015100B514000 tsan-threads, which includest_save_synct_save_syncunder ASan and UBSanpython3 -m unittest dm.tools.tests.test_nsp_mac_app dm.tools.tests.test_launcher_settings dm.tools.tests.test_docsdm/ios/tests(39 tests)clang -fsyntax-onlyofCloudSaves.m,SaveSync.mandfront_ios.magainst the iOS 26 SDKregress.py: not run. The change adds a save hook tohle_fs.cthat does nothing whileDM_SAVE_SYNCis unset and no folder is picked. The other games' paths are unchanged.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index). Not applicable, this is a feature.docs/settings.mdanddocs/env_switches.tsvdescribe it.dmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change. Not applicable.