I'm working on an iOS iPhone app that requires two large (~200MB) bundled data files. I've added the data files to my Xcode project ("Target Membership").
When Xcode installs the app onto the iPhone, it does copy the data files over, but they don't appear in the app sandbox at runtime (e.g., /var/mobile/Containers/Data/Application/1485D9CE-B1EF-3A24-9611-43C6CD368572/Documents).
Q1. Where are the data files located, and how can my app access them?
Q2. Can I have Xcode install these files directly into the app's sandbox?
Can my app modify the file contents in the main bundle?
No. Bundles are always read-only on iOS [1].
Or would it have to copy the file from the main bundle into the sandbox and then modify/update it?
That’s not a bad approach for a small file. However, it’s not a great choice given that size of these files. Just running your app for the first time would eat 400 MB of the user’s storage to no benefit. I’ve seen App Review reject folks for doing similar things.
For something this large, best practice is to implement a layered approach. That is:
-
Create a database in the Documents folder.
-
Query that and then, if there’s nothing there, try the read-only copy in the app’s bundle.
This can get quite tricky, depending on the nature of your data.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] See Separate Read-Only and Read/Write Content in Embedding Nonstandard Code Structures in a Bundle.