Big news came from Microsoft for the Xcode development environment that we use when developing iOS native applications, and Github Copilot can now be used with Xcode. With Copilot, you can now write code faster and it suggests some previously used codes for you, allowing you to write cleaner, simpler, and more understandable codes while making corrections to your code.

What is Copilot?

Copilot is an AI code assistant developed in collaboration with GitHub and OpenAI that helps developers write code. This tool, which previously worked integrated with popular development environments such as Android Studio and Visual Studio Code, analyzes the code written by users and offers suggestions for code completion, function suggestions, and error correction. These suggestions are provided by OpenAI’s Codex language model and trained on a large code dataset.

Info: It is said that Gemini’s experience will be added to Copilot in the near future and it will be a more powerful code completion tool. You can subscribe to the newsletter at the end of the article for developments.

Copilot supports developers in the following areas:

  • Code Completion and Suggestions: It provides suggestions suitable for the line of code you write and speeds up your workflow.
  • Functions and Algorithms: It quickly provides suggestions for complex algorithms or specific functions.
  • Documentation: It suggests explanation lines for functions, which speeds up the documentation process in particular.
  • Error Detection and Correction: It identifies errors and areas that need improvement in your code and offers correction suggestions.

How to Use Copilot in Xcode?

How can you use it with the Github repo? We will explain and implement it step by step.

Install Copilot on your macOS computer

1. Visit the Releases page of the CopilotForXCode Github repo by clicking here.

2. Download the .dmg file from the release section which contains the latest GitHubCopilotForXcode.dmg file. Click for direct download link v0.27.0 (release version).

3. Add the “Github Copilot For Xcode” application to your macOS computer as an application by placing the .dmg file you downloaded in the Applications folder as shown in the image below.

Github Copilot install for macOS

4. To install a download outside of the App Store, you need to allow the popup below.

Grant Permissions To Github Copilot

5. Open the Github Copilot For Xcode application by pressing cmd + space. You will see a welcome screen like the one below.

6. Click on the “Open Prefrences Screen” button for Accessibility permission. And activate it as shown in the screen below.

7. Then go back to the Github Copilot for Xcode application and it will direct you to System Preferences to enable the plugin in Xcode as shown below. If you do not see this step, please restart.

8. When you click on the button, it will take you to the settings and you will see a screen like the one in the left image below. We add Copilot as an extension to Xcode by clicking on the 2nd Xcode Source Editor Button from the bottom and selecting the Github Copilot option as on the right.

9. Then let’s open Xcode and give the permission to access the Copilot folder (as in the image below) by saying OK and proceed.

Open Xcode & Login To Github

10. Then, let’s go to a file that contains any Swift code in our project. As shown below, click on the Editor -> Scroll to end -> Github Copilot -> Open Github Copilot for Xcode Settings (visible if logged in before) or Signin Github (visible if not logged in) button on Xcode.

Info: If you are not logged in, follow the instructions and log in to github. If you have any problems, please let me know in the comments.

Get Started With Github Copilot For Xcode

11. Afterwards, go to the next line in any of your Swift codes and start typing a few letters. Now you will see the logical suggestions offered to you by Github Copilot, the artificial intelligence code assistant in the placeholder.

Here is an example

What Are The Contributions And Disadvantages Of Copilot?

Contributions

It suggests the next code you will write for you by looking at the codes used by the developers who wrote it before. When you copy a code, it offers quick suggestions for you to add it in line with the related codes in other places. When you write a function name, it fills in the content for you.

Disadvantages

If your code performs specific operations, logical operations that are appropriate for your project, copilot does not detect this and may offer you wrong choices/suggestions. In fact, I observe that it prints faulty code almost 40% of the time. In other words, it may actually slow you down while speeding you up. Depending on your experience, its advantages may increase for you, but it is not recommended for people who are new to software development with Swift and iOS applications.


While you can create wonders with Copilot, you may also regret the faulty codes. I mentioned this in my article comparing Copilot and Gemini, you can get better information about Copilot by reading this.

Use your own mind more than the AI’s mind. Don’t trust every code it writes, otherwise it will explode in prod and you will be upset :)

Did you like this article?
You can subscribe to my newsletter below and get updates about my new articles.

Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *