WWDC,2020 which was held in June this year. Apple has announced all the new features and improvements that will be available for the developers all around the globe. As expected, many new features and advancements were rolled out. This has created a lot of excitement in the developer’s community.
I will discuss the changes made in Xcode and Swift in this article. The latest Xcode has many new features which will greatly help developers in the development process.
The Swift language updates make coding better and much safer too.
1. When we run the Xcode, the option to create a Playground is now removed from the Xcode’s Welcome window. To create a new Playground, developers would have to open it from File —> New —> Playground menu options.
2. The Xcode 12 look, feel and styling is made to match the look and feel of the new macOS. There are many changes that add to the overall developer’s experience, will increase the usability of Xcode and productivity of developers. Now, any file when double-clicked will open in a new tab.
3. Code Completion suggestions by Xcode have also improved. The new UI for code completions is now more informative and concise. Also, non-matching items are not included in the suggestions. Also, it has become much faster now. Apple claims that repeated code completion invocations inside Swift function bodies are now up to 12 times faster as compared to Xcode 11.5
4. SwiftUI Previews have changed too, now there are buttons to run a live preview of current SwiftUI view, run preview on the device, add/edit modifiers whose code gets automatically created and can be reviewed, and a button to duplicate the preview. Previews now even allow adding controls and media.
5. Xcode 12 now also makes it possible to add SwiftUI views and modifiers to Xcode’s library in addition to code. These can be reused later in other projects.
6. When using SwiftUI in the new project menu, a new menu of Life Cycle is rendered. There are two options to choose from in this menu, either “UIKit App Delegate” or “SwiftUI App” can be selected. If the latter option is selected, a file <ProjectName>App is created by Xcode to handle the application life cycle. The “App” framework represents the structure and behaviour of an application. The Structure in this file is having @main attribute marking. This marking indicates that this Structure is the entry point of this application. It is not possible to have more than one Structure marked with @main attribute. This Structure has a variable named body of type Scene. Scene Protocol acts as a container for views. Inside the Scene of type WindowGroup, there’s an object of the view(ContentView) that is displayed to the user after the app starts.
7. For the developers, who use storyboards, a minimum is provided by the Apple team in the latest Xcode 12. This minimum can be used to get an overview of the entire canvas. This will be really helpful when navigating between many views and View Controllers. Developers also have the option to on or off this Minimap. (Editor —> Canvas —> Minimap)
8. Xcode 12’s additional support for SVG image assets in Asset Catalog is something everyone is very excited about.
9. Simulators provided with Xcode 12 can now be used for full-screen modes. Also, these simulators will always remain on top of all windows. Developers will also have the option to switch on or off this feature. (Window —> Stay On Top)
10. Simulators now also support Nearby Interactions. For this feature, more than one simulator should be running at a time on your system.
11. Now, from Xcode 12, any Swift package created using Swift 5.3 tools, can contain resources along with the source code. Resources can include asset catalogues, storyboards, images, plist files etc.
12. Swift 5.3, introduces a multi-pattern catch block. This will be of great help in handling various error cases. It’s no longer required to write separate catch blocks.
13. It’s no more compulsory to repeatedly mention the self-keyword inside closures marked with @escaping attribute.
14. For enum, which earlier required conformance to Comparable protocol, Swift now will synthesise conformance to this protocol automatically. This is valid for all cases, as long as value type conforms to Comparable protocol.
15. Before, Swift 5.3, if an enum conformed to a protocol, which has a get-only static property of type Self, and a static function with an argument returning Self, it was necessary to rename identical property and functions. Also, protocol implementation requirements were mandatory. Now, this restriction is removed, this will remove the unnecessary code in the enum.
iOS 14 changes
Apple has tried to reimagine the iOS experience with its new iOS 14.
These changes also bring a lot of opportunities for developers. Developers also need to adapt to these changes and make their apps compatible with iOS 14.
In this article, I will try to cover a few important changes in iOS 14 which are important from a developer’s perspective.
Changes related to User Privacy:
i. Describe app data usage: Now the app will be required to disclose what kind of data the app is using. Also, there is a need to disclose whether these data are used to track the user.
ii. This information will also be published on the app’s App Store page.
iii. To make these changes use App Store connect while submitting apps for review.
iv. Asking permission to track any user: The app needs to explicitly ask for user’s consent via ATT framework, when it is displaying targeted advertisements in the app, sharing personal data with a third-party or using third party analytics SDK.
v. There is also a need for user’s permission, if any data is persisted in the device and is collected by your app, even if it’s for fraud prevention or security purposes.
vi. Photo Library Changes: In the past, you could simply present a UIImagePickerController and access the user’s photo library. But, some of the apps required even more access to the user’s photo library like reading/writing access. This was a privacy concern for users. Some apps even used this to show the users targeted ads as per the data they picked, using this access.
vii. Now, from iOS 14 onwards, UIImageControllerPicker is replaced by PHPicker. Now the need for custom photo pickers is eliminated because of the features of this PHPicker. The new standard permission dialogue for photo library access is also changed. Apps using older SDKs will also keep working, but the user experience may be affected.
viii. New Feature of Approximate location: From iOS 14 onwards, users can give an approximate location to some apps. This will vary from app to app, as not all apps require precise location of the user. Also, the approximate locations will be refreshed less frequently. Users will be able to change the settings for each app from the Setting App.
App Clips
- App clips are a smaller version of your app, which will run without installing. These should be capable of performing a single task, and users will interact with these for the service it provides.
This article covers, few changes of Xcode 12, Swift 5.3 and iOS 14 only, there is still a lot more to read and share. I would recommend all the developers to read about those changes, as they will help us in becoming better and efficient in coding.