Copilot for Xcode is an Xcode Source Editor Extension that provides Github Copilot support for Xcode. It uses the LSP provided through Copilot.vim.
- Node installed to run the Copilot LSP.
- Public network connection.
- Active GitHub Copilot subscription.
- Folder Access
- Maybe Input Monitoring (Realtime Suggestions Only)
Installation and Setup
- Download the Copilot for Xcode.app from the latest release, and extract it to the Applications folder.
- Open the app, and click “Set Up Launch Agents” to set up a background running XPC Service that does the real job.
- Refresh the Copilot status, if it fails, quit and restart the app.
- Sign in. You will be directed to a verification website provided by GitHub, and a user code will be pasted into your clipboard.
- After signing in, go back to the app and click “Confirm Sign-in” to finish.
- Enable the extension in the Settings.app, then maybe restart Xcode.
The first time the actions run, the extension will ask for 2 types of permissions:
- Accessibility API: which the extension uses to get the editing file path.
- Folder Access: the extension needs, to run some Apple Scripts to get the project/workspace path.
- Get Suggestions: Get suggestions for the editing file at the current cursor position.
- Next Suggestion: If there is more than 1 suggestion, switch to the next one.
- Previous Suggestion: If there is more than 1 suggestion, switch to the previous one.
- Accept Suggestion: Add the suggestion to the code.
- Reject Suggestion: Remove the suggestion comments.
- Turn On Realtime Suggestions: When turn on, Copilot will auto-insert suggestion comments to your code while editing. You have to manually turn it on for every open window of Xcode.
- Turn Off Realtime Suggestions: Turns the real-time suggestions off.
- Realtime Suggestions: It is an entry point only for Copilot for Xcode. In the background, Copilot for Xcode will occasionally run this action to bring you real-time suggestions.
About realtime suggestions
The implementation won’t feel as smooth as that of VSCode.
The magic behind it is that it will keep calling the action from the menu when you are not typing, clicking or moving your mouse. So it will have to listen to those events, I am not sure if people like it.
Hope that next year, Apple can spend some time on Xcode Extensions.
- If a realtime suggestions request is triggered, it will block your editor until the result is return.
Prevent Suggestions Being Committed
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. Maybe later I will add an action for that.
# 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."
- The first run of the extension will be slow. Be patient.
- The extension uses some dirty tricks to get the file and project/workspace paths. It may fail, it may be incorrect, especially when you have multiple Xcode windows running, and maybe even worse when they are in different displays. I am not sure about that though.
- The suggestions are presented as C-style comments, they may break your code if you are editing a JSON file or something.
Q: The extension doesn’t show up in the
A: Please make sure it’s turned on in
Settings.app > Privacy & Security > Extensions > Xcode Source Editor Extension.
Q: The extension says it can’t connect to the XPC service/helper.
A: Please make sure you have set up Launch Agents, try running
launchctl list | grep com.intiifrom the terminal, and see if
com.intii.CopilotForXcode.XPCServiceexists. If not, check
~/Library/LaunchAgentsto see if
com.intii.CopilotForXcode.XPCService.plistexists. If they don’t, and the button in the app fails to create them, please try to do it by hand.
Q: The extension complains that it has no access to the Accessibility API
A: Check the list in
Settings.app > Privacy & Security > Accessibility. Turn the toggle on for
Copilot for Xcode. If it’s not on the list, add it manually.
If you have just updated the app, consider restarting XPCService in app or trying removing the Launch Agents and set it up again!
Q: I turned on realtime suggestions, but nothing happens
A: Check the list in
Settings.app > Privacy & Security > Input Monitoring. Turn the toggle on for
Copilot for Xcode. If it’s not on the list, add it manually. After that, you may have to restart the XPC Service.
Q: Will it work in future Xcode updates?
A: I don’t know. This extension uses many tricks to do its job, and these tricks can break in the future.