Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering iOS 14 Programming

You're reading from   Mastering iOS 14 Programming Build professional-grade iOS 14 applications with Swift 5.3 and Xcode 12.4

Arrow left icon
Product type Paperback
Published in Mar 2021
Publisher Packt
ISBN-13 9781838822842
Length 558 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Mario Eguiluz Alebicto Mario Eguiluz Alebicto
Author Profile Icon Mario Eguiluz Alebicto
Mario Eguiluz Alebicto
Chris Barker Chris Barker
Author Profile Icon Chris Barker
Chris Barker
Donny Wals Donny Wals
Author Profile Icon Donny Wals
Donny Wals
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Chapter 1: What's New in iOS 14? 2. Chapter 2: Working with Dark Mode FREE CHAPTER 3. Chapter 3: Using Lists and Tables 4. Chapter 4: Creating a Detail Page 5. Chapter 5: Immersing Your Users with Animation 6. Chapter 6: Understanding the Swift Type System 7. Chapter 7: Flexible Code with Protocols, Generics, and Extensions 8. Chapter 8: Adding Core Data to Your App 9. Chapter 9: Fetching and Displaying Data from the Network 10. Chapter 10: Making Smarter Apps with Core ML 11. Chapter 11: Adding Media to Your App 12. Chapter 12: Improving Apps with Location Services 13. Chapter 13: Working with the Combine Framework 14. Chapter 14: Creating an App Clip for Your App 15. Chapter 15: Recognition with Vision Framework 16. Chapter 16: Creating Your First Widget 17. Chapter 17: Using Augmented Reality 18. Chapter 18: Creating a macOS app with Catalyst 19. Chapter 19: Ensuring App Quality with Tests 20. Chapter 20: Submitting Your App to the App Store 21. Other Books You May Enjoy

Improvements in machine learning

Improvements to Core ML presented during WWDC2020 will help developers with the development of their machine learning apps, with improvements that upgrade your app models, secure them, and group them in targeted collections. We are going to cover in this section the new Core ML Model Deployment, the new model collections with targeted deployments, and the new model encryption.

Core ML Model Deployment, collections, and targeted deployments

One of the most significant features introduced in WWDC 2020 for Core ML is Core ML Model Deployment. To describe it in simple words, it lets developers update their models on the fly. Developers are no longer required to update the whole app in the AppStore to make changes to their machine learning models. Apps can just download a new mlmodel file from the cloud.

Developers will be able to create machine learning model collections on the cloud and update them on CloudKit. Apps will download those collections and stay up to date, with no version upgrading process in the middle. However, developers don't control the download process. The app will detect that there is a new model version available and will download it when the system decides it's appropriate (for example, in the background while the phone is locked and charging on a Wi-Fi connection). So, developers should take into account that the model update may or may not be fast or in real time. The operating system will have the last word.

A useful feature of model collections is that they can be targeted to different users (for example, users on devices with varying capabilities, such as iPhones vs iPads). Assigning different models to different users can be done with targeted deployments applied to collections. There are six options available to configure and target the model that the device will deploy: language code, device class, operating system, operating system version, region code, and app version.

Model encryption

Starting on iOS 14 and macOS 11, Core ML can automatically encrypt the Core ML models.

Xcode will encrypt the compiled model, mlmodelc (not the original mlmodel). The decryption happens when the app is instantiated and occurs on the device. Moreover, the decryption result is not stored anywhere; it is just loaded into memory.

More good news on this: Xcode will help you to create an encryption key, associate it with your developer account, and it will be stored in the Apple servers automatically. You can always download a local copy for yourself, but the process is not seamless.

When the encryption key is stored in Apple servers, the file is .mlmodelkey. When you want to encrypt your model, you just need to add --encrypt {YourModel}.mlmodelkey to the compiler flags. If you prefer using CloudKit, you just need to provide the encryption key when creating the model archive.

The drawback of this process is this: when the app instantiates, it needs to have an internet connection with the Apple servers to download the encryption key and decrypt your model. If for any reason there is no connectivity, you need to implement your fallback process inside the completion errors of the new {YourModel}.load() method. The completion handler will throw a modelKeyFetch error if the encryption key is not available, and you can act accordingly.

Important note

You should not include the encryption key in your app bundle. It is not necessary, and it can compromise your data.

In this section, we have discovered how we can upgrade our machine learning models without updating our apps, how we can group models into collections and assign them to a different type of users/devices, and how we can have our models encrypted and keep our machine learning data safe with no effort. In the next section, we are going to cover the additions to user privacy.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Visually different images