XCode 4 Cursor Jumps To First Line When Auto Suggesting - xcode

I have a problem in XCode 4.2 when I have the autosuggest feature turned on. Whenever an autosuggest (autocomplete) pops up, the cursor will jump to the top of the file, to the second character of the first line. This happens regardless of whether or not I select the autosuggest or take any other action. As soon as I turn off the autosuggest feature, this behavior stops happening.
I have turned off all key binding associated with jumping to the top of the page and have deleted all derived data for the project as per some suggestions I have heard, but have not been able to solve the problem.
Anybody have a solution?

I had similar problem Xcode cursor jumped randomly. It was triggered by an editor theme using an italic font. I changed the font to a regular one, and the problem was resolved.
Simple solution (or workaround):
Open Preferences.
Open Fonts & Colors tab.
Select Basic theme.
I got the hint from this page.

Just in case there is a bounty awarded :) let me repeat my "solution" from above: I suggest moving aside your /Developer folder and re-installing Xcode. Simply running the installer w/o removing the old /Developer folder may not replace all the necessary files. Good luck.

I have had a similar problem where the cursor jumped to the top and I couldn't scroll down. I don't know if it is the same problem that you have but there is no real solution. Its just one of Xcode's bugs there are a lot more. Open another file in the project and go back to the file you were working on, close and reopen the project or restart Xcode. Thats the only solutions I found.
If thats not working, then you can always re-install Xcode

Related

How do I build an Xcode shortcut for frequently used code snippet? [duplicate]

When I follow all the instructions (including apple's video) to drag text to create a code snippet in xcode, I get a different system behavior: all I see is the selection ibeam... I can't drag. It just ends up selecting text again. Am i missing some obvious Apple-ism?
Thanks
Yes, I ran into the same problem, and Apple-ism seems to be a good term for this issue :)
It works this way:
Select (or highlight) the code your want to turn into a snippet
EDIT: Click and hold (do not drag!) on any part of the selected text for a short moment (like 2 seconds, sometimes 8 seconds)
EDIT: The mouse cursor will change icon (not on El Capitan).
Now you can drag the code over the snippets library, where a green + icon will appear. EDIT: On El Capitan the green icon does not appear, but the frame of the code snippets window will become thinner.
This happened to me as well. The given solution didn't work but still needed to create snippets.
This is a workaround although not the best option, it works.
From Xcode, select the snippet window, and leave it selected.
Open a text editor app.
From Xcode, select and copy the code you want to use to create your snippet.
Paste it into your text editor and then select all of it.
Now drag&drop normally from the text editor into the snippets window in Xcode.
As said, not the best option but it works.
(Note for Xcode 8.1) Sometimes selecting the text and maintain the mouse button clicked for 3..8 seconds the cursor turns into an arrow and it's possible to D&D. Too bad it only works sometimes...
On High Sierra 10.13.3 and XCode 9 I faced the same problem. The decision that works for me is selecting code on a blank space before the first symbol and then dragging it to the snippets library.
Important: you need to drag only from the blank space (look at the screenshot below). Otherwise you will reselect your code again.
The cursor changes only when you start dragging, so don't be confused and don't wait until it changes.
I've run into this problem with Xcode 7.2 on Mac OS X 10.11.2 (El Capitan). Click and hold on the selection and the cursor never changes from the I-beam to the arrow for dragging.
Although MLBDG's answer is a usable workaround, I found that quitting and restarting Xcode fixed the problem. This might not work for everyone, but it's worth a try if you're having difficulty.
just highlight your text
copy in filter text field that u can see on your bottom of snippet library
paste the text
now select the text and drag from there to snippet library
The answer is really !undisobvious. You need to select a chunk of text. Then click on actual text characters, but without moving the mouse. Only then will the gods of XCode bequeath unto you a draggable snippet of code to do with as you please. Should you dare to miss the text and click in empty but selected space, the demons of XCode will strike down your selection and make you start from scratch. The unfortunate will not even realise this feature actually exists.
Hold option to duplicate it. For instance to make a duplicate case statement without destroying your copy buffer, then replace the case you cleverly have ready to paste during your search.
As a UI designer it is not obvious to me why this has such an unreliable twitchy implementation.

Xcode assistant editor won't show some of the code

First of all, I would like you to know that the class IS set to the correct file in each ViewController - I know that because it did work before, but then I got a "crash" in Xcode that blinked quickly without me being able to read it before it went off again.
MY PROBLEM IS:
I have a lot of ViewControllers in my Xcode, everything was working fine, I was making some more features to the ViewControllers.
Then I got the "crash" as mentioned above, and it would not show any of the files/classes related to their ViewController in assistant editor.
Assistant editor just said: No Assistant Results. Then I read that I could just show the files inside my XCode project and delete project.xcworkplace and xcuserdata. And I thought it worked at first, but it did not work on every viewcontroller unfortunately - only on some of them.
Now, I still have plenty of ViewControllers left to edit that aren't working, and I would hate if I had to recreate every single one.
Does anyone have a better solution to this? I really hope you do :-)
Make sure you set Automatic not Manual.
There was some related answer but I can't find it. Anyhow: what I do to fix it is to uncheck the Target Membership in the File Inspector for the XIB and then turn it on again. That fixes the issue (in most cases) for me.
Also try restarting/clearing the different caches of XCode.
I was similarly not able to view code/classes relating to the View Controller. In my particular case, it appears i might have caused the issue- I turned OFF Indexing because Xcode was running terribly slow and around that time I started getting the issue and the message “No assistant results”.
To resolve this in my case, I turned indexing back ON and set the Assistant editor to “Automatic”.
To turn Indexing On or Off, open up the Terminal using either of the below commands-
Turn Indexing OFF:
defaults write com.apple.dt.XCode IDEIndexDisable 1
Turn Indexing ON :
defaults write com.apple.dt.XCode IDEIndexDisable 0
From accepted answer regarding Indexing: Stopping xcode from indexing
xcode 9.0
Open project.
Click on "Show the assistant editor".(top right side middle button - circle shape)
Code was show after do second step.
I cloned a project and found that I have the same problem. But all I did to fix it was to just sign the app at Signing and Capabilities and the option for the right View Controller pops up in the top bar of the Assisntant in my View

