Skip to content

Launcher: option to pack the game files into the IPA - #210

Closed
v0lumehi wants to merge 1 commit into
mainfrom
v0lumehi/full-romfs-option
Closed

v0lumehi wants to merge 1 commit into
mainfrom
v0lumehi/full-romfs-option

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Fixes #184. Thanks to @ceedveed for the request.

The launcher could only build the slim IPA (game files in Documents). LiveContainer and other installers that take one large IPA had no way to get the game files inside it short of the command line.

The iPhone / iPad build options now have a row "Game files inside the IPA", off by default, with a note that iOS refuses packages over a few GB (PackageExtractionFailed), so it suits small games. The choice is kept in UserDefaults like the older-devices switch next to it.

One difference from the issue text: build_ipa_from_nsp.py has no --full-romfs flag. What exists is --romfs bundle and the environment switches DM_FULL_ROMFS=1 and DM_COPY_ROMFS=YES, which build_ipa.sh reads (patches/0004). The launcher passes all three, so no vendored file changes. build_ipa.sh gives DM_COPY_ROMFS precedence over DM_FULL_ROMFS, so DM_FULL_ROMFS=1 alone could be downgraded to a slim app.

When the option is on:

  • The NSP script gets --romfs bundle, and the build environment DM_FULL_ROMFS=1 and DM_COPY_ROMFS=YES. Interaction with Install on the iPhone: game data once per game and version, then the slim app #213: that PR passes --romfs separate and a bundled: parameter for its install-once flow. A full build here never passes separate, so the two do not collide. Once Install on the iPhone: game data once per game and version, then the slim app #213 is merged, its bundled: parameter should be driven by this option (bundled: true is this path), and the explicit --romfs bundle keeps the request intact in the meantime.
  • The post-build RomFS export (games/<id>/romfs.img, the DLC images copy) is skipped.
  • The result card shows two steps (install the IPA, launch) and only the IPA row.
  • Install on device: the app is signed with DM_COPY_ROMFS=YES (explicit, because a Gen/dm.xcconfig that says NO would win over an absent setting), and nothing is copied to Documents afterwards.
  • Re-sign of an installed app passes DM_COPY_ROMFS=YES when the app bundle holds romfs.img or a non-empty romfs, else NO.
  • The artifact is checked: an IPA must list Payload/<app>/romfs.img or romfs/..., a signed app must hold a non-empty romfs.img or romfs. Otherwise the build ends with a message instead of success.
  • Older data on the device: main.m reads Documents/games/<id>/romfs.img before the bundled copy, and a full build carries no romfs.id. devicectl has no way to delete one file (only copy to --remove-existing-content, which empties a whole folder), so clearing is not possible without touching saves and other data. The install is therefore limited to fresh installs: before installing, the app's Documents are listed (read only), and when a slim install's game files are there the install stops with a message (delete the app first, its saves go with it, or turn the option off). An app that is not on the device yet counts as fresh. Nothing is ever deleted.
  • The size of the picked files is shown under the option before the build.
  • A Mac app build ignores the option.

The Qt front end has no build options at all (no older-devices switch either, only the target button), so a toggle there would be a new options page and not a small change. Its back end (win/build_app.py) already reads DM_FULL_ROMFS from the environment, which stays without a UI here. The Qt language table is regenerated for the new strings.

Checked

  • Tests: cd frontend && swift build -c release && swift test 487 tests, 0 failures (16 skipped). FullRomfsTests: off by default, environment and --romfs bundle for an iOS build only, remembered, re-sign passes DM_COPY_ROMFS=YES, artifact checks, listing parser, size, all new strings in zh, en, sv without semicolons. LibraryTests (testFull...): full install flow with stand-in xcodebuild and devicectl (no packArchive, no devicectl device copy, install stops on older game files, fails without game files), full IPA with and without game files. No real device was used. python3 -m unittest discover -s frontend-qt/tests OK, the language table regenerates without a diff. python3 scripts/patches.py check OK.
  • Visual QA: NX_LAUNCHER_CAPTURE_DIR=<dir> swift test --filter FullRomfsTests captures the Builds page in en, zh and sv, switch on and off. The row sits under the older-devices row in the same card style. The PNGs are not attached because the CLI cannot upload images.
  • Run on a device or Mac: not run, no full build or device install was done. The build and install paths are covered by the argument and command tests only.

