Getting Your App Ready for iOS 8
This year’s unveiling of iOS 8, and new devices at WWDC and September 9th event marks the arrival of new features and changes that iOS developers should utilize in order to keep their apps relevant and offer their users richer experiences.
Apple users have always been quick to adapt to new versions of operating system compared to other platforms. The Apple website shows that 92% of devices are running iOS 7. With this high adoption rate, you can be assured that a large percentage of your app users will be using the latest version of the OS shortly after its release on September 17th. So you should be taking advantage of the new features it offers to build better apps to give them an edge amongst the competition.
The iPhone 6 and iPhone 6 Plus present developers with another factor to consider: yet another screen size (two, in fact).
The iPhone 5 announcement presented a similar change that developers had to take into consideration. With its larger screen, developers had to design apps that would work on the previous 3.5’ and the new 4.0’ screens. Shortly after that release, Apple started favoring apps that conformed to the new screen size. It was a disadvantage to not update your apps as this meant losing exposure on the App Store.
Months after the release, Apple stopped accepting apps that didn’t support the new screen size. A similar condition was enforced months after the release of iOS 7, when Apple specified that new apps submitted had to be built with the iOS 7 SDK. With this history, it is clear that upgrading your app is advantageous to you and at times necessary. This is especially true if version changes are so drastic that older apps cannot function as expected on newer devices.
But this is not exactly the case with the iPhone 6 and iPhone 6 Plus. With the release of the iPhone 5, apps designed for the smaller 3.5’ screens did not work well with the larger 4.0’ screen and so an update was imperative. But with this year’s new phones and their 4.7’ and 5.5’ screens, developers do not need to update their apps for them to work with the new phones. As Apple’s Phil Schiller said during the event, apps on the store that haven’t been updated to work with the new iOS 8 technologies, will “just work” on the larger screens. He went on to further explain this:
“Built into iOS is a desktop size scaler technology that makes the software look beautiful on different size displays and so the text is sharp, the colors are beautiful. It all just works”.
Even though your old apps will work on the new phones, Apple still encourages developers to update and build for the new screen sizes using new technologies. A large theme in this year’s WWDC conference was building for adaptivity. Not only will this ensure that your apps work well on all supported iPhones, it will also enable you to build iPhone and iPad apps with the same code base and storyboard files.
The iOS 8 release was deemed as the “biggest release since the launch of the App Store” at the WWDC conference. It is said to have over 4,000 new developer APIs.
We cannot cover every change, but will outline the most notable new features and improvements that developers should be aware of to update or build their apps for iOS 8.
We’ll also look at how changes to Xcode, the App Store and iTunes Connect can help improve your workflow and make app development and distribution more efficient.
This article briefly outlines the changes, but in the upcoming months, we will be posting articles that take a deeper look into how to use these new and improved APIs.
We’ll categorize the changes in four broad areas – UI, Integration, Games and Development, Testing and Distribution.
Many changes have been made to UIKit to enable the creation of apps that adapt to different screen sizes, orientations and devices. This includes unified storyboards, adaptive view controllers, adaptive presentations, and adaptive text and tables.
Unified Storyboards for Universal Apps
Previously when developing a universal application, you would create separate storyboards for the iPhone and the iPad. In iOS 8, you can work on the same storyboard to create interfaces that work well on the iPhone and iPad in different orientations.
This is achieved by adjusting your UI components for different size classes. Size classes define the canvas size used in layouts. There are compact and regular size classes and either one can be horizontal or vertical.
When you create a project, Interface Builder starts out in the size class for any width and height. You can use this to layout what is common in your app across all size classes. Then you select different class sizes and set up UI components and constraints for the different corresponding sizes and orientations.
For example, an iPad in both landscape and portrait will have a regular size class in both the horizontal and vertical direction. While an iPhone in portrait will have a compact horizontal size class and a regular vertical size class, and when it’s in landscape it will be compact in both the vertical and horizontal size classes.
One size class doesn’t necessarily map to one device in one orientation. For example, in an iPad layout you could have a view with an iPhone style layout (i.e. compact horizontal size class and a regular vertical size class) when appropriate in smaller spaces on the iPad.
With unified storyboards, you can now create a user interface that will adapt itself to the space it is contained within.
Adaptive View Controllers
With adaptive View Controllers, you can have the same code in your views for both iPhone and iPad without undertaking device checks.
One view controller class that has changed the most is
UISplitViewController. Previously this would be used when writing iPad versions of your application while you wrote different View Controller code for your iPhone version.
With iOS 8, the Split View Controller is now available on both platforms, so you can write one view controller hierarchy that works on iPhone and iPad. On the iPad and in iPhone landscape mode, the Split View Controller will present a side-by-side two-column view and in iPhone portrait mode, it will present a two-page-single-column view.
When creating presentations, you can now write code that is simple and device agnostic but performs correctly on each device.
You can write code without any device checks that will present a full screen modal on iPhone and get something more appropriate such as a form sheet on iPad.
Another example is a popover appearing as expected in the horizontal regular Size Class and appearing as an oversheet in the horizontal compact Size Class.
This can now be done for alerts, popover and search views.
Adaptive Text and Tables
Dynamic Text was introduced in iOS 7, which enabled users to change the size of text in apps. A feature pushed in iOS 8 is dynamic type everywhere.
Table views have also changed to respond to variations in text size. You can now create tables that respond to changes with dynamic type rows without implementing the delegate method
Table view cells natively support autolayout so tables should have a consistent view across different screen sizes.
Notifications and Widgets
In iOS 8, users can interact with notifications and take actions such as reply to a message, confirm a contact request, or like a Facebook post, without switching apps.
Your app must first register to use notifications regardless of whether it is going to display remote user notifications or local user notifications.
Location Based Notifications
You can now create location aware notifications, that for example, appear once a user enters or leaves a certain area.
3rd party applications are now able to define widgets that can appear in the notification center. Your app can present information and offer interaction to the user without requiring them to launch the app.
Here we look at the new APIs that allow developers to extend iOS by adding functionality to system and third-party apps.
Handoff lets a user start an activity on one device and pick it up seamlessly on another, which could be a Mac, iPhone or iPad.
To include this feature, you create an activity to track user actions on a device, e.g. opening a web page. When the context changes, you update that activity. The OS takes care of advertising the activity across all your devices that are near. This update contains only the metadata of the activity such as the url or scroll position, you will have to find your own methods of transferring actual data to other devices.
iOS 8 lets you extend your app’s functionality and content throughout the OS by supplying an app extension. Code that enables custom functionality within the context of a user task. With extensions, you can provide users with the power of your app whenever they require it.
iOS supports app extensions for the following areas, which are known as extension points:
- Action: Perform a simple task with the selected content.
- Share: Share content with social websites or other entities.
- Photo editing: Edit a photo or video within the Photos app.
- Today: Enable a quick task or update in the Today view of Notification Center.
- Storage provider: Provide a document storage location that can be accessed by other apps.
- Custom keyboard: Provide a custom keyboard that the user can choose in place of the system keyboard for all apps on the device.
Each extension point defines appropriate APIs for its purposes.
HealthKit provides a platform where applications can store and share health related information. You can now build apps that can access data from other health apps or health devices. The user has control over what apps can access which information.
The HomeKit framework enables users to communicate with and control supported devices in their homes using iOS devices. This is achieved by issuing commands using Siri. If you are building home automation applications, you should definitely look at the potential HomeKit provides.
CloudKit enables you to write client-server applications without having to write the server part. CloudKit enables you to focus on writing client applications while functionality such as cloud storage, authentication and database maintenance is handled for you. All for free within very high limits.
This feature enables users to authenticate using TouchID inside your application. This means that you can eliminate password fields that tend to make authentication tedious. When utilized, your app will be notified whether authentication was successful or not but it will not give the user’s biometric information. This means the user’s information is always private and secure.
PhotoKit and new Camera APIs
The new photos framework enables you to create applications that can access and edit photo and video assets managed by the Photos app. This is undertaken without having to import them first or create copies. With the iCloud photo library, you can access the entire user collection of photos and videos. You can edit these without worrying whether they are local or in the cloud, changes made will be reflected across all devices. New Camera APIs give full manual control over the camera’s settings. Your app can take direct control over the camera focus, white balance, and exposure settings.
A document picker View Controller class is introduced in iOS 8. You no longer have to write completely custom code to give users a document selection experience. You can now build a document picker into your app that has access to documents in the local and in the iCloud drive scope. If any other app is supplying a document provider extension to the OS, those documents will also appear in your document picker.
A new settings pane combines your app’s preferences with the system preferences into one place. This gives your users a quick way to access and change settings without leaving your app.
In last year’s WWDC conference, Apple introduced game controllers. These are controllers that you can snap onto your device to control the games played on that device. This year Apple announced controller forwarding, a new feature that enables users to snap an iOS device into a game controller and be able to use the controller buttons, device’s touch screen and motion to control games running on iPads or Macs. Developers creating games for these platforms should take these new control options into account when developing apps that support controllers.
SpriteKit was introduced in iOS 7 as a high performance 2D game engine with built-in physics support. With iOS 8, there have been improvements made to SpriteKit. These include graphics technologies such as shaders, lighting and shadows that help create rich game scenes.
The following simulation technologies have been introduced: per-pixel physics occlusion, physics field, universal kinematics and constraints. These improvements will enable developers to enhance the look of their games and to build richer user interactions.
SceneKit is a 3D scene renderer which was previously available only on the Mac, has been introduced to iOS 8. It has an integrated physics engine, particle systems and support for scripted actions. SceneKit can be integrated with SpriteKit to include 3D objects in your 2D games.
Metal enables high performance for graphics rendering and computational tasks because of its low-overhead access to the A7 and A8 GPU.
Before, developers would use OpenGL to access the GPU to create optimized graphics rendering. Metal improves on this by reducing the performance overhead and bottlenecks that were previously present. With Metal, you can now squeeze maximum performance from the devices A7 and A8 chips to create rich graphics and experiences in your games that will delight your users.
Development, Testing and Distribution
With the introduction of Swift came Playgrounds. Playgrounds enable you to write and test code interactively. When you create a Playground document, you will see a two pane window in which you write your code on the left side pane and receive real-time results on the right side pane. With this new feature you can test code without launching your app on a simulator or device. This will speed up your programming workflow.
Document Playgrounds combine the power of interactive playgrounds and documentation. While reading documentation, you can change the code in the file and immediately receive feedback as you would in a regular playground.
Interface Builder Changes
When creating views, it can be difficult to keep track of your view placement in the view hierarchy. Especially as you add view elements, laying them one on top of the other.
Before Xcode 6, Interface Builder could only show you a 2D flat view of your interface. This was not very useful when debugging the layered UI and developers would usually turn to third party applications like Reveal to help them debug their views.
With Xcode 6, you have a live interactive method to debug your UIs. You can look at how UI elements are stacked in you view by using 3D visualization. You can remove layers from the view to better access the layers underneath.
Not only does this give a better visualization of your view hierarchy, but you can make changes to the views and see immediate results, making debugging much easier.
Changes to Interface Builder Canvas
The interface builder canvas is now more interactive than ever. Before there were some changes that you could not preview on the canvas when building your app. You had to run the app on a device or simulator to see the changes you had made.
An example of this is localized text. You had to run the app to view localized text on your UI but now this is rendered live on the canvas. Custom fonts and views can also now be rendered live on the canvas.
Xcode 6 comes with the option of selecting a resizable iPhone simulator and a resizable iPad simulator. You can use these to input custom values for the hardware size of the iPad or the iPhone and test the adaptivity of your code on the fly.
Simulator Custom Configurations
The new iOS simulator enables you to keep data and configuration settings grouped together. Run one configuration for one version of an app with its own data and another configuration for a different app version. This means that you will be able to simulate multiple users on your machine. Each user will have their own data and configurations.
Using Interface Builder Documents for Launch Images
With iOS 8 you can now provide an Interface Builder document and at runtime the OS generates all the necessary launch images for your app. With this feature you will not need to provide individual assets for launch images and you can design your launch presentation in interface builder.
In the past all tests ran synchronously. This could be restrictive as you might be using a large number of APIs which are asynchronous. New APIs have been added to XCTest that allow the creation of asynchronous control flow that manages asynchronous activities. This is achieved through expectation objects (XCTestExpectation), which describe expected events. XCTestCase has a new API that waits for the expectation to fulfill and sets a timeout.
A completion handler is called either when all the events are fulfilled or when the timeout hits. It can be waiting on multiple asynchronous events at the same time making it easier to test code and system interactions that execute asynchronously such as file IO, network requests etc.
In app development, code changes can introduce performance regressions. The improved XCTest framework can measure and quantify the performance of different parts of an application. You can set a baseline performance metric on a test. The test will be run several times and on each run, the performance is compared to subsequent runs, measuring the change over time. If the average performance measure deviates considerably from the baseline, the test will fail, alerting you to a performance regression.
With the introduction of performance testing comes the ability to profile tests in Instruments. You will be able to select a test or test suite to profile and undertake further investigation and analysis using Instruments as to why the test failed and the cause of the regression.
Developers can bundle their apps to provide users a way of buying two or more of their apps at a discount. The bundles can have up to 10 apps and there are some conditions set by Apple such as:
- You can only have up to ten App Bundles available at any given time.
- An individual app may be included in up to three App Bundles.
- An App Bundle is available in all countries where every individually included app is available.
- Apps contained in a bundle must also be available for sale on their own.
- App Bundles support Complete My Bundle. Complete My Bundle provides customers who previously purchased one or more of the apps included within a bundle an additional discount on the App Bundle price.
You can now create app preview videos which will appear on your app details page in the App Store. You have a chance to show customers what your app does, which could be the clincher to convince them to download it.
Changes to iTunes Connect
TestFlight Beta Testing
TestFlight Beta Testing allows developers to invite users to beta test pre-release versions of their apps and provide feedback before releasing the apps to the App Store. You are able to invite up to 1,000 beta testers (users, not devices) to test your app.
iTunes Connect now provides developers analytics for their apps that give insights into App Store views, downloads, engagement and retention. Such information was previously obtainable through third-party SDKs but now developers can get it direct.
Many frameworks in iOS have been modified to take advantage of modern Objective-C syntax:
- Designated initializers have been annotated with
NS_DESIGNATED_INITIALIZERso you’ll now know which are designated initializers.
- Getter and setter methods are replaced by properties in most classes. Code using the existing getter and setter methods should continue to work with this change.
- All return types for initializers have changed from
In most cases, these changes don’t require extra work, but you may want to implement the changes in you Objective-C code, especially to modernize your code when interoperating with Swift code.
Other Notable Mentions
Below I list other technologies that Apple unveiled at the WWDC conference and the recent 9.9.2014 event that are notable.
At WWDC, Apple surprised and/or delighted developers by introducing a new programming language for Cocoa and Cocoa Touch. Swift, has apparently been in the making for four years and is said to be, well, swift.
It builds on the best of C and Objective-C, without the constraints of C compatibility. The good thing about swift is that it works with objective-C code. This interoperability is advantageous to developers because as you begin to update your apps to this new language, you do not have to throw away previous code and libraries.
The iOS Dev Center now offers Xcode 6 GM seeds which you can download and start getting your apps ready for the public release of iOS 8. With the GM seed of Xcode 6 and iOS 8, Swift is now final, and you can submit your iOS apps written with Swift to the App Store.
At its recent event, apple unveiled its rumored and anticipated smartwatch, the Apple Watch. The watch will start selling early 2015 and the good news for developers is that it will also run third party apps.
The WatchKit framework, an addition to iOS 8, will enable developers to build apps for the Apple Watch.
Apple Pay is a new service that Apple introduced in its recent September 9th event. The service offers users an easy, secure and private way to make payments without physical money or credit cards. Apple Pay will work with iPhone 6, iPhone 6 Plus and the Apple Watch. Apple Pay will launch in the US as a free update to iOS 8 this October.
Apple plans on releasing Apple Pay APIs that will enable developers to build apps that utilize this mobile payment option.
There are a lot of new features and technologies Apple have introduced this year to enable developers to create the next level of apps.
To keep your app updated and to offer your users an even better experience will require you incorporate some of these new features in you app, especially if you hope to stay ahead of the competition in the App Store.
What features are you most excited about developing for or using?