Skip to content

refactor(store): move the persistence layer into a shared FlipcashStore package - #755

Merged
bmc08gt merged 1 commit into
feat/database-app-group-storefrom
refactor/shared-store-package
Sep 11, 2026
Merged

bmc08gt merged 1 commit into
feat/database-app-group-storefrom
refactor/shared-store-package

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Third of four PRs behind the push-preload work. Stacked on #754.

The problem

The notification service extension cannot reach Database while it lives in the app target. Xcode's synchronised file groups do not offer a way in: all three PBXFileSystemSynchronizedBuildFileExceptionSet entries in this project list Info.plist as an exclusion, which is the only thing the mechanism does. A file cannot join a second target that way, so sharing code with the extension means a package.

What moved

Flipcash/Core/Controllers/Database/ becomes FlipcashStore, a new target in FlipcashCore linked into both Flipcash and NotificationService. It is separate from FlipcashCore rather than part of it so that everything depending on the models does not also pull in SQLite. The SQLite.swift dependency is branch-pinned to match the app project's reference to the same fork, because SPM resolves one version of it for the whole graph.

NotificationContent is deliberately not wired to the package. It reads NotificationPreviewCache, the JSON side-car, and nothing in this PR changes that.

The move itself is mechanical: types the app target already used become public, and import FlipcashStore is added to the 28 app files and 38 test files that read through the database. No behaviour change.

Two things that did not move cleanly

  • Updateable stayed in the app target. It is a SwiftUI @Observable wrapper that re-queries on .databaseDidChange, not persistence. The app target defaults new types to @MainActor and a package target does not, so in the package its init could not send self into a @MainActor task.
  • Database is open rather than public, so the test bundle's TempDatabase can keep tying temp-file cleanup to the database's lifetime. Its members stay public: a subclass can add state but cannot override behaviour. The alternative was rewriting 96 makeTemp() call sites around a wrapper type.

Where the tests live

The database tests stay in the app test bundle rather than moving to a package test target, so they keep running on the simulator. The two failures this store hit during #754 — SQLITE_CANTOPEN on a read-only WAL open with no -shm, and SQLITE_IOERR from same-inode aliasing across the move — are iOS-specific and did not reproduce on macOS. A package test target would have hidden both.

Next

PR 4 makes the extension write its prefetched messages into the store instead of only into the side-car.

…re package

The notification service extension cannot reach `Database` while it lives in the
app target. Xcode's synchronised file groups do not offer a way in: all three
`PBXFileSystemSynchronizedBuildFileExceptionSet` entries in this project list
`Info.plist` as an exclusion, which is the only thing the mechanism does. A file
cannot join a second target that way, so sharing code with the extension means a
package.

`Flipcash/Core/Controllers/Database/` becomes `FlipcashStore`, a new target in
`FlipcashCore` linked into both `Flipcash` and `NotificationService`. It is
separate from `FlipcashCore` rather than part of it so that everything depending
on the models does not also pull in SQLite. The SQLite.swift dependency is
branch-pinned to match the app project's reference to the same fork, because SPM
resolves one version of it for the whole graph.

The move is mechanical: types the app target already used become `public`, and
`import FlipcashStore` is added to the 28 app files and 38 test files that read
through the database. Two things did not move cleanly:

- `Updateable` stayed in the app target. It is a SwiftUI `@Observable` wrapper
  that re-queries on `.databaseDidChange`, not persistence. The app target
  defaults new types to `@MainActor` and a package target does not, so in the
  package its `init` could not send `self` into a `@MainActor` task.
- `Database` is `open` rather than `public`, so the test bundle's `TempDatabase`
  can keep tying temp-file cleanup to the database's lifetime. Its members stay
  `public`: a subclass can add state but cannot override behaviour.

No behaviour change. The database tests stay in the app test bundle so they keep
running on the simulator — the read-only-WAL and same-inode failures this store
hits are iOS-specific and do not reproduce on macOS.
@bmc08gt bmc08gt self-assigned this Sep 11, 2026
@bmc08gt
bmc08gt merged commit 37d0ece into feat/database-app-group-store Sep 11, 2026
bmc08gt added a commit that referenced this pull request Sep 11, 2026
…re package (#755)

The notification service extension cannot reach `Database` while it lives in the
app target. Xcode's synchronised file groups do not offer a way in: all three
`PBXFileSystemSynchronizedBuildFileExceptionSet` entries in this project list
`Info.plist` as an exclusion, which is the only thing the mechanism does. A file
cannot join a second target that way, so sharing code with the extension means a
package.

`Flipcash/Core/Controllers/Database/` becomes `FlipcashStore`, a new target in
`FlipcashCore` linked into both `Flipcash` and `NotificationService`. It is
separate from `FlipcashCore` rather than part of it so that everything depending
on the models does not also pull in SQLite. The SQLite.swift dependency is
branch-pinned to match the app project's reference to the same fork, because SPM
resolves one version of it for the whole graph.

The move is mechanical: types the app target already used become `public`, and
`import FlipcashStore` is added to the 28 app files and 38 test files that read
through the database. Two things did not move cleanly:

- `Updateable` stayed in the app target. It is a SwiftUI `@Observable` wrapper
  that re-queries on `.databaseDidChange`, not persistence. The app target
  defaults new types to `@MainActor` and a package target does not, so in the
  package its `init` could not send `self` into a `@MainActor` task.
- `Database` is `open` rather than `public`, so the test bundle's `TempDatabase`
  can keep tying temp-file cleanup to the database's lifetime. Its members stay
  `public`: a subclass can add state but cannot override behaviour.

No behaviour change. The database tests stay in the app test bundle so they keep
running on the simulator — the read-only-WAL and same-inode failures this store
hits are iOS-specific and do not reproduce on macOS.
bmc08gt added a commit that referenced this pull request Sep 11, 2026
…discrete-curve

* origin/main: (27 commits)
  fix(database): share one SQLite writer per owner and take write locks up front (#759)
  feat(chat): declare the payment action on tip DM payments (#752)
  refactor(chat): drop the deprecated new_messages overlay (#757)
  feat(notifications): write prefetched messages into the shared store (#756)
  refactor(store): move the persistence layer into a shared FlipcashStore package (#755)
  feat(database): move the SQLite store into the App Group container (#754)
  feat(database): open the store on demand, close it on background (#753)
  feat(nse): extension crash reporting, a WAL checkpoint, and on-device push hooks (#751)
  feat(home): long-press the You tab to open the account switcher (#749)
  fix(tests): reset Photos access before the previous app instance lingers (#746)
  chore: bump version to 2026.9.2 (#745)
  revert: back out the Coinbase Stable Swapper authority migration (#747) (#750)
  fix(swap): follow the Coinbase Stable Swapper authority migration (#747)
  fix(tests): cancel a cash link through the details screen (#744)
  fix(chat): make the whole Send Cash pill tappable while it stands alone (#743)
  fix(username): drop a leading @ in the validator (#742)
  fix(chat): scope the send-button spring to the button (#741)
  fix(transactions): tighten the details card stack and drop the header badge (#740)
  fix(transactions): draw View in Chat as a card, not the primary action (#739)
  feat(chat): flash the message a reply-quote jump lands on (#738)
  ...

# Conflicts:
#	Code.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	FlipcashCore/Package.swift
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