Screenshots

Not attached (the CLI cannot upload images). The Builds page was captured in English, Chinese and Swedish, and the new row reads "Game files inside the IPA" / 游戏文件放进 IPA / Spelfiler i IPA-filen, with its switch right under the older-devices row.

Scope

  • No vendored file (dm/, scripts/, docs/, ref/, AGENTS.md) is edited directly
  • Not an engine or game profile fix
  • No keys, game files or data extracted from a game in the change or the attachments

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

A setting row in the iPhone / iPad build options, off by default. When on, the
build runs with DM_FULL_ROMFS=1 (build_ipa_from_nsp.py has no flag for it, the
environment switch is what build_ipa.sh reads), and the slim-only steps after
it are skipped: no romfs.img export, no copy to Documents, no send-the-game-data
steps in the result. Installing on a device signs the app with its game files
and a re-sign keeps them.

Fixes #184
@v0lumehi
v0lumehi force-pushed the v0lumehi/full-romfs-option branch from 652b931 to ef7fb40 Compare October 30, 2026 13:49
@v0lumehi

Copy link
Copy Markdown
Collaborator Author

@LNPANDY rebased onto current main, CI green. It is a feature, so it can merge after the 48 hours, from 2026-10-31 17:25 UTC, unless you have objections. It changes iOS builds for players only when the new option is switched on (game files packed into the IPA instead of the slim package).

@LNPANDY

LNPANDY commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Reviewed against current main. The option is a good idea, but as written it can silently do nothing, and it cannot be verified from the current tests.

