XCode Image dimensions #3 - ios

I have a general question about XCode / IOS. I know that i can upload several images for all IOS devices(original,#2,#3). I coded know a app and 30% of the time i needed for image processing. I want to understand the way, how XCode handles images.
My Question: Is it enough, when i just add a #3 image? Does XCode scale it down to all devices while building or does the device (iPhone) itself scaling the images down to optimized sizes while running the app?
Does the One-Image-Method cause performance problems on #2 and #1 devices or will IOS reject the app because of missing images for specific devices?
How are you handling this issue?

You have to include #1x, #2x and #3x in an asset catalog. iOS will then select the correct size for the device.
I personally use Asset Catalog Creator to create all my asset catalogs. It will resize and create all the files for you.

If you only use #3x, Xcode does not scale it down to all device. the device (iPhone) itself does not scaling the images down to optimized sizes while running the app.
This One-Image-Method cause does performance problems on #2 and #1 devices,you cannot see the picture on #2x or #1x devices.
IOS will most probably reject the app because of missing images for specific devices.
If your app is developed for all device , You have to include #1x, #2x and #3x. I use A Xcode plugin Named RTImageAssets to create all my asset catalogs.

Related

iOS App Thinning - How to implement it depending on screen size?

Per default Apple only seems to allow #3x, #2x and #1x as suffixes for images and app thinning.
#3x resources seem to be reserved for iPhone 6/7 Plus, even though their screen resolution is smaller than the resolution of the largest iPad Pro - which seems to use #2x.
Is there any way to specifically have 5 different folders with data and use one folder per actual device resolution that is out there? Those folders would be for example (and any new or in-between resolution would use the closest folder and scale):
568p
1136p
1334p
2048p
2732p
Is that possible somehow?
In the Assets in your Xcode project you can click on the + and add a new image set. There you can right click and add iPhone and iPad individually.

Adding #2x and #3x pictures without 1x version

I've started developing an iOS app, adding pictures in resolution which is ok for standard retina screens. Now I want to add #3x pictures for iphone 6 plus and 7 plus. I don't want to include 1x version for older devices. I've renamed all image files to name#2x but these are not recognized in the project anymore. I was thinking that #2x name modifier will be ignored, but this is not the case. Do I need to explicitely add "#2x" in all places I'm referencing these pictures in the code? Or should I leave standard retina versions without any name change and these will be used anyway as #2x and only use #3x name modifier for higher resolution versions?
Use asset catalogs. See Apple Documentation
Then it's really easy to define 1x, 2x and 3x images by drag&drop. If you load the image in code by name (without scale) it works like a charm. If 1x is missing the next possible image will be used automatically.
You can import pdf-images or well known as vector-images as single vector in assets.Hence No need of 1x,2x,3x seperatly.
You can use Blade
Better asset workflow for iOS developers. Generate Xcode image catalogs for iOS / OSX app icons, universal images, and more.
with a definition file like this will generate all the images for you and put it in the right place
blades:
- source: store/slice1.png # this image should be the only image, and the biggest image you can use (typically for icons, 1024x1024)
mount: Project/Assets.xcassets/AppIcon.appiconset

do I need to include #1x images of app only runs on iphone 4s and above?

Is this still necessary? 2x and 3x seem to be the only images I need based on models I support. What is the correct approach?
If your app is targeted for iOS9 or less then you still have to build for the iPad 2 which does not have a retina display.
http://www.evad3rs.net/2014/10/ios-9-supported-devices-compatibility.html
Even if you're building an iPhone only app they will run on an iPad.
You cannot restrict your app by device. So if you're supporting iOS9 or less (which is every OS version) then you should include #1x images for this reason. If you don't then the #1x devices will just display scaled down versions of the #2x images so you don't NEED to include them... but you should.
What you can do instead (which is something that I have been doing more and more recently) is to use an app like PaintCode. This will take your images and turn them into code. This code is then imported into your project and the images are generated at runtime by the code. They are completely resolution independent and it reduces your app bundle size as you don't have to bundle in any images.
According to IOS Human Interface Guidelines all IOS high resolution devices below IPhone 6, use 2x form of images. So if your app will not run for non-high resolution devices, I am guessing you don't have to add 1x version of images.
Here's the thing, apple reviewers always test your app on the latest and greatest device. They will certainly test your app on BOTH iPhone and iPad using the latest hardware. They don't have time to regression test your app on every possible device (ipad2, iphone3, iphone4, iphone5 etc). Your users on the other hand will let you know when things don't work as not everyone is on the latest hardware.
Now when you create a project you are required to provide icon images. I am sure you know this screen in Xcode. You can see there are places for 1x images. What happens if you don't provide 1x images? Go ahead, archive the project and try to upload to itunesconnect. You will most likely get a validation error that certain images are missing.
Like other said you cannot restrict your app from running on iPhone 4 Vs iPhone 4s and your binary will be stopped from upload if any required images are missing.

iOS Swift Using image.xcassets VS dropping image in xcode folder

In the last 6 months I have been able to make a pretty good app in iOS Swift. But Now I want to touch upon some performance and best practices in development.
So I wanted to know what is the best practice of using images in Xcode? To be specific, I usually drag and drop images in my project folder to use it inside my app. But I know that we can also use image.xcassets to do the same thing.
The question is, which one is the right way? Or which one should be used when?
I have seen in image.xcassets we have to provide 3 images. 1x, 2x and 3x. Does that mean that I am increasing the size of the app (considering I am using many images)? Also how does it effect the performance? Is there any difference in fetching the file from project folder or from image.xcassets?
On the top of my head "Image.xcassets" has a bug in Xcode 6 where you cannot load JPEG images. Other than that, it is the best practice of organizing your images. The 1x, 2x, 3x are for the different screen resolutions of iOS devices. 3x images load on iPhone 6 Plus, 2x on any device with a retina screen (iPhone 6, iPhone 5/5s/5c, iPhone 4/4s, etc), and 1x on some of the older iPads and iPhones

Are #3x images mandatory?

I want to update an app which was developed before there were #3x assets. Will my app get rejected if I don't include a #3x version for every image?
No, the #3x suffix is only recommended if you're supporting iPhone 6+ (iOS 8+) although not required at the current time. Below are the requirements and recommendations for image sizes.
Icon and Image Sizes
If your application supports the device running iOS 7, then it will not get rejected. One of my application was recently approved (a month ago), which doesn't contain any #3x images.
But it needs to be confirmed for the application that developed in iOS 8.
Edit
For your information:
My application was already on AppStore and It was an update.
Found from What's new on iOS 8
Support for a New Screen Scale
The iPhone 6 Plus uses a new Retina HD display with a screen scale of 3.0. To provide the best possible experience on these devices, including new artwork designed for this screen scale. In Xcode 6, asset catalogs can include images at 1x, 2x, and 3x sizes; simply add the new image assets and iOS will choose the correct assets when running on an iPhone 6 Plus. The image loading behavior in iOS also recognizes an #3x suffix.
I fear that you need to provide #3x images for all asset images if you are going to publish your application for iOS 8.0 and for iPhone 6 plus device. As it clearly says that "The image loading behavior in iOS also recognizes an #3x suffix".
I suggest you include #3x images before going for approval.

Resources