Description
When setting up a SQL database on tvOS, I always get an error
You don’t have permission to save the file “Application Support” in the folder “Library”.
Error Domain=NSCocoaErrorDomain Code=513
Looking at the code I realize, in many places the library attempt to create
try FileManager.default.createDirectory(
at: .applicationSupportDirectory,
withIntermediateDirectories: true
)
like in Metadatabase.swift, SyncEngine.swift and in DefaultDatabase.swift
These calls will always fail because tvOS apps can't have a support directory.
When I switch to in memory database, some of the errors disappear except the SyncEngine's.
When called, the SyncEngine will try to create a defaultMetadatabase that in turn will try to create the applicationSupportDirectory. This will throw and the entire sync engine initialization fails.
For tvOS I think the best case scenario is to use .cachesDirectory and if the OS purges it, then on next App launch all data will be re-downloaded from iCloud.
Checklist
Expected behavior
Allow the use of different folders on tvOS, like the .cachesDirectory to avoid always throwing an error.
Actual behavior
on tvOS the library always fails with an error You don’t have permission to save the file “Application Support” in the folder “Library”. when using a SyncEngine and iCloud.
Reproducing project
- Setup a Vanilla project.
- Import SQLData
- Configure an iCloud identifier and setup your project with it.
- Create a basic Database initialization (like in the docs) + configure a Sync Engine (keep everything vanilla)
- Run on a real tvOS (on a simulator this will succeed)
SQLiteData version information
1.6.1
Sharing version information
2.8.0
GRDB version information
7.10.0
Destination operating system
tvOS 26.5
Xcode version information
26.5
Swift Compiler version information
Description
When setting up a SQL database on tvOS, I always get an error
You don’t have permission to save the file “Application Support” in the folder “Library”.Error Domain=NSCocoaErrorDomain Code=513Looking at the code I realize, in many places the library attempt to create
like in
Metadatabase.swift,SyncEngine.swiftand inDefaultDatabase.swiftThese calls will always fail because tvOS apps can't have a support directory.
When I switch to in memory database, some of the errors disappear except the SyncEngine's.
When called, the SyncEngine will try to create a
defaultMetadatabasethat in turn will try to create theapplicationSupportDirectory. This will throw and the entire sync engine initialization fails.For tvOS I think the best case scenario is to use
.cachesDirectoryand if the OS purges it, then on next App launch all data will be re-downloaded from iCloud.Checklist
mainbranch of this package.Expected behavior
Allow the use of different folders on tvOS, like the
.cachesDirectoryto avoid always throwing an error.Actual behavior
on tvOS the library always fails with an error
You don’t have permission to save the file “Application Support” in the folder “Library”.when using a SyncEngine and iCloud.Reproducing project
SQLiteData version information
1.6.1
Sharing version information
2.8.0
GRDB version information
7.10.0
Destination operating system
tvOS 26.5
Xcode version information
26.5
Swift Compiler version information