- The new App type so that a SwiftUI application is as simple as
@main100% SwiftUI app - Return
Scene,WindowGroupis 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
Labeltype icon + title - Keyboard shortcuts support
ProgresView,GaugetypesmatchedGeometryEffect❤️ 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
@mainParsableCommand, 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
DiffableDataSourceandCompositionalLayoutfirst. ContentConfigurationandConfigurationStateare the new ways to style cells instead of directly accessing properties inside a cell even forUITableViewCell.- For custom cells can use
UIListContentViewwhich is a regularUIViewso you can reuse it everywhere not just in cells. UICollectionLayoutListConfigurationand how easy it is to combine it with other layouts completely changes how you would use and configure a list/cell, bye byeUITableViewand thanks for the years of service.- Wish
UICollectionView.CellRegistrationAPI 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
StaticConfigurationvsIntentConfiguration- 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
Loggerinos. 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,ErrorandFaultlog 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
@StateObjectproperty for owning state in App@SceneStorageto 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
LibraryContentProviderviews 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 Schemeoption for Playgrounds that when opened it builds the scheme - Build logs for Playgrounds
- Can add assets to Playgrounds
- New
Execution Time Allowanceinxctestplanto kill stalled tests, it’ll generate a spindump for debugging - Parallel Distribution of tests can now be done on physical devices using xcodebuild
UIInterruptionMontitorwill get rid of interruptions with default options but can be customized- New
resetAuthorizationStatusAPI on XCUIApplication to test auth cases
PHPickerbuilt 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 👍
PHPickerConfigurationfor setup- PhotoKit should only be used for things like non-desctructive image editing and photo library organization
- Now when using
PhotoKitthere 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
limitedto query with new PHAccessLevel forreadWriteandaddOnly - If limited can use
presentLimitedLibraryPickerto display native UI to update selection - Set
PHPhotoLibraryPreventAutomaticLimitedAccessAlertin Info.plist after to stop automatic prompt
UISlider,UIProgressView,UIActivityIndicatorView,UIPickerViewvisual changesUIPageControlvisual 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 styleshows the new picker inline like the wheel but new UI- New
UIMenufor adding to controls, default it shows on long press, can setshowsMenuAsPrimaryActiononUIButtonand don’t set primary action onUIBarButtonItemto show menu immediately on touch-down - Back button also shows menu of stack
- Can add own menu interactions to UIControls
- Use
UIDeferredMenuItemfor showing menu async UIActionintroduced in iOS 13 can now be used with new APIs.👋#selector
- Multi-column Split View in iOS 14 ❤️
.doubleColumnstyle for old usual way.tripleColumnstyle for new:.primary,.supplementary,.secondary. - Set
.compactfor 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:tilefor sharing space,displacepushes off screen,overlayshows others over seconday- Can use .hideColumn(...) and .showColumn at any time
- Use
.preferredDisplayMode = .oneBesideSecondaryto fix the dispaly - UINavigationControllers are created automatically and buttons place automatically as well now
- Use
UICollectionViewlist type with sidebar style for creatingsidebarin apps
- Most default components already work out of the box with pointer
- When updating start from top down with first
UIBarButtonItemandUIButton isPointerInteractionEnabled = truefor UIBarButtonItem default- Can use
.pointerStyleProviderto buildUIPointerStylefor custom appearnace, it takes inUIPointerEffect,UIPointerShape, andUIAxis - For custom views use
UIPointerInteractionandUIHoverGestureRecognizer - Can control
UIPointerRegionfor 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:
WidgetConfigurationwhich is either Static or Intent, it takes in theTimelineProviderorIntentTimelineProvider+ the placeholder view for when loading - Provider passes in the
TimelineEntryto 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 TimelineReloadPolicyused to say when to reload the timeline.systemSmallis one giant tappable area while others can use theLinkAPI to Deeplink into app- Can do URL session requests from widget and use
.onBackgroundURLSessionEventsto manage the background tasks - Can use the
WidgetBundleto expose more than 1 widget and use@mainthere - Can use Intent extensions for dynamic configurations
DocumentGroupscene with type, can compose with other scenes and types- Can define custom document types in settings
- Not very interesting for our use case
LazyVStackandLazyHStackthat render content incrementally as it becomes visible on screen- Embed in
ScrollViewfor scrolling - When outer stack is lazy inner stack doesn’t need to be lazy
LazyVGridandLazyHGriddefineGridItemarray and spacing, rest is passed in as before, can use.adaptivetypeListis always loaded lazily- New
childrenparameter inListto defineOutline(groups) underneath it uses new typeOutlineGroupto traverse trees of data - Can use
DisclosureGroupto group insideForm, actuallyOutlineGroupuses 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 @ObservedObjectview does not own it and does not control lifecycle, all views will update that are tied to it when it changes@StateObjectnew 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.@EnvironmentObjectis passed as a view modifier to parent and can be read deep down in a child.onChange,onOpenURLandonContinueUserActivitynew event sources addition toonReceive- New
SceneStorageandAppStorageto restore state when app is killed and restarted SceneStorageto store things like current list selectionAppStorageuses 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