iOS On-Demand Resources from a framework or Cocoapod?

1.1k Views Asked by At

Since iOS 9, iOS has an "On-Demand Resources" (ODR) feature to allow Apple to host resources that can be downloaded on demand rather than having them in the app bundle. By tagging assets with resource tag(s), and then using an NSResourceBundleRequest to request assets for given tag(s), we can reduce our app bundle size by keeping infrequently-used assets off device until needed.

Sadly, I've only been able to get it to work with resources that are specifically included in the app target in Xcode. There are times where code and resources aren't included in the app target, but rather in a shared or external framework (e.g. a library distributed through Cocoapods or a shared framework used to share code and assets across iOS, tvOS, watchOS, macOS apps). Ideally, since these frameworks are embedded in your app target in the end anyway, Xcode would simply be able to extract out the resources from the embedded frameworks and tag them for download.

Although these framework targets have the "Resource Tags" section of their project file and we can still configure resource tags in these targets, at runtime, the resource request simply fails with NSBundleOnDemandResourceInvalidTagError. The "Disk" pane in the Debug Navigator also doesn't show a On-Demand Resources section.

I can't find any documentation that specifically states that using ODR is or is not possible using external frameworks. Does anyone know if it's possible, and if so, how it might be accomplished?

0

There are 0 best solutions below