Friday, August 28, 2015

Whats new in iOS 9

In this article I will cover some of the major features and functionalities of iOS 9 and what are the main aspects we should keep in mind so as to make our apps iOS 9 compatible one.

Existing apps will function normally in iOS 9, Ideally Apple will take care of it; which is nothing but “Forward Compatibility”, as it was managing this before in its earlier version releases.

If you want to release an update of your existing app or you are going to release a brand new iOS app, in which you wish to make use of iOS 9 features and make your app compatible with iOS 9 then you need to take care of few stuffs, 

Prerequisites for iOS 9: Xcode 7; iOS 9 SDK is compatible with Xcode 7, So the first and foremost thing any one wants to do is download Xcode 7 from and start using iOS 9.0 SDK.

Before going in to details here is a quick snapshot on crucial points on iOS 9.0,

- Multitasking Enhancements for iPad
- App Transport Security(Adopt/Migrate your web-services to HTTPS asap)
- App Thinning
- Search
- Support for Right-to-Left Languages
- Contacts and Contacts UI
- UI Testing in Xcode 7

1) Multitasking Enhancements for iPad:
iOS 9 enhances the user’s multitasking experience on iPad with Slide Over, Split View, and Picture in Picture

- The Slide Over(below is the reference image) feature lets users pick a secondary app and quickly interact with it.

- The Split View(below is the reference image) feature gives users the ability to use two apps side by side on iPad, both the apps were responsive for user interaction and will run in parallel. 

- The Picture in Picture feature (also known as PiP - below is the reference image) lets users watch video in a window that floats above other onscreen apps.
Picture in Picture feature is for apps whose primary role is video playback.

Apple recommends for existing apps to adopt multitasking enhancements of iOS9 on iPad,If you are releasing any new iPad app or releasing an update for the existing app, Its better that if you adapt your apps for multitasking since users will be expecting all apps with Slide Over, Split View, and Picture in Picture features of iOS 9.

Note: For apps which you are planning to support multitasking enhancements make sure that you are supporting all the interface orientation.” You need to explicitly add the  UIRequiresFullScreen key to our Xcode project’s Info.plist file and apply the Boolean value YES from next update/new release.”

- SplitView functionality will work only from iPad Air 2 and above(with upcoming iPad devices).
- SlideOver and Picture in Picture functionality will work on iPad Mini 2,iPad Mini 3,iPad Air,iPad Air 2 (and with upcoming iPad devices).

Reference for Implementation:

2) App Transport Security

App Transport Security is a feature that requires secure connections between an app and web services. 

Here is a note from Apple mentioned on developer site: “You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.”

“If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.”

Reference for Implementation:

So go ahead instantly and migrate your web-services to HTTPS, if you are developing new services then by default opt for HTTPS services.

For a temporary fix or to bypass App Transport Security in your app, refer

3) App Thinning

The App Store and operating system optimize the installation of iOS apps by tailoring app delivery to the capabilities of the user’s particular device, with minimal footprint. This optimization, called app thinning.

If you adopt App thinning within your apps, then apps will occupy minimum disk space, faster downloads from App store.

App Thinning includes three components: slicing, bitcode, and on-demand resources.

- In general Slicing is recommended as a best practice for every app as-well as developer,
Since Slicing will check the user’s iOS device and based on that specific device it will send a specific installation package(unnecessary resource files will not be included in the package during download process(.ipa))
Below is a reference image(pictorial representation) on how App Thinning will work,

- Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store.

Note: For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. 

- On-demand resources are resources—such as images and sounds—that you can tag with keywords and request in groups, by tag. The App Store hosts the resources on Apple servers and manages the downloads for you. On-demand resources enable faster downloads and smaller app sizes, improving the first-time launch experience. For example, a game app may divide resources into game levels and request the next level of resources only when the app anticipates that the user will move to that level. Similarly, the app can request In-App Purchase resources only when the user buys the corresponding in-app purchase.
Below is a reference image(pictorial representation) on how On-demand resources will work,

Reference for Implementation:

4) Search

Search in iOS 9 gives users great new ways to access information inside of your app, even when it isn’t installed. 
If you adopt iOS 9 Search feature in your apps, it helps you to increase the usage of your app and improve its discoverability by displaying the app content(description of the app) when users search across the system and on the web; even when your app is not installed in users device.

Reference for Implementation:
iOS 9 introduces the following APIs to adopt Search:

5) Support for Right-to-Left Languages

iOS 9 brings comprehensive support for right-to-left languages, which makes it easier for you to provide a flipped user interface.

Arabic, Persian, Urdu are few of the examples for Right to Left languages.

Reference for Implementation:

6) Contacts and Contacts UI

iOS 9 introduces the Contacts and Contacts UI frameworks (Contacts.framework and ContactsUI.framework), which provide modern object-oriented replacements for the Address Book and Address Book UI frameworks.

Reference for Implementation:

7) UI Testing in Xcode 7

Find and interact with UI elements, Validate the UI properties and state, UI recording.
- Xcode 7 introduces UI testing as a major new feature of the existing XCTest framework.
- Now from Xcode 7 and iOS 9 their is a native support for both Unit testing and UI testing.

Reference for Implementation:

Go ahead and explore and make use of this amazing native UI Automation testing support for your apps from Apples Xcode.

For more information & additional new features of iOS 9 refer Apple's official documentation here,

Hope this post is helpful, any comments or suggestions are acceptable and appreciated.

How to make http services work on iOS 9 or how to bypass App Transport Security(ATS) of iOS 9?

By default in iOS 9 if we try to load an HTTP resource in your app it's actually going to try to load the HTTPS version. If the HTTPS version is using security which Apple considers weak, or the server just doesn't support HTTPS at all, the request will fail.

But as a temporary fix for this without migrating your existing services to https is to add Pre-Domain exceptions to your applications info.plist file as below,

1) If you know all the insecure domains which you need to use in our app, then go for the below solution,

      <!--Include to allow subdomains-->
      <!--Include to allow HTTP requests-->
      <!--Include to specify minimum TLS version-->

2) If you don’t know all the insecure domains which you need to use or if you want to completely allow any http request to work within your app, then go for the below solution(add those keys to your apps info.plist file),

  <!--Include to allow all connections-->

Below is a pictorial representation of this solution in the actual info.plist file, for your reference,

NOTE: Disabling or Bypassing App Transport Security is not a good idea and its not recommended by Apple. This is just a temporary fix until you implement App Transport Security for your app. Since It's yet to be seen how hard Apple will come down during app review in the coming years about ATS exceptions we request.

Why Apple is forcing us to implement ATS or to use secure connections is for protecting personal data from being compromised over insecure wireless connections, and making sure our users online activity is properly secured from unwanted network snooping.

The permanent fix for this problem is to go ahead and implement App Transport Security by considering Apple recommended security practices.

While migrating the services from http to https protocol you must consider the Apple recommended security practices listed below,

The protocol Transport Layer Security (TLS) must be at least version 1.2.

Connection ciphers are limited to those that provide forward secrecy.

Certificates must use at least an SHA256 fingerprint with either a 2048 bit or greater RSA key, or a 256 bit or greater Elliptic-Curve (ECC) key.

For more information on this refer Apple's official documentation here,

Hope this post is helpful, any comments or suggestions are acceptable and appreciated.