App thinning without @3x images and when some images are JPGs

…衆ロ難τιáo~ 提交于 2019-12-04 09:22:19

I performed several additional tests using the procedure proposed by Matt:

  1. When minimum deployment target is iOS 6 no Assets.car is being generated. [UIImage imageNamed:] returns nil for JPG images unless ".jpg" extensions is provided as part of the image name
  2. When minimum deployment target is iOS 7 Assets.car is generated but it contains only those images which were imported in Asset Catalog as PNGs. All JPGs get copied outside of Assets.car. [UIImage imageNamed:] returns nil for JPG images unless ".jpg" extensions is provided as part of the image name.
  3. When minimum deployment target is iOS 8 Assets.car contains all images. Its size is 13MB. [UIImage imageNamed:] returns JPG images correctly even when not specifying ".jpg" extension. Images also load correctly when ".jpg" extension is included
  4. When minimum deployment target is iOS 9 Assets.car contains all images. Its size is 11.5MB. [UIImage imageNamed:] returns JPG images correctly even when not specifying ".jpg" extension. Images also load correctly when ".jpg" extension is included

I have used the image extractor tool suggested by Matt to extract images from these Assets. I was only able to export from archives for devices which are with Retina and I can confirm that all images had correct resolutions (i.e. only retina size, iPad specific images ignored). The tool, however, saved all of them in PNGs format and so the resulting size of the folder was always bigger then Assets.car.

What is most surprising is that the size of the folder was the same (39.4MB) for cases 3 and 4. Also, the images seem to be exactly the same. So, I really wonder what happens there because there is a difference of 2MB in the size of Assets.car for these cases.

To conclude, we are still not sure if such testing method can be used to accurately mimic the App Thinning behaviour. So, if anyone had a personal experience with this it would be awesome if they could share it.

However, assuming that exporting for specific device for AdHoc produces the same result as actual App Thinning performed by App Store we can conclude that:

  1. App thinning only kicks in when deployment target is iOS 7 or later
  2. App thinning for JPG images only works starting from a minimum deployment target of iOS 8
  3. [UIImage imageNamed:] returns JPG images correctly without providing ".jpg" extension only when JPG images are correctly processed through Asset Catalogs. Which, as mentioned earlier, only happens when minimum deployment target is iOS 8 or later
  4. [UIImage imageNamed:] always loads correct images if ".jpg" extensions is specified.

The last two conclusions seem to be irrelevant to this question, but I have found several conflicting opinions on Stack Overflow about how to load JPG images correctly with Asset Catalogs. Some people claimed that you can load them without providing ".jpg" extension whilst others complained that this approach doesn't work. I think 3 and 4 above explain in details what is happening in this case and why people get different results.

Answer your own question. Archive the app. Export the app for the target device you're interested in:

Now look inside the exported app and see what resources it contains. An .ipa is just a .zip file by another name; it's easy to look inside it by changing the suffix. Now you know what resources an iPhone 6 Plus user will download from the App Store.

After getting iPhone4s and iPhone 6SPlus archive, from a project with missing 3x images

then using the image extractor tool suggested by Matt,

deployment target iOS 7

here's the result:

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