SwiftData SQL file location changed after update?

Hey everyone, I’m having trouble finding my SwiftData SQL files after updating to macOS 15.4 and Xcode 16.3 beta. I used to be able to see them easily, but now they’re gone.

I tried this code to find them:

ContentView()
    .onAppear {
        let folder = FileManager.default.urls(for: .appSupportDirectory, in: .userDomain).last
        print("File location: \(folder ?? URL(fileURLWithPath: ""))")
    }

But no luck. I can’t even find ‘default.store’ using Finder search.

Update: I found the files in ‘/Users/me/Library/Application Support/’ instead of the old location. It looks like all apps are sharing one set of files now.

Is there a way to get separate SQL files for each app again? Any settings I need to change? Thanks for any help!

hey there, i ran into this too! it’s a pain, right? apple keeps changing things up on us. :sweat_smile: have you tried using the app sandbox? that might help keep your files separate. just remember to set the right entitlements in your project. good luck!

I’ve encountered a similar issue after the recent updates. It seems Apple has changed the default storage behavior for SwiftData in the latest versions. While the new shared location might be more efficient for system-wide data management, it can indeed cause confusion for developers used to the old structure.

Unfortunately, there’s no straightforward setting to revert to the previous app-specific file structure. However, you can still achieve separate storage for each app by explicitly specifying a custom URL for your SwiftData container. Here’s a quick example:

let storageURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("YourAppName.store")
let container = try! ModelContainer(for: YourModel.self, configurations: ModelConfiguration(url: storageURL))

This approach allows you to maintain separate SQL files for each of your apps, giving you more control over data management and making debugging easier.

hmm, interesting issue! have u considered using Core Data instead? it might give u more control over file locations. or maybe try digging into the SwiftData documentation for any new configuration options? curious to hear if anyone else has found a workaround!