SOTU

This is the stuff I think most developers will care about - although I'd be lying if I wasn't sat here trying to work out what I'm going to make for Vision OS.

Swift

Macros

You can now generate your own macros in Swift, using @ and #. these are a little fancier than the existing ones. These can do a lot of work for you, i.e, compile time validation. The example shown was URL validation, which is great - you could do similar work for things like keys.

An Attatched Macro allows you to annotate your code, similar to a property wrapper, but there's a lot more going on. The example shown was @AddAsync which lets you make a function also have a an async version.

Macros can be distributed in Swift macros, so we can look forward to some fantasic packages from the comunity.

C++ Interop

You can now talk right to C++, without an inter-op layer. You set a compiler flag, and you're good to go. For high performance code, this could be something speciacular.

SwiftUI

The best way to build modern user interfaces, across all apple platforms, is SwiftUI

  • Pie Charts
  • Brand new "inspector API"
  • Paging?!
  • Data Flow
  • Low-Level Keyboard Input
  • UIKit Trait Bridging
  • and way more

### SwiftUI Animations

Animations now default to spring, with a nice new initialiser that just asks for the bounce and duration. Im hoping we're also going to see that animations also run at full framerates now.

There's also an advanced animation API that allows you to create custom animation phases, and you can even add keyframes. This solves so many dispatch queue hacks for me!

The api looked a little like this - certainly a big improvement!

KeyframeTrack(\.centerCoordinate) {
    CubicKeyframe(.infiniteLoop, duration: 10.0)
    CubicKeyframe(.applePark, duration: 7.9)
}
KeyframeTrack(\.centerCoordinate) {
    CubicKeyframe(.infiniteLoop, duration: 10.0)
    CubicKeyframe(.applePark, duration: 7.9)
}

Data Flow

No more @Published - say hello to observable. Public variables in SwiftUI views have this by default, and its just as smart as @Published, only updating when it has to.

## Swift Data

Purely based on code, all on the new macro system.

You just add @Model to your class, and you're good to go. You can customise stuff even further with attributes that say things such as Unique.

Its as easy as this...

// The Model
@Model
class Bird {
    var name: String
    var species: Species
    var songs: [Song]
}

// The Modifier to make sure they're accessible
yourview
    .modelContainer(for: Bird.self)

// The property wrapper 
// yourview.swift
@Query(sort: \.creationDate, order: reverse)
// The Model
@Model
class Bird {
    var name: String
    var species: Species
    var songs: [Song]
}

// The Modifier to make sure they're accessible
yourview
    .modelContainer(for: Bird.self)

// The property wrapper 
// yourview.swift
@Query(sort: \.creationDate, order: reverse)

Lots of magic going on here, so we'll have to wait and see just how customisable it is.

WidgetKit

Your new widgets will kinda just, work. In StandBy they'll just delete their backgrounds, so make sure you don't require it. They'll be tinted in a uniform way just like the ones we already have on the lock screen.

Super simple tasks are now available in views, but only simple ones. The example of tapping a button was given, and its likely thats all we get. Just use Button and Toggle. You can launch an AppIntent from these new Button and Toggle, and react to that inside your extension.

Using this modifier, your background will be removed for you in the right contexts.

.containerBackground(for: .widget) {
    yourBackgroundView
}
.containerBackground(for: .widget) {
    yourBackgroundView
}

Your widget timeline will now show in Xcode, so you can preview the whole thing just in the canvas!

watchOS

Big emphasis on paging. You can use a new conrainer background for lovely gradients, or you can even use toolbars. NavigationSplitView is now available, and it uses a real lovely spring - based on the velocity of the user's swipes. You'll get a lot of this stuff for free!

The demo given of the UI is really quite incredible. I cannot wait to see what people do with these APIs.

Custom workout & Core Motion API's look like they're going to open up a whole new world for pro fitness apps - bug fixing championship anyone?

## The little bits

### App Intents

The brand new shortcuts app has support for a custom display inside the app, and its super easy to support.

TipKit

Instead of doing your own onboarding, you can actually just use Apple's. Just define a Tip, and provide it to the existing templates.

AirDrop

Supporting the new way to share is is super easy, just use ShareLink. For UIKit folks, it should work automagically if you're using the system view controllers.


I can't wait to get playing with this stuff! I'm personally looking forward to SwiftData more than anything.

If you fancy reading a little more, or sharing your experiences, I’m @SwiftyAlex on twitter.