Question

I'm making an iOS application that that populates a UITableView with strings that are stored in a .plist file which is in the app's main bundle (usual place you'd have a .plist). I've noticed that this .plist is getting copied over to my app's Application Directory by the Copy Bundle Resources phase of the build phases. I started wondering if it really needs to be there, since Im accessing it from my app's main bundle, not the Application Directory. So as a test, I deleted the .plist from the Copy Bundle Resources phase, ran the application, and found that my UITableView still gets populated with the strings from the .plist. I've cleaned the build and ran the application again, it definitely works. Two questions:

  1. If security and privacy is of interest to your app, shouldn't you always delete secure/private resources from the Copy Bundle Resources phase so that they can't be accessed?
  2. Why do resources like the Storyboards get copied over by default when they're not actually accessed from there?"

Thanks so much in advance for help

Was it helpful?

Solution

You are making wrong assumptions. The application directory IS the main bundle. When you remove files from the copy phase, they will not be installed in your app, and the app will fail.

The reason it SEEMS to work is that building takes shortcuts. A normal build does not remove files that were put in the bundle by the previous build.

If you do a clean (from the project menu) and then build again, Xcode will delete the previous copy of the app and re-build it from scratch. You should also delete it from your target device/simulator, since it will also pick up left-over resources from a previous build when it copies the new build onto the device.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top