Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Does Apple's On Demand Resource System download files to the App's Main Bundle?

Tags:

I am currently trying to implement Apple's API for On Demand Resource Management for AWS Cloudfront because Apple's ODR is somehow too unreliable.

I noticed that when I tag images inside of Assets.scnassets/ with an ODR resource tag, I can access that image using

UIImage(name: resourceName)

once it has been downloaded by a NSBundleRequest object. Because I can access the downloaded resource as a UIImage, I know that the resource is located in the app's main bundle but I thought this was impossible because Bundles were read-only. How did apple do this? The most important aspect is being able to create UIImages using this incredibly simple interface.

like image 695
btomtom5 Avatar asked Jul 17 '18 15:07

btomtom5


1 Answers

I know that the resource is located in the app's main bundle but I thought this was impossible because Bundles were read-only. How did apple do this?

It’s an illusion. ODR files are downloaded to a directory outside the app bundle, and calls like UIImage init(named:) are swizzled to look in that directory.

like image 110
matt Avatar answered Oct 11 '22 16:10

matt