WWDC20 session notes
WWDC week is here and with it the usual post with all my notes about the sessions.
This year I've changed the format and I will keep the notes grouped by their topic instead of session. Over the years I've come to realise that different sessions repeat a bunch of the same content so a topic based system seems more appropriate.
This post will be kept up to date with information with my notes as I keep watching the sessions. Check out other WWDC posts. Last Update: Saturday.
You can find my notes separated by topic below. The sessions in bold are those that I think are a must watch. If you have any other suggestion or comment feel free to reach out to me.
- 10041: What's new in SwiftUI
- 10048: Build complications in SwiftUI
- 10119: Introduction to SwiftUI
- 10042: Build SwiftUI apps for tvOS
- 10037: App essentials in SwiftUI
- 10185: Visually edit SwiftUI views
- 10649: Add custom views and modifiers to the Xcode Library
- 10031: Stacks, Grids, and Outlines in SwiftUI
- 10039: Build document-based apps in SwiftUI
- 10149: Structure your app for SwiftUI previews
- 10033: Build SwiftUI views for widgets
- 10040: Data Essentials in SwiftUI
I recommend to start with the introduction to SwiftUI. Even if you're already an expert in the framework is a good refresh of the cool technology we have in our hands.
There is a lot of new things in SwiftUI, it definitely feels like the improvements that we were all expecting. I plan to make a proper deep dive once I've watched all the sessions. I don't want to release something that may be wrong, so I will wait for the end of the week. For now here's a summary of what's new!
- New API for Scenes and Apps :
WindowGroup, create new windows in iPad, macOS (automatically gives a New comment)
DocumentGroup, document based apps (automatically gives a
@StateObjectlets SwiftUI manage the lifecycle of the model, its tied to the View (not the struct) lifecycle. As opposed to
@ObservedObjectthat doesn't manage the lifecycle for you (a.k.a. will be recreated every time).
@SceneStoragekeeps and restores the state for a Scene.
@AppStoragedoes it for an entire app (user defaults). Use this just to persist the UI state of your app, your data should still be persisted as part of your model layer.
- Event sources: User interaction, onReceive, onChange, onOpenURL, onContinueUserActivity, closures run on the main thread.
.keyboardShorcutsthat can be used with
- Launch Screen with just the Info.plist. Bye bye storyboards!
- Lists become outlines by using the children
- LazyGrids are composed with ScrollView (not with List)
- semantic placements and positional placements
Labeladds semantics to Text + Image, but you can use any other views.
helptooltips on macOS, accessibility hint for the rest of platforms.
ProgressView, linear and circular styles.
Gaugeonly watchOS. I don't get why they don't ship the same UI everywhere :(
- Other system frameworks provide SwiftUI views
matchedGeometryEffectlets you animate a view between “screens”. This is amazing.
- Custom fonts supported in text that automatically scales. You can even specify a
relativeToparameter to scale int he same way that a specific system style, by default is relative to body style.
@ScaledMetricscales other numbers based on the dynamic type accessibility settings. You can pass a relative to like with custom fonts.
Textnow can interpolate
Images and other
ContainerRelativeShape()takes the closer shape from the parent including corner radius. Very useful to make sure your radius is the same as the system you're running on, ideal for widgets.
accentColorfor macOS and
AppAccentColorin the asset catalog for all the platforms.
listItemTintfor list items or sections.
Switchand other control styles now support specific custom accent colors.
Linkopens the url with Safari or universal links. Ideal to use in Widgets to open the App. The environment now has a
openUrl` that lets you open a URL manually.
- New UTType framework. It helps with drag and drop support.
CardButtonStylefor tvOS effects.
- tvOS has a bunch of new focus APIs for SwiftUI.
LibraryContentProviderprotocol to include your views in the Xcode Library.
- One cool thing about
Appstruct is that Xcode knows about it and doesn't initialise the model when running under previews.
- If you want assets or tests data only for previews use Xcode's Development Assets option.
- Xcode previews work on device and update immediately. And you can have previews in multiple devices at the same time. You even have an icon on Springboard to go back to the last preview.
- One thing I'm very glad the SwiftUI team says clear: your view struct initialisation should be cheap. Don't perform heavy work in there, use events to trigger those side effects.
- 10170: What's new in Swift
- 10169: Explore logging in Swift
- 10165: Embrace Swift type inference
- 10217: Explore numerical computing in Swift
- 10648: Unsafe Swift
- 10167: Safely manage pointers in Swift
What's new in Swift is worth watching but it doesn't add anything that we didn't know about the language, the beauty of open source! If you're interested in some deep dives check out my Following Swift Evolution videos.
Lots of nice improvements for the language coming with Xcode 12 (Swift 5.3)
Something that was not clear from the session is if the new SwiftSystem framework would be part of Swift.org or a private Apple framework. Ted has confirmed that it will be part of the open source project.
New Swift logging APIs on Xcode 12. It uses compiler integration to be really performant. Numeric types are redacted by default. use
privacy: .public in string interpolation to disable that. It includes log levels. Logs can be retrieved on the console app or streamed live, also in Xcode. String interpolation has many things like fixed with with padding and formatting capabilities.
Xcode 12 brings a bunch of better error reporting capabilities from Swift type inference engine. The presentation does a great job of explaining what the compiler does to resolve all the type constraints of your code.
Float16 is new to the standard library. The Numerics package introduced a Real protocol that you can use to write generic numeric code. It adds a Complex type that conforms to Real, useful for complex numbers.
I'm so glad that the "Unsafe Swift" exists. It clearly states what safe means in Swift, which is often misunderstood by programmers that have not spend a lot of time with the language. The session slides have very nice tables with the correspondence of C pointers and Swift unsafe API.
Xcode, Swift Package Manager and Playgrounds
- 10169: Swift packages: Resources and localization
- 10096: Explore Packages and Projects with Xcode Playgrounds
- 10654: Create Swift Playgrounds content for iPad and Mac
- 10091: Write tests to fail
- 10164: XCTSkip your tests
- 10687: Triage test failures with XCTIssue
- 10643: Build a SwiftUI view in Swift Playgrounds
- 10221: Get your test results faster
- 10147: Distribute binary frameworks as Swift packages
- 10644: Use Swift on AWS Lambda with Xcode
The new features of SPM are the missing parts that we've waiting for to fully replace other dependency managers. It has been part of the open evolution so no new surprised there. I can't wait to have all of this in Xcode!
Swift Playgrounds is fully integrated with Xcode build system. That allows them to support:
- Swift Packages
- Frameworks in the same project
- Other resources (including machine learning models that need to be compiled).
Build logs from playgrounds are now displayed in Xcode.
XCTSkip for when you want to skip specific tests, even conditionally. Xcode has a third state "skipped" so distinguish from Pass and Error.
New setup and tearDown "with error" functions that can throw.
XCTIssue encapsulates the failure message, file path, line number and others. It now keeps the stack trace of the failure so you can follow it until the point of the assert. Much better than passing #file and #line around, although you may still want to keep that to improve clarity. You can overwrite
record(issue) on the test class to do whatever you want with it. This seems like a very nice thing for testing frameworks.
The new option execution time allowance lets you add a timeout to tests so they fail instead of hanging the suite for ever. By default is 10 minutes.
It's pretty cool to see a session about AWS Lambda. The fact that the library comes with a solution for local development out of the box is huge. In my limited experience with lambdas this was a big pain. It's great to work with these technologies from our familiar tools.
- 10097: Advances in UICollectionView
- 10045: Advances in diffable data sources
- 10026: Lists in UICollectionView
- 10027: Modern cell configuration
The new additions on UICollectionView look amazing. They continue with the modern APIs included last year. Unfortunate I haven't been able to look too much into them since for old projects you can use it and for new ones I've been using SwiftUI.
What I'm more interesting in is the configuration pattern making it into UIKit. I will have to look again at it when new sessions are released, because for now I don't see how it will work with custom views.
- 10028: Meet WidgetKit
- 10034: Widgets Code-along, part 1: The adventure begins
- 10035: Widgets Code-along, part 2: Alternate timelines
- 10036: Widgets Code-along, part 3: Advancing timelines
The best thing about WidgetKit is how it's fully using SwiftUI. They use the declarative nature of the framework (your UI is just data) to serialise that and make sure the home screen always has a valid UI to show without loading screens.
- Widgets are not mini-apps, they just project your content on the home screen.
- Widget bundles to have different widgets on the same app.
- You should support as many sizes as make sense.
- supportedFamilies: systemSmall, medium, large.
- Configuration system is based on intents. The system makes the UI from them.
- static configuration
- intent configuration
- You provide a placeholder view that is used as the default content, without user data. This is usually only used on environment changes.
- In small widgets the entire view is one tappable area (
.widgetURL). In medium and large you can have different subviews deep links to different parts of the app (
- Snapshots are used in the gallery so what you see there is your real UI, no mock designs.
- You can perform reloads by:
- widgetcenter.reloadtimeline to force a reload from in the app
- background url session
- timeline api (similar to the old complications API on the watch)
previewContext(WidgetPreviewContext)in your SwiftUI previews.
.isPlaceholder(true)to get a placeholder UI for free. AMAZING.
- Environment has a
- URL Background session completion is handled in the widget itself.
- 10174: Explore app clips
App Clips are really interesting and I'm curious to see if they become a common feature on iOS Apps.
- App clip experiences are based on URLs.
- Invocation methods: Safari, Messages, Maps, NFC Tag, QR Code and Location.
- They are like universal links URLs handled by app clips instead of a browser. Registered in App Store Connect instead of the existing associated domains file.
- They are mutually exclusively with apps. When the app is installed you need to handle the app clips URLs.
- They are just a standalone app (target) that has access to all iOS APIs (with some privacy restrictions).
Intelligence, Siri and Shortcuts
- 10068: What's new in SiriKit and Shortcuts
- 10086: Design for intelligence: Apps, evolved
- 10087: Design for intelligence: Make friends with "The System"
- 10088: Design for intelligence: Discover new opportunities
- 10200: Design for intelligence: Meet people where they are
Intelligent system experience. "How the operative system works with apps that people use everyday to make the everyday easier for people." It's a platform convention.
- Define, learn and execute.
- 10660: What's new in location
More privacy controls.
- (iOS 13) Never, Ask Next Time, While Using, Always. The flow from 13.4 has changed!
- Let's the user select precise or approximately.
- This is fully controlled by the user, the app needs to adapt.
authorizationStatusclass function becomes a property.
- A new property to know the accuracyAuthorization.
- New didChanteAuthorization method that covers both dimensions.
- Reduced locations still come on the same delegate but with low accuracy and updated only four times per hour. They contain the user true location but not the exact point.
- Significant location changes API doesn't change much. The amount of deliveries are the same. The timestamps are still accurate, but the location is more approximate.
- Bacons and regions need accurate access.
- New constant to ask only for reduced precision.
- If the user only shares approximatly location but you need full you can:
- send user to settings
- prompt for temporary full accuracy. The purpose must be in a new dictionary of the Info.plist.
- asking only when is needed is better for the user.
- 10668: Meet Nearby Interaction
- 10052: Build with iOS pickers, menus and actions
The U1 chip is accessible by devs with the Nearby Interaction framework.
- Both devices need to grant permission.
- Get distance and direction.
- Have different sessions with different devices at the same time.
- You need to share the discovery token on your own, with multi-peer connectivity or a backend service.
- It works in the simulator with different simulator windows.
Minor UIKit design updates across standard controls. Menus may be a replacement for UIPicker in many contexts. UIPageControl supports unlimited pages and custom icons. New color picker. UIDatePicker has a compact style and a full calendar. Menus
UIMenu on controls triggered by a long press, or you can trigger the menu directly with
showsMenuAsPrimaryAction = true. Navigation back button now has menu with the history. UIAction menus can be added to bar button items.
- 10104: Adopt the new look of macOS
- 10056: Optimize the interface of your Mac Catalyst app
I really like the new macOS design. Some details need to be polished IMO but the new style feels very fresh.
- Full height sidebars.
- Accent color tint fully supported in sidebars.
- Unified toolbar style.
- New search bar item that collapses when there is no space.
- New multicolor accent color that lets app use their own tint. Specified in Info.plist and Asset Catalog.
- Large control size.
- Text Styles come to macOS!
- SF Symbols come to macOS!
Enabling the optimised mode for Mac on catalyst apps seems to be a very nice way of migrating your iPad app for the mac.
- 10206: Design for iPad
Make your apps profit from the iPad size, don't just make it a halfway product between iPhone and Mac.
- Show more content: Sidebars help you fill the screen with content, faster navigation and easy drag and drop. Tweak the density to better use the screen space.
- Keep the context: keep people in context, keep controls at the same level instead of overlays.
- Immersive experience: big display but with only your content so you can focus on it with custom layouts.
- Keyboard shortcuts, pointer/trackpad/pen/scribble. Combine multiple inputs, like keyboard with touch or pencil and touch.
- Sidebars with 3 column layout in all iPads.
- Keep tabbars for compact mode and iPhone. Don't just move the tabs into a sidebar, enrich the sidebar with shortcuts to the most important content, but don't overload it with everything.
- Don't mix sidebars and tabbars.
Symbols and fonts
- 10207: SF Symbols 2
- 10175: The details of UI typography
SF Symbols supported on macOS! The app lets you now organise in custom categories. Check the app for the names. Some symbols have changed the names to be consistent.
SymbolConfiguration/.imageScale lets you change the scale of the symbol independent of the size of the text/icon.
Label is handy for combining text and image in one go or even interpolating Image in Text string.
Some symbols are localised automatically.
Symbols are now multicolor. isTemplate false to have the multicolor variant.
Apple is moving to a single font SFPro instead of having to download multiple files for all the variants. Thanks to variable fonts. Design tools will let you tweak granularly the weight and optical size. In code is all automatic.
If you need to make letters close together don't use kerning, is better to use tracking for that. But is just better to enable
allowsTightening. The font has tables that use the proper tracking based on size, etc.
Use text styles, this year macOS has support for them too (although without dynamic type).
And if you need a little more visual difference you can get their descriptor and apply a symbolic trait.
The system automatically adds more leading (space between lines) to locales that have a lot of vertical letters, like arabic. You can see how the default controls get taller. Or in watchOS the leading is reduced to show more content. You can apply the same variations to your text if needed.
And you can use SF rounded, NY or SF mono with these traits too. You can also use these font styles on webkit.
- 10046: Create complications for Apple Watch
Complications are complicated.
- 10182: What's new in HealthKit
- 10661: Getting started with HealthKit
Very short video. I really like the new format!
- Symptoms support.
- Electrocardiogram exposed to HealthKit.
- Mobility data types.
AppStore and In-App Purchases
- 10659: Introducing StoreKit Testing in Xcode
- 10651: What's new in App Store Connect
It's pretty cool how testing can be when Apple gives us a proper framework. It completely changes the development flow for in-app purchases.
iOS 14 has a separate account slot for sandbox user accounts.
Family sharing for subscriptions and other in-app purchases.
App Metadata and analysis tools are now part of the App Store Connect API!
- 10665: Meet Safari Web Extensions
Safari has extensions again, based in standard web technologies so people can use the same code they use for other browsers. More privacy controls and being able to be sold on the App Store. I still find weird that you have to use Apps to distribute extensions, especially when the App doesn't do anything.