Using predictive code completion in Xcode
As you know, when you type code, Xcode will try to help you by displaying suggestions in a pop-up menu. Code completion takes this to another level, providing more thorough code suggestions via an on-device AI coding model. This model is specifically trained on Swift and Apple SDKs and will be able to infer what you are trying to do based on the surrounding code context, such as function names and comments.
To see this in action, you'll add a new file to your project and create some example structures and functions. Follow these steps:
- Open the completed Xcode project in the
Chapter24folder of the code bundle for this book, which can be downloaded from https://github.com/PacktPublishing/iOS-26-Programming-for-Beginners-10E. - Click Settings in the Xcode menu and click the Editing tab. Click Completion and set Display code predictions to Automatically:

Figure 25.1: Settings window showing Display code...