Skip to content

Live Activity apply: remove files for activities taken out of the spec - #5

Merged
ayushflow merged 4 commits into
mainfrom
ayush/live-activity-apply-manifest
Nov 30, 2026
Merged

ayushflow merged 4 commits into
mainfrom
ayush/live-activity-apply-manifest

Conversation

@ayushflow

Copy link
Copy Markdown
Contributor

Live Activity apply: remove files for activities taken out of the spec

Before, removing a Custom card from the spec left its generated files, and the Xcode entries that compile them, in the app.

What changes

apply now writes .flutterflow_live_activity_manifest.json in the app's root: every file it generated and the SHA-256 of the content it wrote. On the next run, a recorded file the new spec no longer generates is removed.

What it deletes

  • A recorded file the spec no longer generates, only if its content still matches the recorded hash (or it is already gone).
  • For LiveActivityCards.swift and LiveActivity.entitlements: their lines in project.pbxproj (file reference, group entry, build file, sources phase, the extension's CODE_SIGN_ENTITLEMENTS). Nothing else in the project file changes.
  • Folders left empty by the above.

What it never deletes

  • A file you changed since it was generated: it stays (with its Xcode entries), apply warns <path> changed since it was generated; left in place. on every run until you remove it.
  • Anything when there is no manifest (apps applied with 0.3.0) or the manifest cannot be read. The manifest is written, and the next apply can remove.
  • Anything outside ios/LiveActivity/ and packages/ff_live_activity/, even if a manifest lists it (pubspec.yaml, project.pbxproj, Info.plist, Runner.entitlements, paths with ..).
  • Entries in files apply only edits and cannot tell from yours: NSSupportsLiveActivities, the keychain groups, the Runner's CODE_SIGN_ENTITLEMENTS. Documented in the README.
  • Nothing is written or deleted when validation or the bundle-id check fails.

API

applyLiveActivities(..., onRemoved:), addLiveActivityTarget(..., removedFiles:, keptFiles:). New dependency: crypto. The CLI reports removed N.

Tests

New test/apply_manifest_test.dart: A+B then A only (B's files gone, A's intact, project file equals a fresh apply of A apart from the Runner's own entitlements setting, rerun changes nothing); one of two Custom cards removed (shared files stay); edited file survives with a warning and is cleaned up once deleted by hand; no manifest deletes nothing; unreadable manifest; tampered manifest paths; refused apply writes nothing. All three packages pass; dart analyze --fatal-infos and dart format clean.
Smoke test in a fresh flutter create app: apply A+B, apply A (removed 11 files, no Cards/entitlements entries in the target), apply again (0 changes), flutter analyze clean, flutter build apk --debug builds.

🤖 Generated with Claude Code

…longer in the spec

apply records every file it writes, with a SHA-256, in
.flutterflow_live_activity_manifest.json. A later apply deletes a recorded
file the spec no longer generates only when its content is unchanged, takes
the deleted Swift and entitlements files out of the Xcode target, and
removes folders left empty. A changed file is left in place with a warning.
Without a manifest nothing is deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow
ayushflow requested a review from sbis04 November 27, 2026 18:46

@sbis04 sbis04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Checked in a flutter create app on iOS as well as Android: applied a spec with a Custom card (Delivery) and a progress card, then applied it again without the Custom card. 11 files removed, rerun changes nothing, and the project file lost only the LiveActivityCards.swift / entitlements entries plus the 3 extension CODE_SIGN_ENTITLEMENTS lines. flutter build ios --simulator builds, with LiveActivity.appex embedded. A kept (edited) LiveActivityCards.swift doesn't depend on any removed file, so it still compiles. 150 tests pass, analyze clean.

Nits, non-blocking:

  • Hashes are of the exact bytes, so a checkout with CRLF conversion (git autocrlf on Windows) makes every stale file look edited and keeps it. That fails safe; normalizing \r\n before hashing would avoid it.
  • _staleFiles warns ("changed since it was generated; left in place") before the project/bundle id checks, so those warnings print on a run that then refuses to apply.

ayushflow and others added 2 commits November 30, 2026 13:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngs only once the run applies

A checkout with CRLF conversion no longer makes every generated file look edited. Warnings about changed files are held back until the project and bundle id checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow

Copy link
Copy Markdown
Contributor Author

Both nits fixed in d9a4dfa (main merged in first, both CHANGELOG entries kept).

  • CRLF: \r\n is read as \n before hashing, for the recorded hash and the on-disk check, so old manifests still match. Test: a stale file rewritten with CRLF is still removed.
  • Warning order: the stale-file warnings are held back until the project and bundle id checks pass. Test: a run refused for the bundle id prints none.

Format, analyze (fatal infos) and 152 tests pass.

@ayushflow
ayushflow merged commit 53919ed into main Nov 30, 2026
1 check passed
@ayushflow ayushflow mentioned this pull request Nov 30, 2026
@ayushflow
ayushflow deleted the ayush/live-activity-apply-manifest branch November 30, 2026 18:28
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.

2 participants