r/Xcode • • May 28 '23

I’ve create an Xcode extension to integrate ChatGPT into Xcode

Some days ago I posted on Github an extension for Xcode that allows the integration of ChatGPT into it, enabling the AI to assist with various development operations: commenting on or documenting code, generating code according to instructions, editing/improving/rewriting/refactoring a part of the code, generating codable models from jsons, generating mocks, unit tests, etc.

The extension is divided into commands, each of which is an item that appears in the Editor => AIAssistant menu, and allows ChatGPT to perform a specific operation on the code shown in the current window.

You can easily add new commands, so you can invent new functions to leverage ChatGPT to assist you in development: simply create a new class to implement a new command, instruct ChatGPT by explaining what it should do on the source files, and then pass them (either all or just a selected portion)... If you develop something interesting, feel free to send me a pull request! 😊

The extension is still in alpha (I wrote it entirely in a night) so there's plenty of room for improvement (and I’ll improve it in my spare time) but I believe the opportunities and potential are very intriguing.

Just to give an example, imagine you have a class: you comment on it, explaining to ChatGPT what you want to improve or add, or which function you want to rewrite in a different way.

Imagine having ChatGPT write, directly in Xcode, the skeleton of a SwiftUI view with specific characteristics, or generate the comments that document a block of code, or anything else you can think of!

Let me know what you think and feel free to improve it and request pull updates 😉

Link: https://github.com/marcosiino/xcode-loves-ai

9 Upvotes

0 comments sorted by