The precedence that matters is in dm/ios/tools/build_ipa.sh:182-184: DM_COPY_ROMFS wins over DM_FULL_ROMFS whenever it is set. --romfs separate (and its xcconfig line) sets it, so:

  1. DM_FULL_ROMFS=1 alone can lose. ContentView.swift:1298-1300 injects only that variable. Once Install on the iPhone: game data once per game and version, then the slim app #213 (which always passes --romfs separate) merges, the full-package request is downgraded to a slim app while the UI hides the RomFS row and claims the files are inside. Pass --romfs bundle explicitly as well, or take Install on the iPhone: game data once per game and version, then the slim app #213's bundled: parameter.
  2. Omitting DM_COPY_ROMFS=NO on re-sign does not enable the files. If Gen/dm.xcconfig already says NO, Xcode keeps it and stage_resources.sh strips romfs. ContentView.swift:1982 and :2106 should pass DM_COPY_ROMFS=YES in full mode.
  3. Nothing checks that the artifact really contains the game files. ContentView.swift:1946 decides on archive.isEmpty and then reports success. Check DmIOS.app/romfs.img or DmIOS.app/romfs (or the IPA's Payload) and fail with a clear message.
  4. Old Documents data wins over the bundled copy. main.m:112-115 prefers Documents/games/<id>/romfs.img over the app bundle, and a full build carries no romfs.id. A device that was installed slim before keeps using the old image, even after a game update. Either clear that folder on a full install, or restrict the switch to fresh installs.
  5. FullRomfsTests.swift:31-37 asserts only that DM_COPY_ROMFS=NO is absent — which is exactly the case that would pass while point 2 is broken. Assert DM_COPY_ROMFS=YES, and add a full install-flow test (no packArchive, no devicectl device copy).

Two smaller things: docs/env_switches.tsv:44 still calls DM_FULL_ROMFS a diagnostic, and the Qt back end already supports it (win/build_app.py:668) without any UI, so "nothing to add" there is not quite right.

For the size question: the switch is global rather than per game, and a full IPA for a large title is several GB on the device and again in LiveContainer. At least show the RomFS size before the build.

No device test was run here either, so 1-5 are from reading the code paths.

@LNPANDY

LNPANDY commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Closing this one. The launcher path it targets already handles the game data, so the option would only add a way to get the two copies out of step.

What decided it:

  • The Mac launcher's direct install already places the data. signAndInstall installs a slim app and then offers to copy games/<id> into Documents, so a full IPA changes nothing for the players this UI serves.
  • Packing is not unsupported today. DM_FULL_ROMFS=1 (or DM_COPY_ROMFS=YES) already packs romfs.img and the DLC into the app (build_ipa.sh:183); the fork only made the slim package the default because iOS refuses to install multi-GB IPAs. Anyone who wants a self-contained package from the CLI still has it, and the Qt back end carries the same switch.
  • The Windows question can wait. The Qt front end has not shipped, and once it does a sideloaded image can also be moved into Documents in several ways; the UI for that flow is better designed together with the release, not now.

The review above stands as a record of what a full-package option would have to get right (the --romfs separate precedence, DM_COPY_ROMFS=YES on re-sign, verifying the artifact, and the Documents-over-bundle precedence in main.m) — that list is the starting point if we ever revisit it.

Thanks for putting it together; the code was clean and the analysis of the existing switches was accurate.

@LNPANDY LNPANDY closed this Oct 30, 2026
@v0lumehi

Copy link
Copy Markdown
Collaborator Author

@LNPANDY thanks, all five points are in the new commit e2977e1 (rebased onto current main). The PR text is updated too.

  1. Full mode no longer relies on DM_FULL_ROMFS=1 alone. The NSP script now gets --romfs bundle (gameFilesArguments, ContentView.swift near startBuild), and the environment carries DM_FULL_ROMFS=1 and DM_COPY_ROMFS=YES (gameFilesEnvironment). With Install on the iPhone: game data once per game and version, then the slim app #213: that PR passes --romfs separate and has its bundled: parameter. A full build never passes separate, so they do not collide, and once Install on the iPhone: game data once per game and version, then the slim app #213 is in, its bundled: should follow this option (bundled: true is this path). Whichever of the two merges second needs a small rebase there.
  2. Re-sign. signAndInstall and resignCommand pass DM_COPY_ROMFS=YES explicitly in full mode (and NO otherwise). The re-sign decides by appHoldsGameFiles (non-empty romfs.img or romfs/).
  3. The artifact is verified. An IPA must list Payload/<app>/romfs.img or romfs/... (ipaHoldsGameFiles, via unzip -Z1), and a signed app must hold them before devicectl install (appHoldsGameFiles). Otherwise the build ends with msg.fullNoGameFiles and does not count as done. The archive.isEmpty decision is gone, the code uses lastBuildPackedGameFiles.
  4. Older Documents data: fresh installs only. devicectl has no delete for a single file (the only removal is copy to --remove-existing-content, which empties a whole folder, so it would reach saves and aoc/). So I took the second option. Before a full install the app's Documents are listed read only (devicectl device info files ... --subdirectory Documents --recurse). If a romfs.img or romfs is there, the install stops with dev.oldGameFiles (delete the app first, the saves go with it, or switch the option off). An app that is not on the device yet counts as fresh. Nothing is deleted anywhere. The option note says the same.
  5. Tests. FullRomfsTests: DM_COPY_ROMFS=YES and --romfs bundle asserted, re-sign asserts YES and the absence of NO, artifact checks, listing parser, size. LibraryTests has the install flow with the stand-in xcodebuild and devicectl (testFullInstallPacksNoArchiveAndCopiesNothing: no romfs_image, no devicectl device copy, YES on every sign, listing before install), plus stop on older files, fail without game files, fresh device, and the full IPA with and without game files. 487 tests pass, no real device was touched.

Smaller things:

  • Size. With the option on, the row shows the size of the picked files before the build (base, update, DLC, keys excluded). That is the NSP size, so it is a lower bound for the RomFS, not the exact number. It is still global rather than per game, I left that as is.
  • docs/env_switches.tsv:44. That line comes from the fork-only patch 0004-ios-slim-ipa.patch, upstream (seedds/nxnative) has no DM_FULL_ROMFS at all, so there is nothing to propose there. The wording change (diagnostic to player) would be an edit of patch 0004 here. I did not touch it, tell me if you want it as its own small PR.
  • Qt. Its UI has no build options at all (not even the older-devices switch), so a toggle would be a new options page and not a small change. I corrected the PR text instead: the back end reads DM_FULL_ROMFS, the UI does not offer it. Its language table was missing the new strings, that is regenerated now.

Still open, needs a device: a full build installed through the launcher on an iPhone, a slim install followed by a full one (the stop message), and the IPA in LiveContainer. None of that was run.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: add option to use romfs.img or not (i.e. build game files into IPA instead)

2 participants