Skip to main content

Obtención de sugerencias de código en el IDE con GitHub Copilot

Use GitHub Copilot para obtener sugerencias de código en el editor.

About GitHub Copilot in Xcode

This guide demonstrates how to get coding suggestions from GitHub Copilot in Xcode. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

Prerequisites

To use GitHub Copilot for Xcode, you must install the GitHub Copilot for Xcode extension. See Installing the GitHub Copilot extension in your environment.

Getting code suggestions

GitHub Copilot offers coding suggestions as you type. For example, type this function signature in a Swift file:

Swift
func calculateDaysBetweenDates(

GitHub Copilot will automatically suggest an entire function body in grayed text. To accept the first line of a suggestion, press Tab. To view the full suggestion, hold Option, and to accept the full suggestion, press Option+Tab.

Improving code suggestions

If you encounter issues with code suggestions, such as conflicting or missing suggestions, you can try the following:

  • Disable Xcode's native predictive text completion: To avoid receiving two sets of code suggestions, you can disable Xcode's native predictive text completion. You can find this setting in the Xcode settings in the "Editing" tab under "Text Editing".
  • Check for duplication detection in Copilot: If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information on duplication detection, see Managing Copilot policies as an individual subscriber.
  • Check for updates and restart Xcode: Ensure you have the latest version of Copilot for Xcode in the extension application and restart Xcode.

You can also open an issue in the Copilot for Xcode repository.

Next steps