WWDC 2024 Recap

WWDC 2024 has come and gone, and in its wake there are a lot of videos to check out. By Josh Steele.

Leave a rating/review
Save for later
Share
You are currently viewing page 2 of 2 of this article. Click here to view the first page.

SwiftUI Charts

My background is in science, so I’m always excited to see improvements to SwiftUI Charts. This year, function plotting is part of the framework and is really customizable, allowing you to express data just how you want. For example, I wanted to make a plot of what my age is versus how I felt:

import UIKit
import SwiftUI
import Charts
import PlaygroundSupport

struct FunctionChart: View {
    var body: some View {
        Chart {
            LinePlot(
                x: "Age", y: "How I feel"
            ) { x in // (Double) -> Double
                return pow(x, 1.2)
            }
            .foregroundStyle(.black)
        }
        .chartXScale(domain: 0...100)
        .chartYScale(domain: 0...150)
        .frame(width: 500, height: 500)
    }
}

LinePlot now takes in a closure it uses to read in a formula — here raising the value of x to the 1.2 power.

Xcode showed me this.

Data plot comparing age to perception

That checks out. For more on what Swift Charts can do this year, check out Swift Charts: Vectorized and function plots.

Code Assist

Apple Intelligence stole the show in the latter half of the Keynote, and in the Platform State of the Union, Apple showed off improvements for Xcode. The one available now (instead of later this fall) is predictive code completion. This is a predictive model in Xcode (once you download it like the various platforms when you first launch Xcode) that gives you suggestions for what you’re trying to do with your code as you write. Think of GitHub Copilot, for example. This requires macOS Sequoia and Xcode 16. It also can’t be run in a virtual machine, so you either need to test the beta with a separate volume on your disk or take the plunge and update your machine to the beta.

Predictive code completion really looks like it is going to be autocomplete on steroids. If I take the starter project and, in `ContentView.swift`, add a comment that I want to get the item’s time, and then start to define the function:

    //return the item's date
    func getItem

Predictive code completion suggests this:

Example of code suggested by predictive code completion

When you press Tab a few times, you get this:

    //return the item's date
    func getItemDate(_ item: Item) -> String {
        return item.timestamp.description
    }

In this case, the second press of Tab was used to accept the suggested body that predictive code completion presented.

This is a pretty basic (but powerful!) example. Another example from earlier in the week showed predictive code completion helping the developer write a ForEach loop for the items in their collection. If anything, aid like this can decrease overall development time, but it’s not super powerful. That’s where Swift Assist will come into play later this year.

Conclusion

WWDC is always filled with great developer videos, and WWDC 2024 was no exception. The thing to remember is that you don’t need to watch them all, and even if you do, you don’t have to watch them as quickly as possible. They’re recorded for a reason! Focus in on the videos that are important to your app and learn what’s new so you can keep your app up to date and your skills honed.