tptcat
tptcat

Reputation: 3961

Allowed to delete files/folders from Main Bundle resources?

I am designing an app that will come bundled with some audio files. They'll total about 50MB in size. The app will allow you to download other audio files via in-app purchase. My goal is to have all of these files stored in one location (the Documents Directory).

What I'm doing in my code is this:

  1. On first launch, copy the bundled songs from Main Bundle Resources to the documents directory.
  2. Delete the files from their original location in the Main Bundle Resources.

I have all of this working fine so I know it's possible to do. My question is can anyone point me to Apple documentation/guidelines that says I'm not allowed to do this? Or, is this perfectly acceptable according to Apple's guidelines? I know they don't want you writing to the Resources folder, but haven't been able to find a definitive answer on deleting.

Upvotes: 1

Views: 2068

Answers (2)

Rob Napier
Rob Napier

Reputation: 299375

The documentation you're looking for is in the App Distribution Guide [emphasis mine]:"

Code signing your app allows the operating system to identify who signed your app and to verify that your app has not been modified since you signed it. Your app’s executable code is protected by its signature because the signature becomes invalid if any of the executable code in the app bundle changes. Note that resources such as images and nib files are not signed; therefore, a change to these files does not invalidate the signature.

That said, as I noted in my comments on @Wain's answer, this probably isn't a great thing to do if the files are read-only. It adds a big copy step on first launch, and you have to deal with it again on every upgrade.

Upvotes: 3

Wain
Wain

Reputation: 119031

It is not acceptable and will not work when running on a device (I guess you're testing on the simulator). You can't edit the bundle contents. The bundle is signed and editing it will invalidate the signature.

It would be advisable to deploy the app without the audio files and then to start downloading them as soon as there is a (suitable) internet connection after first launch (if this is an option for you).

Upvotes: 3

Related Questions