I'm building a framework, and need to differentiate between a file that is a bundle resource (included in the App Store IPA / static file defined at development time) and a file that the app creates (downloads and saves, or just otherwise writes to a file in application support, temp, or any other writeable location).
I want to do this because the SDK is free to use with a local config file, but using a cloud-based config that updates without shipping an app update is a paid feature.
I've tried a few ways, but I've quickly found ways to defeat my own checks.
- Check file permissions: but the app can just change any file to read only permissions
- Check the file exists in a bundle: but the temp directory (and probably others) are in the main bundle
Any authoritative way to check a file is a bundle resource included in the app release, and not just any old file?
Thanks!
After some testing, this is easier than I thought.
The issue was that testing it is nearly impossible. When test cases are running, the tmp, application support, caches, and documents directories all appear inside the test bundle. In real apps running outside of tests, these directories are outside of that bundle.