title: iOS simulator only uses the first app folder for localStorage files but creates a new app folder for everything else
body: <p>I'm trying to delete the localStorage files of my app, and to do that I need to know where the app stores its cached data, but I don't consistently get the correct path in the iOS simulator, this only works consistently on the phone.</p>
  
  <p>I think this has something to do with the fact that Xcode <a href="https://stackoverflow.com/q/25233386/1465640">renames the app directory</a> when you rebuild. If I delete the entire <code>/Users/john_doe/Library/Developer/CoreSimulator/Devices/</code> and start the app <code>NSSearchPathForDirectoriesInDomains</code> finds the correct folder. On the next build the path that is returned is the new application directory, but the iOS simulator still uses the localStorage files in the old folder.</p>
  
  <p>The code I run in Xcode to find the caches path: <code>NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomainMask.UserDomainMask, true).last as! String</code></p>
  
  <p>tl;dr iOS simulator gives you a <a href="https://stackoverflow.com/q/25233386/1465640">new application folder</a> every time you stop and rebuild the app, but it uses the application folder from the first build for writing and reading the localStorage files.</p>
  
  <p>Anybody have a workaround? A bug on this with Apple?</p>