-1

I am developing a multi-platform app in XCode 14. My previews read + write data to the Application Support directory for my app, and use @AppStorage properties.

How do I delete all the data for previews? I'd like to reset all the @AppStorage values and file storage, but every article or tutorial seems to be outdated. How do I reset all this data for XCode previews?

I have tried to delete various files and directories based on various tutorials. I have seen some articles and tutorials mention menu items that don't seem to exist in XCode 14.

For instance, I have old files in the "Application Support" directory for my app that are causing issues and I just don't know how to get rid of them.

I would also like to completely erase any @AppStorage values.

Essentially I just want to create a state that mirrors a situation where my app has NEVER run. On my physical iPhone, it's easy enough to just delete the app and reload it from XCode. But the XCode previews are a total mystery to me. I also haven't found a way to reset data for the macOS build.

I just cannot believe it's meant to be so difficult to reset the data. Am I missing something?

halfer
  • 19,824
  • 17
  • 99
  • 186
jnfjnjtj
  • 409
  • 4
  • 10
  • Request you add the links which you tried already. It'll help the community to provide you with quick solutions. – Nirmit Dagly Jul 18 '23 at 23:49
  • @NirmitDagly I agree and I'm so sorry that I don't have them available. It was a lot of random Googling and trial and error. However, the only answer I've gotten so far did link to a thread where a comment did solve my issue. I'm trying to add more to that answer now and mark it as accepted but SO is having some kind of edit queue issue right now. – jnfjnjtj Jul 19 '23 at 00:12

1 Answers1

2

You can try the following steps:

  • Open terminal.
  • Go to your project directory.
  • Run the following command:

xcrun simctl --set previews delete all

This should clear your preview cache data and it should load fine.

Edit from OP:

Run sudo xcode-select -s /Applications/Xcode.app first.

jnfjnjtj
  • 409
  • 4
  • 10
Nirmit Dagly
  • 1,272
  • 1
  • 12
  • 25
  • I have seen that suggested before online, but I don't have `simctl`. What am I missing? I thought I had the full stack installed. Is `simctl` a separate install? (`xcrun` is installed) – jnfjnjtj Jul 18 '23 at 23:44
  • It is a command line tool that should have been set in XCode. Follow the link to resolve this error: https://stackoverflow.com/questions/29108172/how-do-i-fix-the-xcrun-unable-to-find-simctl-error – Nirmit Dagly Jul 18 '23 at 23:47
  • Unfortunately that linked answer isn't helpful. My settings were already all the defaults. I even deleted some of the directories the UI told me about and my XCode previews still retain all of their data, even after quitting XCode and restarting. The `simctl` command never became available. However - I will continue to research the `simctl` angle. That seems to be the ticket here. – jnfjnjtj Jul 19 '23 at 00:03
  • WAIT another post on that thread did solve the problem for me. I'm trying to edit your post to add the additional info but SO is experiencing too many edits right now apparently. I will accept this after I add the additional info! In case I don't make it into the edit queue, it's the simple command `sudo xcode-select -s /Applications/Xcode.app` that fixed it all and allowed me to run `simctl` via `xcrun` – jnfjnjtj Jul 19 '23 at 00:09