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, like 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
Chapter22
folder of the code bundle for this book, which can be downloaded from https://github.com/PacktPublishing/iOS-18-Programming-for-Beginners-Ninth-Edition. - Click Settings in the Xcode menu and click the Text Editing tab. Click the Editing tab and tick the Predictive code completion check box:
Figure 26.1: Settings window showing...