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.
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?
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
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.
Does the Enumeration section here help?
https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html#//apple_ref/doc/uid/TP40014150
It states that NS_ENUM "improves code completion".
I just find a plugin that makes exactly what I wanted, SCXcodeSwitchExpander. It works like a charm :D
Related
I am not very familiar with Xcode,
Since I think every decent IDE should have a shortcut for auto-fix a template of implemented protocol (such as interface in java) to save some effects of the programmers to just fill in the logic and don't have to type in the method name and parameter stuff.
Such as when we meet this:
And I googled around and some guy said that there should be a fix all in scope thing in the Editor, but seems I can't make that clickable :-(
So, how to do this with xcode? Thanks.
Unfortunately Xcode is fairly behind compared to other IDE's in features for refactoring and such.
The main Xcode version: 8.x, can't do what you wish for. But some of it will be/is available in beta Xcode 9
Xcode may suggest a fix for a compiler error. You can click the errors individually to see the suggested fix(es) and select one.
Alternatively the 'Fix All In Scope' allows you to tell Xcode to select suggested fixes of the current file.
I've updated my Xcode yesterday to version 7.3 and since then I got a really strange autocomplete (marked text, case sensitive etc.):
Is it something of the new version? Can I turn it off and use the classic autocomplete of Xcode?
Thank you!
Yes, it is a new autocomplete in the new Xcode version. It uses fuzzy matching to provide suggestions. I haven't found a way to turn it off, but give it a shot. The old autocomplete is absolutely dreadful. I used to install a Fuzzy Autocomplete plugin to make it work properly.
In the old days (in case of Objective-C, for instance, but it's the same with Swift), if you wanted to implement
- tableView:heightForRowAtIndexPath:
you typed -tableView, saw all the methods starting with tableView:, then you added a colon, and the autocomplete died. Now you can just enter something like -tv:hfrowatinp, and you instantly get your method.
It will take a bit of time getting used to, but it's worth it, trust me.
I'm learning basics of Objective-C and using XCode for writing code.
As you all know autocomplete option is perfect for new users that don't know (or remember) name of functions.
I have a problem with using autocomplete in XCode 6.3 couse its just.. not working - it is not showing anything or showing things that are not connected.
For example I just wrote simple few lines of code gusing NSMutableArray and NSEnumerator, when I'm trying to remind myself function/message 'nextObject' of NSEnumerator, XCode is not suggesting anything.
Here is a pic to show it:
Am I doing sth wrong or there is a way to fix it?
thanks in advance!
It must be a temporary glitch. Happens to me almost all the time while Xcode is "indexing". You might be typing too fast and by the time Xcode gives indexing a break and looks for the auto-completion you might have types something for which there is no method (or something that you expected)
Also, for custom classes & method, make sure you have included the respective header files.
It seems that autocomplete does not work when there is an error in the code.
The reason for autoComplete not working can be anything. Do any one of the following to debug it
Check if there are errors and if so try to solve it and then check autoComplete. If any error is present in any of the line then autoComplete will not work for below code. Try autoComplete above the error incase you want to check.
If debugger does not throw any error then try commenting out the all lines and uncomment it from top to methods to recheck the autoComplete
Quit Xcode and Reopen it
Clear Derived data and then launch Xcode and check
I am using Xcode 6.1 on Yosemite, writing IOS apps using swift.
For example:
If I type:
myClass.st
I was hoping the editor to show me this:
myClass.SetTitle()
but the reality is not what I had expected.
the editor says no match. In case of visual assist or Sublime Text, "st" mathes "SetTitle"
Sometimes people only remember a few keywords of the long variable name, rather than the full name from the very beginning.
Is is possible to solve this issue by some plugins?
Thank you
I think I have found the answer to this.
The plugin is called
FuzzyAutocompletePlugin
Written by GitHub.com/chemo
As we all know Xcode's code completion is awesome and necessary at the same time. But sometimes it can be be quite annoying as well...
Is there any way that I can modify the list of possible completion results?
E.g. I'm using "CGSizeMake" all the time, but never want to use "CGSizeMakeWithDictionaryRepresentation" that is suggested in the first place. So I would like to exclude the later one. Another example is "Nil" vs. "nil".
Any information regarding how the code completions works would be appreciated.
I don't believe so. The code completion is generated from indexing the code within the project so anything that is included in the project will be available. Anything that you do to limit the indexing will break the code completion for changes to the code in the project.
Possible options for you include code snippets and, possibly but likely a lot of work, creating an Xcode plugin to try to modify the completion (random sample plugin project).
This is slightly off topic, but you could try using AppCode. AppCode has a much more intelligent auto complete. With AppCode you can also create certain keywords for auto complete as well.