In this article, I would like to talk about iOS 10 and what you need to do to prepare your apps for iOS 10.
As with every major release, iOS 10 introduces a slew of changes and enhancements. Some are required, others are recommended, and there are also a few changes that can improve your application's user experience. Let's start with an overview of what is required if you build your application against the iOS 10 SDK.
1. App Transport Security Is Coming
The most important change isn't strictly related to iOS 10, but it is important enough that I want to discuss it first. Even though App Transport Security (ATS) has been around since iOS 9, it has always been easy to opt out of ATS by adding the following snippet to your target's Info.plist.
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
But that is about to change. On 1 January 2017, every application submitted to the App Store, including updates of existing applications, will need to comply with the ATS guidelines. This means that your application is required to securely communicate with web services over HTTPS.
If you read my detailed discussion of App Transport Security, then you may remember that App Transport Security defines a set of rules. The servers your application communicates with need to comply with those rules. In other words, making network requests over HTTPS isn't enough. Each server your application talks to needs to be secured by and comply with modern security standards.
You can still define exception domains in the target's Info.plist, but it is no longer allowed to opt out of App Transport Security altogether.
Local Network Connections
I recently ran into a problem related to App Transport Security. The application of a client needed to communicate with other devices on the same network. It talks to other devices using their IP address, which isn't supported by App Transport Security exception domains. And to make things even more complicated, the IP address of a device isn't fixed. It can and will change over time.
Fortunately, as of iOS 10, it is possible to resolve this issue by adding an additional key-value pair to the
NSAppTransportSecurity dictionary in the target's Info.plist. By setting the value of
YES, it is possible to disable App Transport Security for local network traffic.
If you've been struggling with App Transport Security in the past, then I recommend taking a look at the updated App Transport Security documentation. Apple has added a few additional keys that make working with ATS less of a headache.
For example, many applications load content from the web in a web view. Your application often doesn't know what websites the user is going to visit, which makes it impossible to define exception domains for App Transport Security in the target's Info.plist. As of iOS 10, you can disable App Transport Security for web views by setting
YES in the target's Info.plist.
App Transport Security Is Required
What you need to remember is that App Transport Security is required for every application submitted to the App Store after 31 December. Opting out of App Transport Security is no longer possible. Note that the App Store review team requires an explanation from you if you partially opt out of App Transport Security by using an exception, such as
NSAllowsArbitraryLoadsInWebContent. You can read more about this in Apple's documentation.
Apple continues to invest in protecting the privacy of its customers, and that commitment also has consequences for developers. What does that mean for you?
If your application accesses a system service or device capability that requires the user's explicit permission, the user sees a system alert in which the application asks for the user's permission. The content of that alert used to be provided by the operating system if your application didn't specify one. This has changed in iOS 10.
As of iOS 10, your application needs to tell the user why it needs access to a particular system service or device capability. You do this by adding a key to the target's Info.plist. If your application is localized, then you also should provide a translation for the description in the InfoPlist.strings file.
Here is a complete list of the privacy keys available in iOS 10. Most of them should look familiar, but some are new in iOS 10, such as
If you don't add a usage description for the system services and device capabilities your application uses, a warning is shown in the console, and the system alert that asks the user for permission isn't shown to the user. As a result, your application is denied access to that particular service or capability.
"This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSLocationAlwaysUsageDescription key with a string value explaining to the user how the app uses this data."
It goes without saying that the App Store review team rejects any applications that violate this policy. In fact, builds uploaded to the App Store that don't comply with this policy are automatically rejected.
If you use a third-party library or framework in your application, then make sure the correct usage descriptions are added to the target's Info.plist. Libraries and frameworks for ads often require several permissions you may not expect or know about.
3. Swift 3
If you open an existing project for the first time in Xcode 8 and it contains Swift, you are asked to migrate to Swift 3. If you don't feel quite ready yet, Xcode asks you to migrate to Swift 2.3 instead. You have to choose one or the other since Xcode 8 only supports these versions of the Swift language. Swift 2.2.1 and Swift 2.3 are very similar. The most important difference is that Swift 2.3 is compatible with iOS 10, tvOS 10, watchOS 3, and macOS 10.12.
Should You Migrate Today?
Should you migrate to Swift 3 today? Probably not. But don't wait too long. At some point, Apple will require developers to submit applications with Xcode 8, which doesn't support Swift 2.2.1. You could stick with Swift 2.3, but why wouldn't you just make the jump?
It is true that migrating a project to Swift 3 has a dramatic impact on your project's codebase. Almost every line of code changes in some way. The API changes are substantial. But the upside is that you get to use Swift 3. I have been using Swift 3 for several months, and I love it. It is a major improvement over Swift 2.2.1 and Swift 2.3.
If you are working on a large project for a client, make sure you carefully plan the migration to Swift 3. For complex projects, the migration can take several days. The advantages are that you can start using the Swift 3 API, and you also benefit from the improved Swift 3 compiler powered by LLVM and Clang.
4. Enhancements and Deprecations
With every major release of iOS, Apple improves the platform by adding and removing APIs. Several frameworks have received a significant update, and the company also introduced several new frameworks.
Why is that important? If you want to stand out in the App Store, it pays off to keep your applications up to date and add support for new features of the platform. That's what this section is about.
UILocalNotification class is deprecated as of iOS 10. What does this mean for you? You can still use
UILocalNotification to schedule and manage local notifications, but it will probably go away at some point. But why has Apple decided to deprecate
UILocalNotification? It worked fine, right?
In iOS 10, Apple introduced the User Notifications framework. As the name implies, the framework is in charge of scheduling, managing, and handling notifications, local and remote. That is what makes the framework great. Your application no longer needs to make a distinction between local and remote notifications. The User Notifications framework offers a unified API for handling local and remote notifications.
The API looks and feels very nice. The framework treats local and remote notifications the same from a developer's perspective, which makes adding notification actions easy and transparent. Handling notification actions is centralized in a concise delegate protocol.
We have some tutorials about the User Notifications framework right here on Envato Tuts+!
You might also be interested in my recent blog posts about scheduling local notifications and notification actions with the User Notifications framework.
One of the bigger announcements during this year's WWDC was the possibility to integrate your application with Siri through SiriKit. Even though the options are limited for the time being, if your application fits into one of the supported categories, it is a great way to set your application apart from the competition. Siri currently supports a limited number of domains, including VoIP calling, messaging, and workouts.
You integrate with Siri by adding an extension to your application. Every application integrating with Siri needs to add an intents extension. It allows your application to carry out a task in response to information Siri sends to your application. You can optionally create an intents UI extension to customize the look and feel of the resulting user interface that is presented to the user after the task is completed.
The brand new haptic engine of iPhone 7 and iPhone 7 Plus has opened up many new possibilities for developers. In iOS 10, it is possible to use the haptic engine of the device to provide the user with tactile feedback when they perform a specific action or a particular event occurs.
Your application can drive the haptic engine through the
UIFeedbackGenerator class and its three concrete subclasses:
UIFeedbackGenerator subclass is designed for a specific scenario. If you add support for the haptic engine, you are certainly going to amaze the users of your application. Give it a try.
Core Data is probably my favorite Cocoa framework, and Apple has made it even more awesome on iOS 10 and with the release of Swift 3. This is the biggest update the framework has seen in the last few years.
Swift 3 and Xcode 8 join forces to make Core Data easier to use than ever before. Apple also introduced the
NSPersistentContainer class, which makes setting up and managing a Core Data stack a breeze.
The company even revamped the underpinnings of the framework by rethinking the interaction of the framework with SQLite. The results are truly fantastic. It is great to see that Apple continues to invest in Core Data, more than ten years after its introduction on macOS Tiger.
To learn more about Core Data, check out some of our other courses and tutorials here on Envato Tuts+.
- iOSGet Started With Core DataMarkus Mühlberger
- Core DataCore Data and Swift: Core Data StackBart Jacobs
- iOSData Validation With Core Data: Common ConstraintsBart Jacobs
What Should You Do?
If you build your application against the iOS 10 SDK, which means you are using Xcode 8, then you need to make sure you comply with App Transport Security and the privacy guidelines Apple has put into place. Make sure you tick those boxes first.
Even though the other enhancements and improvements are optional, I encourage you to take a look at them. For example, don't wait too long to migrate to Swift 3. You could surprise your users by adding support for the haptic engine. It's optional, but it's an opportunity to stand out in today's crowded App Store.
To learn more about Swift 3 or iOS 10, check out some of our other courses and tutorials.
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post