IOS data protection does not work with already installed app

I want to enable "Data Protection" in my application. Also, I wanted to test if it works with existing applications as I didn't use it at first. To test this, I used the developer provisioning profile. First, I installed the previous application (DataProtection disabled) on my device with the code and made sure that the user's documents are available in the Documents folder. Then I included Data Protection in my provisioning profile and rebuilt the application using this new profile. Then I installed it on top of the previous application. Then I locked the device and loaded the app sandbox using Xcode and noticed that I can access the sandbox without any problem. I've done this a few times, but the sandbox is still available.

Then I uninstalled the app and just installed the app that had data protection enabled. Then I downloaded the Application Sandbox and I noticed that all the folders in the sandbox, including the Documents folder, are empty.

This means that data protection only works on a recently installed application. Am I doing something wrong? I want to incorporate data protection into my existing applications. How can I achieve this?


source to share

1 answer

Since I hadn't paid enough attention to this issue, I submitted it to the Apple Developers Forum. What they offer was after enabling data protection. If we are going to update the application (without removing the old application), we must explicitly set data protection for all files, including the old ones.

So, I did a loop in my document folder and set the data protection attribute to all of my old files. Also I set the data protection attributes in all places where I create new files. This solves my problem.

So the bottom line is if you want to enable data protection in your old application to do it explicitly.



All Articles