Why would Xcode stop drawing tabs when indent level is greater than three?

For some reason Xcode 4.5 and 4.4.1 have both stopped displaying indented text at the proper level if there are more than three Tab characters of leading whitespace on the lines.
Easier to show than describe:
There are five leading tabs on the line the arrow is pointing to, but Xcode is drawing it as if there were only three. Using the left and right arrow keys confirms the Tabs are there.
I have deleted the derived data associated with my projects, deleted the project.xcworkspace file and xcuserdata directories within the project package, mucked around with various combinations of Indentation settings in Xcode's Preferences, all to no avail.
Newly created projects exhibit the same behavior. Changing the Source Editor font preferences have no effect either. This is in OS X 10.8.1.
Help -- my brain can't understand the code when it doesn't "look right"! What else can I try?
So, I filed a Radar, then heard back from a friend of mine who was having the same problem. Are you using the new SourceCode Pro font from Adobe? Your screenshot makes it look like you might be. Try switching back to a different theme and restarting Xcode? That's what I did, and it seems to be fine.
Eventually I removed (after quitting Xcode) the entire UserData folder in ~/Library/Developer/Xcode and that seems to have fixed the problem.
Hopefully it won't take more than another half hour to restore all the key equivalents and syntax coloring that I am accustomed to.
Leaving the question 'alive' in case it happens to someone else.

Xcode Code Completion "flicker"

I've recently upgraded from Xcode 4.3 to 4.4 and I'm about to bash my screen in with frustration.
The problem I'm having is with the code completion. As I type a variable or method name, the completion window pops up with the suggestions like it's supposed to. But if I attempt to use the cursor keys to scroll between the suggestions, the suggestions disappear and the cursor moves in the code, not between the suggestions. If I press enter to accept the default suggestion, it again dismisses the suggestions and inserts a return into the code taking the cursor to the next line.
This doesn't happen every time I attempt code completion, but it does occur more often than not. For a given name I'm trying to complete, it either works or it doesn't (e.g. if I press escape to get the suggestions back, it will disappear just as quickly as the first time it disappeared for that line/name I was trying to complete). When I get to the next line of code, it's a whole new bet whether it will work or not. It seems that the closer to the actual completion of the name I am, the more likely it is to actually work and accept the suggestion or move between the suggestions. Sometimes, if I act quickly enough, I can move the highlighted suggestion one or two lines before the suggestions disappear. I'm aware that if you don't select a suggestion quickly enough that it's supposed to eventually remove the suggestions (on the order of several seconds), but this behavior is not what I'm describing. I'd be VERY happy at this point if I had a single second to actually respond and select a suggestion from the pop-up.
So far I've tried a clean of the project, deleting all of the project's derived data, and restarting xcode. All of which don't seem to affect the behavior. Any ideas? I've searched stackoverflow and google and haven't found any other people reporting this problem ...
Thanks for any ideas,
Will
UPDATE:
After upgrading to the XCode 4.6 release version (and 4.5 somewhere in the middle there), this problem is still present ... and making edits in the left/main editor window is still a work-around.
I am seeing the same with Xcode 4.4.1. It seems to be related to where the completion window pops up. Debugger pane open or closed does not change anything here.
When in the Assistant Editor trying in the right pane the completion windows flickers. Same line of code in the left window works fine. Single editor works, too.
Try upgrading to Xcode 4.4.1. I used to have this problem, but I don't seem to have it after upgrading.
If this doesn't solve the problem, a crude workaround seems to be to put a lot of blank lines at the bottom of each file - the problem seems to occur from frequently when the file is scrolled all the way to the bottom.
There is a fix (at least Xcode 4.6.3): re-create the affected file by deleting it. Now create a new file and copy the content to it and drag it into the project - done. Fixes the issue here. It seems to be tied to certain files.

Xcode find in document stuck in case-sensitive

When in Xcode editing code for my objective C files, I often press Command-F to bring up the little Find-In-Document banner across the top. Sometimes this gets stuck in case-sensitive search, and when it does that it also won't loop through the entire document and sometimes won't even display the selected found string.
I can't find any options to turn off the case sensitivity, and I never intentionally turned it on. I've restarted xcode several times hoping that would be it but it's changed nothing.
Slightly off-topic, but this was the best place I could think of to ask this question. Thanks for any response!
EDIT: I've also tried restarting the computer. Still no dice. Also this happens on any project I open in xcode and is not specific to one project.
Anna's comment is the correct answer: When you press Cmd-F, clicking on the little magnifying glass next to the search input brings up a menu where you can check/uncheck Ignore Case.
You can set parameters for search by clicking on magnifier placed in left-side of search-bar.
There is provision to select/de-select "Match Case" i.e. case-sensitive search on pop-up shown.
Below is screenshot for the same.

Resources