4

For an upcoming update to one of my apps I have packed all the image resources into Asset Catalogs.

However, at the moment I do not have @3x version for most of my images. I have checked with the simulator and on iPhone 6 Plus @2x versions are used.

I don't mind this behaviour for two reasons:

  1. The result is good enough for images which I am using
  2. Only 50% of my users are using iOS 9. If I add @3x images the size of my app will skyrocket for those on older OS

Although images load correctly in the Simulator for iPhone 6 plus, I am a bit worried about what happens when I archive my app. In particular, I am afraid that with App Thinning iPhone 6 Plus users will get an app without any images :)

So, I have two questions:

  1. If I do not provide @3x images will @2x be loaded on iPhone 6 plus after my update goes live on the App Store?
  2. Will I still benefit from App Thinning because users with @2x and @3x displays will not be downloading @1x images (and vice versa)? Or will App Thinning not work in this case and users will get the same assets irrespective of their device's screen?

These are trivial questions, but I couldn't find info anywhere online as to what happens when you do not follow Apple's guidelines by not providing @3x images in asset catalogs but your app is still available for iPhone 6 +. In addition, some of my images are in JPG format which adds extra uncertainty because it is not an ideal format for iPhone.

Thanks in advance for any assistance!

Andriy Gordiychuk
  • 6,163
  • 1
  • 24
  • 59
  • So why don't you test and find out? You can export the app thinned to see what it does, right there on your machine. Why not _try_ it? – matt Oct 21 '15 at 03:02
  • @matt thanks for this advice. However, I am not sure how I can see which images will be loaded on which devices by looking at the archive. Can you please expand on this? – Andriy Gordiychuk Oct 21 '15 at 03:13
  • You export the app thinned for, say, iPhone 6 Plus. Now look inside it and see what resources it contains. Now you know what an iPhone 6 Plus user will have in the app. So if the 2x images are there, you know they will be loaded, because that's what happens when there are 2x images and not 3x images. And if the 1x images are not there, you know you _did_ benefit from app thinning. Which is what you asked, is it not? – matt Oct 21 '15 at 03:15
  • @matt that makes sense, thanks. But how do I limit the app only to specific iPhone when archiving? Unfortunately, I do not have 6+ device, so "build active architecture only" doesn't seem to be the option. Sorry if I sound too nooby on this – Andriy Gordiychuk Oct 21 '15 at 03:17
  • Please listen carefully. You do not limit the app when archiving. You limit the app when _exporting_ from the archive. Just try it, you will see! Stop spinning your wheels and just do it. – matt Oct 21 '15 at 03:18
  • https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html – matt Oct 21 '15 at 03:21
  • @matt this tool worked for me. I have added an update to my question – Andriy Gordiychuk Oct 21 '15 at 18:09
  • Fascinating. I feel like now I should leave my answer there, since it proved fruitful after all and might be useful to others, and you should also give an answer giving your conclusions (instead of putting your conclusions in your edited question). You can even accept your own answer (in 48 hours). – matt Oct 21 '15 at 18:20
  • @matt you should definitely keep your answer as it is really helpful. I will post mine soon - there is another interesting thing which I discovered related to how imageNamed can be used with JPGs – Andriy Gordiychuk Oct 21 '15 at 19:01

3 Answers3

4

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.

Andriy Gordiychuk
  • 6,163
  • 1
  • 24
  • 59
3

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

enter image description here

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Thanks a lot! I didn't know this was possible. Will give it a shot tomorrow morning and will update question by providing results. – Andriy Gordiychuk Oct 21 '15 at 03:40
  • 1
    something is broken in this approach. I have tried it and I got all images included. Then I made a simple test and I removed all images from my asset catalog apart from app icon and launch images. These are provided in all variants including 3x. When I archived it and then exported for iPhone 6+ I got all of those images included. Clearly, in the later case, app thinning should strip 1x and 2x images but it doesn't do it. Do you know what might be wrong? – Andriy Gordiychuk Oct 21 '15 at 14:35
  • Unfortunately, that doesn't prove what we want to prove, and neither does the method I proposed, since you wind up with an opaque _.car_ file. I'll delete my answer. I'm sorry it didn't work for this particular issue. – matt Oct 21 '15 at 15:28
  • thanks for your help! I really hope that someone ran into the same issue and can just tell from their experience what happens if I do not include 3x images... – Andriy Gordiychuk Oct 21 '15 at 15:34
  • although I have to say that it is very strange that with such exporting App Thinning never works. As part of the export process there is a message "Performing App Thinning" (or something similar) so one would assume that it actually performs it... – Andriy Gordiychuk Oct 21 '15 at 15:35
  • The thing is, we don't know whether app thinning "works" because we don't know what to expect. – matt Oct 21 '15 at 15:46
  • You might try this tool for looking inside your .car files, although it isn't working for me: https://github.com/devcxm/iOS-Images-Extractor – matt Oct 21 '15 at 15:46
0

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: iphone 4S left, iphone 6 plus right

Ted
  • 22,696
  • 11
  • 95
  • 109
  • It is very strange that some images were not copied at all. Was there any difference between ico-xxx and other images which led to this result? – Andriy Gordiychuk Feb 22 '16 at 13:33
  • should I expect that assets without 3x will be copied in iphone 6plus? – Ted Feb 23 '16 at 06:20
  • I am not sure to be honest. However, what I know for sure is that if none of your assets contain 3x version, 2x images will be copied to iPhone 6 plus. Probably it works differently when some of the assets have 3x version. – Andriy Gordiychuk Feb 23 '16 at 13:39