- The new App type so that a SwiftUI application is as simple as
@main
100% SwiftUI app - Return
Scene
,WindowGroup
is default supports all devices and multi-window.DocumentGroup
,Settings
. - New multi-platform template for SwiftUI apps in Xcode
- Launch screen config in .plist
- SwiftUI is used for Widgets and Watch complications
- Outlines in lists
- Lazy loading grids for CollectionView like behavior
- Toolbar modifier to describe semantics and for platform it’ll decide where to place in UI.
- New
Label
type icon + title - Keyboard shortcuts support
ProgresView
,Gauge
typesmatchedGeometryEffect
❤️ for really nice Apple Music like transitionslistItemTint
- New
Link
❤️ view for deeplinking and opening link in web
- Code Size decreased from x2.5 -> x1.5 obj-c code Swift 4 -> Swift 5.3
- 43% Reduction in SwiftUI binary size 5.2 -> 5.3
- Swift overhead decreased A LOT
- New diagnostics system for precise errors and warnings ❤️
- Code completion speed 15x ❤️
- Code indentation improvements ❤️
- Increased robustness in debugging ❤️
- Multiple-trailing syntax { } { } { } 🤔
- Use key paths as function type in Swift 5.2 (Used a lot in Composable Architecture) ❤️
- Unified
@main
ParsableCommand, SwiftUI, UIKit ❤️ - Implicit self, define in capture list and omit in body { [self] in selfFunction } ❤️
- New do catch statement for error pattern matching do { } catch error 1, error 2 { } catch { } ❤️
- Synthesized comparable conformance for enums
- If let and switch statements in SwiftUI blocks ❤️
- Can use HTTPS to directly point to the binary, can also point to path.
- Will need to ship with Swift 5.3 (Xcode 12).
- Definitely check out -> Sample App
- Good to Watch WWDC19 videos regarding
DiffableDataSource
andCompositionalLayout
first. ContentConfiguration
andConfigurationState
are the new ways to style cells instead of directly accessing properties inside a cell even forUITableViewCell
.- For custom cells can use
UIListContentView
which is a regularUIView
so you can reuse it everywhere not just in cells. UICollectionLayoutListConfiguration
and how easy it is to combine it with other layouts completely changes how you would use and configure a list/cell, bye byeUITableView
and thanks for the years of service.- Wish
UICollectionView.CellRegistration
API came earlier - Would probably use SwiftUI instead of UIKit if was able to use iOS 13-14, so don’t know if will ever use actually. 🤔
- Some of these APIs use structs with closuresinstead of the delegation pattern, might be good to look into for our own APIs
- [image:86B234F7-5492-4306-930D-3FC95234A584-2823-000006CFF7784D07/image.png]
- Primer is more of configuring the site association correctly, still good refresher if didn’t look at universal links before.
- Sample Code Fruta App
- 1st setup app clip in app-association file, 2nd setup entitlement, 3rd setup app clip as different target, 4th ship the app clip with the app, 4rd configure the preview on the app store with image, title and subtitle.
- Can setup multiple app clip experiences.
- App clips team was one of the more diverse teams.
- First woman engineer in all of the videos watched.
- Great tool for app engagement but sadly no usage for me currently.
- Widgets are not mini-apps, they should be glanceable, relevant and personalized
- WidgetKit -> SwiftUI
StaticConfiguration
vsIntentConfiguration
- 3 size types + 3 view types placeholder (empty), snapshot and timeline (series of snapshots)
- StatelessUI -> deeplink to app when tapped
- Use system reloads to update the timeline through networking, environment changes or app based
- Intents framework is used to configure (SiriKit and Shortcuts)
- Sample Code
- Fun new API, curious about what people will build with it.
- Needs U1 chip and iOS14 so pretty limited use currently.
- Need to exchange device token with some other API between devices before starting session using it.
- Can have multiple sessions between multiple devices.
- Works best when device is in field of view, doesn’t work well when phones are in different orientation.
- Need to manage session correctly for pausing/termination etc.
- New in Xcode 12 is the unified
Logger
inos
. It takes in subsystem and category parameters to distinguish logs. - Log message is not converted to string and is optimized for performance
- Can control privacy of parameters passed in so they appear redacted in logs
- Can collect logs from Console app as usual, prints to Xcode console as well when Product > Run
- Has the
Debug
,Info
,Notice
,Error
andFault
log levels - Persistence of log message increases with log level, Debug is not persisted, Info only persisted during log collect , Notice+ is persisted
- Debug level is very performant performance decreases through levels
- You can use formatting as well like precision
- App -> Multiple Scenes (Windows) -> Same Views
@StateObject
property for owning state in App@SceneStorage
to store view state of scene- On MacOS different Scenes can be grouped into tabs
- A bit repetitive of whats new in SwiftUI
- Simple recap on building SwiftUI views and applying modifiers
- Still crazy on how a view that would take an hour to do correctly on UIKit can be done just in 2 minutes
LibraryContentProvider
views and modifiers that returnLibraryItem
- Nice to have components and modifiers to show up in the Library for easy insertion
- Don’t need to run the project for items to show up in library, Xcode scans the code and adds it automatically 😮
- Can also define in Swift Packages
- Fully integrated with the modern build system
- Using Playgrounds as a way of documenting the library is a nice idea 👍
- New
Build Active Scheme
option for Playgrounds that when opened it builds the scheme - Build logs for Playgrounds
- Can add assets to Playgrounds
- New
Execution Time Allowance
inxctestplan
to kill stalled tests, it’ll generate a spindump for debugging - Parallel Distribution of tests can now be done on physical devices using xcodebuild
UIInterruptionMontitor
will get rid of interruptions with default options but can be customized- New
resetAuthorizationStatus
API on XCUIApplication to test auth cases
PHPicker
built in search, zooming, multi-select finally!, selectable type can be specified 👍- Runs out of process of the app (Like Android) so no photos access prompt required! Only selected photos get passed to the app 👍
PHPickerConfiguration
for setup- PhotoKit should only be used for things like non-desctructive image editing and photo library organization
- Now when using
PhotoKit
there will be “limited” option that user gives access to part of library, this will be the case for existing apps as well - Without changes: user needs to go to settings to manage selection, or app will re-prompt to update selection after re-launch 👎
- New status value
limited
to query with new PHAccessLevel forreadWrite
andaddOnly
- If limited can use
presentLimitedLibraryPicker
to display native UI to update selection - Set
PHPhotoLibraryPreventAutomaticLimitedAccessAlert
in Info.plist after to stop automatic prompt
UISlider
,UIProgressView
,UIActivityIndicatorView
,UIPickerView
visual changesUIPageControl
visual and functional changes like scubbing + customization options:backgroundStyle
,preferredIndicatorImage
,setIndicatorImage
- New
UIColorPickerViewController
❤️ pretty usual controller delegate pattern - Updated
UIDatePicker
❤️ new Compact style
, shows calendar as modal for selection, time from keyboardInline style
shows the new picker inline like the wheel but new UI- New
UIMenu
for adding to controls, default it shows on long press, can setshowsMenuAsPrimaryAction
onUIButton
and don’t set primary action onUIBarButtonItem
to show menu immediately on touch-down - Back button also shows menu of stack
- Can add own menu interactions to UIControls
- Use
UIDeferredMenuItem
for showing menu async UIAction
introduced in iOS 13 can now be used with new APIs.👋#selector
- Multi-column Split View in iOS 14 ❤️
.doubleColumn
style for old usual way.tripleColumn
style for new:.primary
,.supplementary
,.secondary
. - Set
.compact
for when not enough space (iPhone) and system takes care of rest 🤯 but this leads to two different flows for compact and regular so need to manage state when transitioning between these two .preferredSplitBehaviour
:tile
for sharing space,displace
pushes off screen,overlay
shows others over seconday- Can use .hideColumn(...) and .showColumn at any time
- Use
.preferredDisplayMode = .oneBesideSecondary
to fix the dispaly - UINavigationControllers are created automatically and buttons place automatically as well now
- Use
UICollectionView
list type with sidebar style for creatingsidebar
in apps
- Most default components already work out of the box with pointer
- When updating start from top down with first
UIBarButtonItem
andUIButton
isPointerInteractionEnabled = true
for UIBarButtonItem default- Can use
.pointerStyleProvider
to buildUIPointerStyle
for custom appearnace, it takes inUIPointerEffect
,UIPointerShape
, andUIAxis
- For custom views use
UIPointerInteraction
andUIHoverGestureRecognizer
- Can control
UIPointerRegion
for snapping to control for polishing (needs to be within the hit test of view)
- As the name suggests this these are code-along videos -> Start Here
- NOTE Simulator in Beta 1 doesn’t work correctly so need to run on device
- Add Widget extension target and add shared files like you would do with Watch target.
- In the demo there is already a view that can be used as the widget, easily displayable in preview using
.previewContext(WidgetPreviewContext(family: .systemSmall))
- Widgets components:
WidgetConfiguration
which is either Static or Intent, it takes in theTimelineProvider
orIntentTimelineProvider
+ the placeholder view for when loading - Provider passes in the
TimelineEntry
to the view of the widget to use as data - The
.isPlaceholder(true)
is used to convert the SwiftUI view directly to a placeholder view but doesn’t work in current Xcode version TimelineReloadPolicy
used to say when to reload the timeline.systemSmall
is one giant tappable area while others can use theLink
API to Deeplink into app- Can do URL session requests from widget and use
.onBackgroundURLSessionEvents
to manage the background tasks - Can use the
WidgetBundle
to expose more than 1 widget and use@main
there - Can use Intent extensions for dynamic configurations
DocumentGroup
scene with type, can compose with other scenes and types- Can define custom document types in settings
- Not very interesting for our use case
LazyVStack
andLazyHStack
that render content incrementally as it becomes visible on screen- Embed in
ScrollView
for scrolling - When outer stack is lazy inner stack doesn’t need to be lazy
LazyVGrid
andLazyHGrid
defineGridItem
array and spacing, rest is passed in as before, can use.adaptive
typeList
is always loaded lazily- New
children
parameter inList
to defineOutline
(groups) underneath it uses new typeOutlineGroup
to traverse trees of data - Can use
DisclosureGroup
to group insideForm
, actuallyOutlineGroup
uses this internally as well, composition at its best!
- A look into type inference in Swift
- swift.org/blog/new-diagnostic-arch-overview/
- Does not do fully validate its input
- Used for inter-op with code written in C or Obj-C, control over runtime performance
- Don’t think messing with memory access directly with pointers and buffers would be needed in our usage
- Creating books for Swift Playgrounds for iPad and Mac
- Watch the Swans Quest videos for more info
- Swift Playgrounds can be used as a prototyping area when you create a Xcode Playground template, it’ll be ready to port directly
PlaygroundPage.current.setLiveView(..)
- Can add new files inside didn’t know that, multiple tabs to edit multiple files
- Can create a new view inside main page to imitate a preview and give modifiers to test with different environment variables
- Recap of how to use
@State
,@Binding
,@ObservedObject
,@EnvironmentObject``@Published
@ObservedObject
view does not own it and does not control lifecycle, all views will update that are tied to it when it changes@StateObject
new in iOS 14. SwiftUI owns the ObservableObject, only instantiated when the body runs and kept alive for the view lifecycle. Example for this is an image loader.@EnvironmentObject
is passed as a view modifier to parent and can be read deep down in a child.onChange
,onOpenURL
andonContinueUserActivity
new event sources addition toonReceive
- New
SceneStorage
andAppStorage
to restore state when app is killed and restarted SceneStorage
to store things like current list selectionAppStorage
uses UserDefaults to store things like settings- Point Free makes the point that it is very hard to have code that is testable by using the vanilla approach, Composable Architecture series gives a very good background for this