Copilot for Xcode is an Xcode Source Editor Extension that provides Github Copilot support for Xcode. It uses the LSP provided through Copilot.vim.
Thanks to LSP-copilot for showing the way to interact with Copilot. And thanks to LanguageClient for the Language Server Protocol support in Swift.
- Node installed to run the Copilot LSP. (Version 16 preferred)
- Public network connection.
- Active GitHub Copilot subscription.
- 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.
- 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 Editor menu.
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 ifcom.intii.CopilotForXcode.XPCServiceexists. If not, check~/Library/LaunchAgentsto see ifcom.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 forCopilot for Xcode. If it's not on the list, add it manually.If you have just updated the app, consider trying removing the Launch Agents and set it up again!
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.
Check my other extension, you can find a short introduction there.
- Auto trigger Copilot while editing (I have some ideas but not sure if they will work).
