onmyway133 / blog

🍁 What you don't know is what you haven't learned
https://onmyway133.com/
MIT License
679 stars 33 forks source link

How to use GitHub Copilot for Xcode #985

Open onmyway133 opened 3 weeks ago

onmyway133 commented 3 weeks ago

During GitHub Universe 2024, GitHub announced that GitHub Copilot code completion in Xcode is available in public preview. The project is open source at CopilotForXcode

image

GitHub Copilot has been available as VS Code extension for a while, but this is first time we have official extension for Xcode.

GitHub Copilot for Xcode supports multiple programming languages commonly used in the Apple ecosystem, including Swift and Objective-C

Here's how to use this new extension in Xcode. I'm using Xcode 16 on macOS Sequoia. You can download latest Xcode from xcodereleases

Setting Up GitHub Copilot in Xcode

1. Download

Head over to release to download GitHubCopilotForXcode.dmg

Once downloaded, open and extract the file. Essentially you can drag GitHub Copilot for Xcode to Applications folder

image

2. Install

Follow the installation prompts. The Copilot icon will also appear in your menu bar.

Screenshot 2024-11-01 at 10 40 36 image

3. Login to GitHub

Authenticate with your GitHub account to use Copilot.

You need to have a Copilot license to get access to Copilot for Xcode. All Copilot individual, business, and enterprise users have access to the public beta

CleanShot 2024-11-01 at 10 43 29@2x

Once authenticated on GitHub, you will receive this message

image

4. Permission

Copilot needs Accessibility permission and Xcode Source Editor extension to work.

To grant Accessibility permission, simply click on Accessibility Permission in the GitHub Copilot extension for Xcode app, it will opens System Settings app with the correct Accessibility pages opened.

CleanShot 2024-11-01 at 10 46 17@2x

To grant Xcode Source Editor extension, click on Extension Permission, it will open System Settings with page Login Items & Extensions

CleanShot 2024-11-01 at 10 47 59@2x

While on the Login Items & Extensions we can also allow Copilot extension to be launched at login, if it isn't already turned on.

CleanShot 2024-11-01 at 10 49 44@2x

Using Copilot in Xcode

After granting Xcode Source Editor extension for Copilot, we should restart Xcode to apply the changes.

We should see Copilot in Xcode -> Editor menu

image

Start typing something, and press Tab to expand suggestions