Skip to main content

Asking GitHub Copilot questions in your IDE

Use Copilot Chat in your editor to give code suggestions, explain code, generate unit tests, and suggest code fixes.

Note

Copilot Chat in Xcode is in public preview and subject to change.

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.

If you have access to GitHub Copilot via your organization, you won't be able to use GitHub Copilot Chat if your organization owner has disabled chat. See Managing policies for Copilot in your organization.

Submitting prompts

You can ask Copilot Chat to give code suggestions, explain code, generate unit tests, and suggest code fixes.

  1. To open the chat view, click Copilot in the menu bar, then click Open Chat.

  2. Enter a prompt in the prompt box. For example prompts, see Getting started with prompts for Copilot Chat.

  3. Evaluate Copilot's response, and submit a follow up prompt if needed.

    The response often includes interactive elements. For example, the response may include buttons to copy or insert a code block.

Using keywords in your prompt

You can use special keywords to help Copilot understand your prompt.

Slash commands

Use slash commands to avoid writing complex prompts for common scenarios. To use a slash command, type / in the chat prompt box, followed by a command.

To see all available slash commands, type / in the chat prompt box. For more information, see GitHub Copilot Chat cheat sheet.

File references

By default, Copilot Chat will reference the file that you have open or the code that you have selected. To attach a specific file as reference, click in the chat prompt box.

Chat management

You can open a conversation thread for each Xcode IDE to keep discussions organized across different contexts. You can also revisit previous conversations and reference past suggestions through the chat history.

Sharing feedback

To indicate whether a response was helpful, use or that appear next to the response.

Further reading