I have an swift4 app that is having certain issues where on-demand resources packages hang when downloading. The issue appears to be related to different versions of resource bundles being used in testflight environment as opposed to prod. Some users indicate that the packages do not download, but after several days (presumably after the bundles have been purged by the OS), the downloads start working again.
My question is, is there a way to forcibly clear the downloaded bundles rather than waiting for the operating system to remove them at its own leisure. I know it can be done via xcode (via purge in the data panel), but I need a solution that is native to the app itself. (Using the NSBundleResourceRequest.endAccessingResources() function will only stop the resources being used, but will not remove them)
In short, there is no way to delete ODR programmatically. I asked a similar question on Apple Developer forums and got the answer:
There is currently no way to programmatically purge ODR resources. It is up to discretion the OS.
When a new network request for ODR content is initiated, the system will do a sort of inventory check, checking what is currently in memory and if there’s room for new memory. This check also takes into account several other metrics, such as which assets are currently being used, which were used recently, is the asset being used for the UI, etc.
After this is done, the system will determine how much of the chosen assets are to be purged, so that there is enough room to fit the new content. If I remember correctly, the OS will try and delete whole assetpacks. What this means is, if the system is purging assets, it will purge resources that are grouped together such as, all assets from Level 1, Level 2, and Level 3, provided the user is on Level 4. So, the system might purge slighly more space than exactly needed.
If you would like to change your app's ODR assets, you will have to submit an update to your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With