Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode plugin for improving code completion

Recently I've done a small service (available in Github) to return a switch case structure from a given enum.

The next step is to achieve this behaviour as an Xcode code completion option when I begin typing the enumeration name.

Code completion

What I want is to add a new option in this popup giving the possibility of generating a switch case with those three options.

I'm searching for documentation to make an Xcode plugin but I can't find much. My first question, and the most important is: is it possible to get the definition of a symbol while I'm typing it, to extract the data of the enum and generate the snippet?

like image 521
emenegro Avatar asked Aug 07 '13 07:08

emenegro


People also ask

Does Xcode have code completion?

Conversation. Xcode tip #9: Xcode has great code completion built right in, but sometimes as you scroll through the options you might find the names are too long to fit. Fortunately, you can just grab the edge of the autocomplete popup and drag it as wide as you want!

How do I enable autocomplete in Xcode?

Go to Xcode > Preferences > Text Editing again. Quit out of Xcode and then relaunch Xcode. Now go to Code completion and check 'Suggest completions while typing'. Try typing library function or enum and enjoy!

What does P mean in Xcode?

P: property (IIRC Xcode favors L/V for Swift, but you see P for ObjC properties)

Is Xcode a good IDE?

Pros: Xcode is the best tool for developing iOS apps in Swift: it's very well integrated with the language, the compiler and the source control (Git). You can easily start developing your first mobile app for iPhone or you can use it for huge and professional products.


2 Answers

You can have a look at KSImageNamed, an XCode plug-in used to add autocompletion on image name.

You can inspire yourself on its code.

KSImageNamed-Xcode

like image 186
Gougou Avatar answered Nov 13 '22 17:11

Gougou


an alternative to what you are suggesting is to save it as a code snippet. it wont be dynamic like you probably want it, but if you are using the same enum over and over, it can work. enter image description here

like image 25
Fonix Avatar answered Nov 13 '22 18:11

Fonix