Store Tracks Core Data DB in Caches on tvOS#361
Merged
Conversation
tvOS sandboxes apps so that only the Caches and temporary directories are writable; Application Support is not. TracksContextManager created its Core Data SQLite store under Application Support, which throws TracksApplicationSupportException / TracksPersistentStoreException when TracksService initializes on Apple TV. (The tvOS Simulator masks this because it inherits the Mac filesystem, so the store only fails on real hardware.) Route the store's base directory to Caches on tvOS, keeping Application Support on all other platforms. The per-bundle-identifier subfolder and directory creation are unchanged, so the store becomes Library/Caches/<bundleid>/Tracks.sqlite on tvOS. Caches is purgeable, which is acceptable for the Tracks event queue since events are flushed to the server. Also make the directory-creation error messages platform-neutral and the store-directory test platform-aware. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
These private helpers now resolve to Caches on tvOS (not Application Support), so the old names were misleading. Rename to platform-neutral, store-oriented names: storeBaseDirectoryURL, storeDirectoryURLForContainerApp, and storeDirectoryURLForAppWithBundleIdentifier:. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
kean
force-pushed
the
fix/tvos-store-directory
branch
from
June 11, 2026 15:48
22691d0 to
8e889c3
Compare
3 tasks
pull Bot
pushed a commit
to Mu-L/pocket-casts-ios
that referenced
this pull request
Jun 11, 2026
Point the Tracks dependency at the commit that stores the Tracks Core Data DB in Caches on tvOS, where Application Support is not writable, so the analytics pipeline no longer throws at TracksService init on Apple TV. Depends on Automattic/Automattic-Tracks-iOS#361. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
TracksContextManagercreates its Core Data SQLite store under Application Support, which isn't writable on tvOS (only Caches and tmp are). On a real Apple TV,TracksServiceinit throwsTracksApplicationSupportException/TracksPersistentStoreException. The tvOS Simulator hides this (it inherits the Mac filesystem), so it only fails on device.Fix
Route the store's base directory to
NSCachesDirectoryon tvOS, keeping Application Support on every other platform. The store becomesLibrary/Caches/<bundleid>/Tracks.sqliteon tvOS. Caches is purgeable, which is fine for the transient Tracks event queue (events are flushed to the server). Also made the directory-creation error text platform-neutral and the store-directory test platform-aware.Testing
testStoreIsInExpectedDirectorypasses on tvOS (store under Caches) and macOS (Application Support);build-for-testingsucceeds for the tvOS Simulator.CHANGELOG.mdif necessary.🤖 Generated with Claude Code