GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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 try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

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.