

I’ll save that for another post.įinally, you can also enable/disable GitHub copilot from the bottom toolbar anytime from the GitHub Copilot icon. There is another way to preview the changes that I haven’t figured out yet but it entails using xcodebuild command to run and launch the simulator. It seems VSCode won’t tell you it won’t compile. This way you can preview the changes and if it complies properly. If you want more options and suggestions, hit CTRL + Enter and it would open the suggestions in a new tab, where you can accept solutions.īy the way, you can have XCode open on the same project as your VSCode Editor so you can preview using XCode Canvas. Suggest a function by typing the name: func addĬreate code based on comments using natural language( like ChatGPT) // create a view with a slider that adjusts the opacity Start creating the struct view by just typing the initial code: struct MyView (Hit the tab key to accept the suggestion or hit the esc key). It would attempt to suggest the next code. There is a variety of ways GitHub Copilot could assist when writing code.

You can follow this getting started guide. Open the Extension Marketplace and search for “GitHub Copilot” then select from the results and go ahead and install. You must have an active GitHub Copilot subscription for this to work. Step 4: Install the GitHub Copilot extension in VSCode Open VSCode and go to the Extension Marketplace and search for “Swift” then select from the results and go ahead and install. Step 2: Install Swift Extension in VSCode I find that I don’t need to run this command explicitly for the SourceKit-LSP to work. It can be run from the terminal with the command xcrun sourcekit-lsp I’m using XCode 14.2 at the time of writing this post. Hopefully, you should already have XCode, if not, go to Mac App Store and download XCode. Having XCode 11.4+ and higher, the SourceKit-LSP server is included, no need for a separate download. Step 1: Get SourceKit-LSP by installing XCode To do this we need the Language Server Protocol(LSP) which is supported on both VSCode and Swift via a package called SourceKit-LSP. How To Setup VSCode for Swift Developmentįirst, we need VSCode to show definitions and code completion when writing in the Swift language. Good thing there is a way to accomplish it in VSCode. There is a nice attempt using Xcode Source Editor Extension in this GitHub project by “intitni” that allows you to run Github Copilot in Xcode but honestly, it is a bit clunky to use and not as seamless experience compared to VSCode.
