Vietnam Swift News # 9

Tram Ho

9

Vietnam Swift News # 9

Last week Apple released Beta 3 for Xcode 12, iOS and iPadOS with some new APIs. Apple has also opened the Exposure Notification library. This library is used by countries around the world to build app contac tracing to help work against COVID-19. I have found out in Vietnam that Bluezone app developed by BKAV does not use this library. We hope the next versions of Bluezone will be updated to use this library because it is supported directly from Apple. I myself am participating in a project related to this library so I strongly support the use of Exposure Notification Framework. However, the weakness of this is that only devices that can be installed on iOS 13 or later can use the Exposure Notification Framework.

Swift:

async keyword

Anyone writing C # or Javascript should be familiar with keyword async, await already. With async and await, code concurrency is easier to write and logic is easier to understand. Swift On Github of Swift, there was a PR to introduce keyword async for Swift. Mr. Lattner also had the Swift Concurrency Manifesto from 3 years ago, including async and await here.

Open source Exposure Notification Framework

Apple has provided the Exposure Notification Framework source code for everyone to refer. A special feature is that the source code is written in Objective-C.

Posts:

Use OSLog

For our programmers, it is extremely important to have logging data from the apps we write, which not only helps us find bugs but also helps us understand user behavior. With Apple tightening privacy on iOS 14 , using frameworks like Firebase Craslytics / Firebase Analytics / Sentry will be more difficult. One solution to this is to use built-in operating system components like OSLog or MetricKit . The SwiftLee site has an introduction to using OSLog here . Information about MetricKit , you can watch live from WWDC this video .

Using CoreData with SwiftUI in Xcode 12

If you create a new SwiftUI project in Xcode 12, you won’t see AppDelegate or SceneDelegate anymore, making it difficult to set up CoreData . Donny Wals has introduced a way for you to set up CoreData and connect it to the UI section here .

Add resources to the Swift Package Manager

From Xcode 11, we can use the Swift Package Manager, but it only supports packages that have only source code (i.e. no resources like images, non-Swift files, or Objective-C). Since Xcode 12, SPM has supported the addition of these resources to the package. You can see detailed instructions on how to add and use resources in SPM here .

Source code:

RSS Reader NetNewsWire

9

NetNewsWire is an open source RSS Reader application for all Apple platforms. Interestingly, the application maintainers decided to switch to SwiftUI. This is a great opportunity for SwiftUI learners to bring their skills to practice, and have just contributed to a good open source application. Details about learning SwiftUI with NetNewsWire application here .

Virtualization Framework

9

My friend KhaosT did a test to run Ubuntu in the macOS app using the Virtualization Framework . You refer to the source code here .

Snap

9

A fairly common UX design pattern today is the bottom drawer. We can see it in Apple Maps, Apple Music or Google Maps. If you use SwiftUI, you can refer to [Snap], if you use UIKit, you can refer to ContainerController

Spotify’s network library

9

Spotify last week also introduced a network library they use in their app, called SPTDataLoader . This library builds on NSURLSession and supports authentication + back-off policy. Please refer to the source code on Github

Epilogue:

Next week I will relocate to Singapore so I will be quite busy. It is possible that the article for the coming week will be later than usual, please understand.

If you have posts related to Swift, WWDC and want to share with the community, you can connect with me to discuss more.

You also remember to follow the Swift Vietnam Facebook page to stay updated with the latest information about Swift and the Swift Vietnam developer community.

Share the news now

Source : Viblo