| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Copilot for Xcode is an Xcode Source Editor Extension that provides Github Copilot and ChatGPT support for Xcode. It uses the LSP provided through Copilot.vim to generate suggestions and displays them as comments or in a separate window.
Thanks to LSP-copilot for showing the way to interact with Copilot. And thanks to LanguageClient for the Language Server Protocol support in Swift.
For frequently asked questions, check FAQ.
For development instruction, check Development.md.
For suggestion features:
For chat and prompt to code features:
If you are concerned about key logging and cannot trust the binary, we recommend examining the code and building it yourself. To address any concerns, you can specifically search for CGEvent.tapCreate, AXObserver, AX___ within the code.
You can install it via Homebrew:
brew install --cask copilot-for-xcodeOr install it manually, by downloading the Copilot for Xcode.app from the latest release, and extract it to the Applications folder.
Then set it up with the following steps:
Enable the extension in System Settings.app.
From the Apple menu located in the top-left corner of your screen click System Settings. Navigate to Privacy & Security then toward the bottom click Extensions. Click Xcode Source Editor and tick Copilot.
If you are using macOS Monterey, enter the Extensions menu in System Preferences.app with its dedicated icon.
The first time the app is open and command run, the extension will ask for the necessary permissions.
Alternatively, you may manually grant the required permissions by navigating to the Privacy & Security tab in the System Settings.app.
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
This app runs whenever you open Copilot for Xcode.app or Xcode.app. You can quit it with its menu bar item that looks like a steering wheel.
You can also set it to quit automatically when the above 2 apps are closed.
If the app was installed via Homebrew, you can update it by running:
brew upgrade --cask copilot-for-xcodeAlternatively, You can use the in-app updater or download the latest version manually from the latest release.
If you are upgrading from a version lower than 0.7.0, please run Copilot for Xcode.app at least once to let it set up the new launch agent for you and re-grant the permissions according to the new rules.
If you find that some of the features are no longer working, please first try regranting permissions to the app.
About real-time suggestions
Whenever you stop typing for a few milliseconds, the app will automatically fetch suggestions for you, you can cancel this by clicking the mouse, or pressing Escape or the arrow keys.
Chat commands are not available in comment mode.
The chat panel supports chat plugins that may not require an OpenAI API key. For example, if you need to use the /run plugin, you just type
/run echo hello
If you need to end a plugin, you can just type
/exit
| Command | Description |
|---|---|
| /run | Runs the command under the project root. You can also use environment variable PROJECT_ROOT to get the project root and FILE_PATH to get the editing file path. |
| /airun | Create a command with natural language. You can ask to modify the command if it is not what you want. After confirming, the command will be executed by calling the /run plugin. |
Prompt to code commands are not available in comment mode.
It looks like there is no way to add default key bindings to commands, but you can set them up in Xcode settings > Key Bindings. You can filter the list by typing copilot in the search bar.
A recommended setup that should cause no conflict is
| Command | Key Binding |
|---|---|
| Get Suggestions | ⌥? |
| Accept Suggestions | ⌥} |
| Reject Suggestion | ⌥{ |
| Next Suggestion | ⌥> |
| Previous Suggestion | ⌥< |
| Chat with Selection | ⌥" |
| Explain Selection | ⌥| |
Essentially using ⌥⇧ as the "access" key combination for all bindings.
Another convenient method to access commands is by using the ⇧⌘/ shortcut to search for a command in the menu bar.
Since the suggestions are presented as comments, they are in your code. If you are not careful enough, they can be committed to your git repo. To avoid that, I would recommend adding a pre-commit git hook to prevent this from happening.
#!/bin/sh
# Check if the commit message contains the string
if git diff --cached --diff-filter=ACMR | grep -q "/*========== Copilot Suggestion"; then
echo "Error: Commit contains Copilot suggestions generated by Copilot for Xcode."
exit 1
fiMIT.
| Back | FazBrowse Home | New Git URL |