Skip to content

Install: show when the signature expires, and renew it without rebuilding - #151

Closed
LNPANDY wants to merge 3 commits into
task-145-reinstall-saveipafrom
task-145-resign-expiry
Closed

LNPANDY wants to merge 3 commits into
task-145-reinstall-saveipafrom
task-145-resign-expiry

Conversation

@LNPANDY

@LNPANDY LNPANDY commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Second half of #145. Stacked on #149 (it edits the same install card and string table): review/merge #149 first, then retarget this to main.

A free Apple ID's provisioning profile lasts 7 days. The game stops starting a week after install, no sideloader can renew it, and the only way back was a full rebuild.

What changes

  • Expiry, read from the signature. The app's embedded.mobileprovision (CMS-wrapped plist) is read with security cms -D and its ExpirationDate shown: the game card's status line gets "· 3 days of signature left" (orange at two days or fewer, help text with the date), and the hero shows the full date. Whole calendar days, so the switch happens on the day iOS would refuse to start the app.
  • Re-sign in the hero, at any time (the count only changes colour at two days or fewer, the button is always offered): the install's xcodebuild line — same project, scheme, destination, -derivedDataPath, -allowProvisioningUpdates, DEVELOPMENT_TEAM, DM_COPY_ROMFS=NO — so Xcode reuses every compiled product and only signs again; then devicectl device install app over itself.
    • PRODUCT_BUNDLE_IDENTIFIER is passed as the installed app's own, not re-derived: the device keeps the app's Documents (game data, saves). The install's taken-App-ID retry must not run here for exactly that reason.
    • Project and derived data are derived from the installed app's path (<work>/xcode-derived-data/Build/Products/...), so no stored build state is needed.
    • An installed app whose profile cannot be read still offers the button (the line says the expiry is unknown).
  • Actionable failures: no cached project (build once more), no signing team, and a failed sign (devicectl's/xcodebuild's own error line plus the Manage Certificates next step), in both languages.

Verified

  • swift test --package-path frontend → 192 tests, 6 skipped, 0 failures (L10n.selfCheck() included).
  • New cases: profile plist → date (and missing/garbage), calendar-day arithmetic and the 2-day threshold, the wording in en + zh, the exact re-sign command (install line + app's bundle ID), the paths derived from an installed app, the re-sign flow through the fake-xcrun fixture (one more xcodebuild -project, no second romfs pack, then devicectl install), and the missing-project/no-team messages.

Not verified

  • A real 7-day expiry and a real re-sign on a device — the owner's. The profile is also only present on installed apps; a Mac app or a build never installed shows nothing, by design.

A device build ends in `devicectl device install app`, so it never writes an
.ipa: deleting the app on the phone meant a full rebuild (extraction, shaders,
signing) to get it back, and nothing could hand the signed build to another
Mac or a sideloader.

The signed .app already sits in xcode-derived-data. The install card now has:

- Reinstall: `devicectl device install app` of that app as it is — no unpack,
  no signing, no packing. The bundle ID does not change, so the device keeps
  the app's Documents (game data and saves).
- Save IPA…: NSSavePanel, then the app as Payload/<name>.app, an ordinary IPA
  a sideloader or another Mac installs while the signature lasts. The game
  data is not in it (it stays in Documents/romfs.img), and --norsrc keeps
  __MACOSX out.

A missing cached app, an expired signature (devicectl's own error line) and a
failed pack each say what happened and what to do, in both languages.

Verified: swift test --package-path frontend -> 183 tests, 6 skipped, 0
failures (5 new: the reinstall command and that it does not build or pack
again, the Payload zip listing, the two missing-app paths, the IPA name).
Not verified: a real device (the owner's).
…ding

A free Apple ID's provisioning profile lasts 7 days: the game stops starting a
week after it was installed, and nothing in the launcher said when. A sideloader
cannot renew it either, so the only way back was a full rebuild.

The launcher now reads the date from the profile the install signed with
(<app>/embedded.mobileprovision, `security cms -D`):

- the game's status line says how many days are left, orange at two days or
  fewer, and the hero shows the date;
- at two days or fewer the hero offers Re-sign: the install's xcodebuild line
  (same project, scheme, destination, derived data, team, DM_COPY_ROMFS=NO),
  which reuses every compiled product and only signs again, then devicectl
  installs the app over itself. PRODUCT_BUNDLE_IDENTIFIER is passed as the
  installed app's own, so the device keeps its Documents (game data, saves);
- a missing cached project, no chosen team and a failed sign each say what
  happened and what to do (the certificate in Xcode → Settings → Accounts →
  Manage Certificates, or the network).

Verified: swift test --package-path frontend -> 192 tests, 6 skipped, 0 failures
(9 new: the profile parse, calendar-day count, urgency, the wording in both
languages, the re-sign command and the paths derived from the installed app,
the re-sign flow through the fake xcrun, and its missing-project/team paths).
Not verified: a real 7-day expiry and a real re-sign on a device (the owner's).
Renewing an app's signature early is as valid as renewing it just in time (a
trip, a demo, a device handed to someone else), and the owner asked for the
button at any time. The hero shows the line for every app installed on a
device; the count stays orange at two days or fewer, and the button is always
there. When the profile cannot be read (an app signed by something else), the
line says unknown and still offers the re-sign.
@LNPANDY

LNPANDY commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

#149 merged. This PR is stacked on its branch, which is now deleted; rebase task-145-resign-expiry onto main in the worktree at /Users/hejie/ZCodeProject/nxnative-task-145 (git fetch origin && git rebase origin/main), push, and retarget the base to main. Its only failing check was the patch queue one, which was main's state before #147/#148 — the rebase clears it. Merge when green.

@LNPANDY

LNPANDY commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Reopened as #156: GitHub cannot reopen this one (its base branch was deleted with #149's merge), so #156 carries the same branch task-145-resign-expiry, rebased onto main, with the re-sign offered at any time. #155 stays stacked on that branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant