iOS simulator only uses the first app folder for localStorage files but creates a new app folder for everything else

邮差的信 提交于 2019-11-30 14:22:38

问题


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.

I think this has something to do with the fact that Xcode renames the app directory when you rebuild. If I delete the entire /Users/john_doe/Library/Developer/CoreSimulator/Devices/ and start the app NSSearchPathForDirectoriesInDomains 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.

The code I run in Xcode to find the caches path: NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomainMask.UserDomainMask, true).last as! String

tl;dr iOS simulator gives you a new application folder 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.

Anybody have a workaround? A bug on this with Apple?

来源:https://stackoverflow.com/questions/30343373/ios-simulator-only-uses-the-first-app-folder-for-localstorage-files-but-creates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!