TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Remove Xcode live preview data?

Forums > SwiftUI

Hi everybody

While developing and testing my SwiftUI views, I have created files in the documents directory of the simulator which is running the live preview.

Is there any easy way to clear the apps container? I tried to "Clean build folder", which didn't help. As the simulator is not visible and cannot controlled in the same way as a regular iOS simulator, I cannot simply delete my app.

Sometimes the content disappears... but I do not understand exactly when. I tried to stop/start the live preview, restarting Xcode, ...

Has somebody found a solution?

kr Philipp

3      

Two places to look:

Derived Data: Xcode -> Preferences -> Locations -> Derived Data ^^ that will tell you where the folder is. Then you can look into the folder named YourAppName-{some long string of characters}/Index/...

If you are storing data in CoreData, you can look here:

~/Library/Containers/{your.bundle.identifier}/Data/Library/Application Support/{YourAppName}

Hope that helps!

3      

Try clearing the data model completely.

Setup a do catch for your core data persistent stack and pass the error into a fatalError message

} catch {
    fatalError("The database failed to load: \(error)")
}

This will then print the error in ~/Library/Logs/DiagnosticReports

The printed error should show you a URL where you can find the .sqlite file.

Delete the directory at the /preview level.

I also deleted the /preview folder that had a 'dateModified' of today, because my error was specifically 'failed migration'. So I figured the model from the referenced (older) folder was trying to migrate to the current.

3      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.