This Week's Sponsor:

Incogni

Put an End to Spam, Scams, and Robocalls on Your iPhone


A Look at Code Completion and Swift Assist Coming in Xcode 16

Source: Apple.

Source: Apple.

Earlier today, I got the very first live demo of Swift Assist, one of the many developer tools introduced today by Apple. I also saw code completion in action. It was an impressive demo, and although the tools seem like magic and will undoubtedly be valuable to developers, they do have their limitations, which are worth exploring.

Code Completion in Action. Source: Apple.Replay

First, from what I could tell, code completion works extremely well. The demo I saw was of a simple restaurant app that displayed a menu. As an Apple representative typed variables and other items into Xcode, code completion named things in ways that made sense for a restaurant menu, such as Name, Price, and Calories. The feature also filled in types like strings, integers, and bools, along with the appropriate surrounding syntax.

In most cases, after typing just a handful of characters, the correct suggestion appeared and with a quick tap of the Tab key, the rest of the line of code was filled in. When the suggestion wasn’t what was wanted, a little additional typing steered the AI that backs code completion to the correct solution.

The model that drives code completion is trained specifically for the Swift programming language and Apple’s APIs. It runs locally on a developer’s Mac, enhancing privacy and ensuring that it’s available regardless of Internet connectivity. Although Apple was vague about the code on which the model was trained, it was clear from my briefing that it wasn’t on Apple’s own internal code, but Apple said it is code that it is authorized to use. I was also told that the model isn’t trained on the code of the developers that use the feature. Also worth noting is that Apple’s code completion model is continually updated independent of the update release cycle of Xcode itself.

Swift Assist in action. Source: Apple.Replay

The code completion demo also included a live demo of Swift Assist. Unlike code completion, Swift Assist requires an Internet connection because requests are sent to the cloud. As a result, it takes several seconds for Swift Assist to return results. The delay was noticeable compared to the speed of code completion, but it wasn’t a painfully long wait either.

Swift Assist allows developers to type a natural language prompt to generate code and UIs. Code can even be created from the text of a developer’s inline comment. The model that powers Swift Assist has an awareness of the Human Interface Guidelines, Apple’s frameworks, and what Apple considers coding best practices.

The results of Swift Assist were impressive, but it’s worth keeping in mind that it’s designed to help developers explore new ideas, prototype apps, and learn new frameworks, not write a full, complex app. It reminded me of a more sophisticated version of Swift Playgrounds in that way, generating useable code but not full apps. That’s not a knock against Swift Assist any more than it is to say you can’t write a complex app in Swift Playgrounds. Instead, Swift Assist is a tool for getting over the hurdle of a blank Xcode project and transitioning from the spark of an idea to concrete code.

It was also noted during my briefing that Swift is now a decade old, which is wild. It’s hard to believe it’s been that long since Chris Lattner took the stage at WWDC at the Moscone to drop the bombshell that Apple had developed a brand-new programming language. Swift has come a long way in the meantime, and with tools like code completion and Swift Assist, Apple is catching up with competitors like Microsoft that have used AI to enhance developer tools for a while, which is good to see.

You can follow all of our WWDC coverage through our WWDC 2024 hub or subscribe to the dedicated WWDC 2024 RSS feed.

Kolide ensures that if a device isn’t secure it can’t access your apps.  It’s Device Trust for Okta. Watch the demo today!

Access Extra Content and Perks

Founded in 2015, Club MacStories has delivered exclusive content every week for nearly a decade.

What started with weekly and monthly email newsletters has blossomed into a family of memberships designed every MacStories fan.

Learn more here and from our Club FAQs.

Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with apps, tips, automation workflows, longform writing, early access to the MacStories Unwind podcast, periodic giveaways, and more;

Club MacStories+: Everything that Club MacStories offers, plus an active Discord community, advanced search and custom RSS features for exploring the Club’s entire back catalog, bonus columns, and dozens of app discounts;

Club Premier: All of the above and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.