Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Xcode 16 Brings Predictive Code Completion Using Custom Model

Xcode 16 Brings Predictive Code Completion Using Custom Model

At WWDC 2024, Xcode and Swift Playground senior manager Ken Orr presented the most salient features of the upcoming version of Xcode, Xcode 16, including predictive code completion and many bug fixes and improvements.

One of Apple's leitmotives at WWDC 2024 was the integration of generative AI features into their OSes and tools. Xcode is no exception in this regard with its new LLM-powered code completion. Orr explained that Apple trained its own model specifically tailored for Swift and Apple's SDKs.

[Predictive code completion] uses your project's symbols to customize suggestions and runs locally on your Mac. Your code is private, you get super-fast results, and works even when you are offline.

Orr demoed Xcode's ability to suggest variable names and types based on the name of a struct by just typing the initial letter. The same kind of behavior applies to the definition of functions, whereby Xcode can also propose an implementation in some specific cases, e.g. when the function is meant to sort a collection, as Orr showed.

As you would expect, predictive code completion can generate a function from a comment expressed in human language. For example, if you enter the comment Return videos for a given director, as Orr did in the demo, Xcode will suggest the signature func videosForDirector(_ director: String) -> [Videos] as well as a plausible implementation of filtering a collection.

Another nice feature of Xcode predictive code completion is its ability to fill out all arguments to a function you pick from a list of methods available on an object. This means that you do not get just the usual placeholders, but code that will compile from the outset, hopefully with meaningful values so you can try it out, says Orr.

This is not revolutionary and pretty much close to what you have come to expect from current LLM-enabled IDEs that are already available. it is interesting that Apple is now providing this same kind of functionality to all developers through its standard development environment and tightly integrated with its platforms, languages, and tools.

As a final note, Xcode predictive code completion model is less than 2GB and requires Apple Silicon and at least 16GB of unified memory.

Xcode 16 includes many more new features and bug fixes in distinct areas, including the UI, the Clang compiler, the asset catalog, the build system, C++ standard compliance, and more. Do not miss the official release notes for the full detail.

Xcode 16 is currently available as a beta and requires a Mac running macOS Sonoma 14.5 or later.

About the Author

Rate this Article