Reputation: 2991
My app ships with a folder of assets and JSON in the bundle. On first install, it takes the assets and JSON, maps it to core data and deletes the folder upon completion.
This appears to be working as expected, looking at the app bundle in the Finder via iOS simulator, I see the folder deleting and the application's footprint decreasing in size.
However, when running this on the device, the usage in settings doesn't decrease after the folder is deleted. Does anyone know why this would happen?
Thank you for your time.
Upvotes: 0
Views: 62
Reputation: 131471
The simulator is a Mac OS app. App bundles are read/write on Mac OS, so it works.
However, the app bundle on iOS is read-only. Your call to removeItemAtPath will fail on an actual iOS device.
There are various gotchas with the simulator. This is one. Another filesystem gotcha is that on most Macs, filenames ignore case. (I say "most macs" because you can configure the Mac filesystem different ways, some of which are case sensitive and some are not. The default filesystem for Mac OS volumes is not case sensitive.) However on iOS filenames are always case-sensitive. So if you write code that names a file but mismatches the case, it will work on the sim (on most Macs) but fail on a device.
There are other cases where the simulator actually uses Mac OS versions of OS frameworks to implement different APIs, and there are subtle and not-so-subtle differences in the behavior. It used to be that you could write code using NSURLDownload (a Mac OS only class) and it would compile and run on the sim, but you'd get an undefined symbol error when compiling for an actual iOS device. I don't know if this is still true.
The lesson here is to test on actual target devices, early and often.
Another point: Modifying your app bundle is very bad practice even on Mac OS where it works.
Upvotes: 2
Reputation: 122401
You cannot should not modify the app bundle in any way.
A better approach would be to supply a "seed" coredata database to copy into the Documents folder, if it doesn't currently exist.
Upvotes: 0