简体   繁体   English

按需资源 - 强制清除/清除下载的资源包

[英]On-demand resources - Force purge/clear of downloaded resource bundles

I have an swift4 app that is having certain issues where on-demand resources packages hang when downloading.我有一个 swift4 应用程序,该应用程序存在某些问题,即下载时按需资源包挂起。 The issue appears to be related to different versions of resource bundles being used in testflight environment as opposed to prod.该问题似乎与 testflight 环境中使用的不同版本的资源包有关,而不是 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.我知道它可以通过 xcode 完成(通过数据面板中的清除),但我需要一个应用程序本身固有的解决方案。 (Using the NSBundleResourceRequest.endAccessingResources() function will only stop the resources being used, but will not remove them) (使用 NSBundleResourceRequest.endAccessingResources() 函数只会停止正在使用的资源,而不会删除它们)

In short, there is no way to delete ODR programmatically.简而言之,无法以编程方式删除 ODR。 I asked a similar question on Apple Developer forums and got the answer:我在 Apple Developer 论坛上问过类似的问题并得到了答案:

There is currently no way to programmatically purge ODR resources.目前没有办法以编程方式清除 ODR 资源。 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.当发起对 ODR 内容的新网络请求时,系统将进行某种库存检查,检查当前内存中的内容以及是否有新内存的空间。 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.此检查还考虑了其​​他几个指标,例如当前正在使用哪些资产,最近使用了哪些资产,是用于 UI 的资产等。

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.这意味着,如果系统正在清除资产,它将清除组合在一起的资源,例如级别 1、级别 2 和级别 3 的所有资产,前提是用户处于级别 4。因此,系统可能会清除比实际需要的空间略多。

If you would like to change your app's ODR assets, you will have to submit an update to your app.如果您想更改应用的 ODR 资产,则必须提交应用更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM