Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an iOS app have write access inside its bundle?

Tags:

ios

I save some run-time generated files inside the .app bundle of my iOS app. In the simulator it works fine, in the device it crashes:

Could create output files in the given shader cache path '/var/mobile/Applications/CB064997-B40E-4FE3-9834-B3217CE33489/SimedTest.app/Ogre3D/assets/RTShaderLib/cache/

Is there a good overview of where I should and shouldn't put files - how to use Documents, Library and tmp, etc?

To clarify, these are files created at startup which pre-calculate some data to save time. IF they are not present they get created so it's fine they are deleted, but not while the app is running.

like image 333
Mr. Boy Avatar asked Oct 01 '12 19:10

Mr. Boy


1 Answers

The bundle is read-only. You don't want to mess around with it for two reasons:

  • Code Signing: the signature is verified by against the contents of the bundle; if you mess around with the bundle, you break the signature.
  • App Updates: updates work by replacing the entire app bundle with a newly downloaded one; any changes you make will get lost.

Where you should save stuff:

  • Documents: if you want it to persist and be backed up
  • Library/Caches: if you just want to cache downloaded data, like profile pics; will be auto deleted by the system if it is low on room unless you specify with a special do-not-delete flag.
  • tmp: temporary files, deleted when your app is not running

For a full explanation check out File System Programming Guide and QA1719.

like image 103
benzado Avatar answered Nov 12 '22 02:11

benzado