iOS stores them in
This looks like the path returned by
NSFileManager
for the
NSDocumentDirectory
directory. If so, items store there should be preserved across updates. If this isn’t working for your app then that’s worth investigating because it works for a bazillion other apps.
This folder is in the app bundle, yes?
No. It looks like a path to the app’s container, not the app’s bundle. Consider this code:
let docDir = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let bundleDir = Bundle.main.bundleURL
print(" docDir:", docDir.path)
print("bundleDir:", bundleDir.path)
If you run it on a modern iOS device you get this:
docDir: /var/mobile/Containers/Data/Application/834D6255-CEB6-429E-9F0E-C24E2161BB66/Documents
bundleDir: /var/containers/Bundle/Application/0DA395D2-C136-4ECD-B422-7EAEAED23593/xxsi.app
Note that the app’s container is within
/var/mobile/
, which you can think of as the user’s home directory. In contrast, the app’s bundle is in (the confusingly named)
/var/containers/
.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"