Does Both Referencing an Asset Catalogue and Including it from a Framework Create Duplication?

我与影子孤独终老i 提交于 2019-12-02 05:44:39

Apple's goal is to minimize the space required for assets, so assets are combined and compressed into one file called 'Asset.car'.

When you submit to the app store a process called App Thinning is started that creates variants for different actual devices.

You can mimic the process locally and with a third-party tools even take a look inside the 'Asset.car' file.

I described the whole process in detail in this answer: Pixelated images on iOS10 when building with Xcode 10

To test it myself I did the following:

  • I created a workspace
  • I added a framework
  • I added an app
  • inside the framework I added a 'Media.xcassets'
  • I reference this Media.xcassets from the app
  • I added one picture called 'Regensburg.jpg' to Media.xcassets
  • I use this image in a storyboard

Then I do the process described in my linked answer above and extract the Asset.car file.

When taking a look with the third-party tool inside, one can see that the image is just once there.

So good news: like expected no duplication happens.

Screenshot

In the screenshot you can see:

  • Xcode project structure with framework and app as well as .xcassets in the background

  • usage of the only image inside in the storyboard

  • the extracted Assets.car in Finder in the lower right area

  • finally the mentioned third-party tool in the lower left area, where you see that the file is there just once

More information

Like in my other answer I would recommend to take a look at this WWDC 2018 video: Session 227, Optimizing App Assets, https://developer.apple.com/videos/play/wwdc2018/227/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!