15

As of recently I experience some troubles with Xcode's 6 code editor, which conclude in rapid change of focus in the editing window, jumping to a completely different place in the same file, while editing text. This is how it all started. Lately the editor refuses to scroll up and down, hangs, stops displaying the line numbers, or any other text altogether. What can I do to make it stop misbehave? All the solutions I found thus far are concerning older versions of Xcode and do not work for me.

Update: I initially thought it was the Optionals. There is a point in my code where I do this:

tile?.position.vertical >= 2

I presumed that by comparing the optional to a value, I messed with the compiler and I was supposed to compare it only to nil. Subsequent testing proved me wrong. Then I notices something in one of my enumerations:

enum Figure: Int {
     case King = 0
     case Pawn = 1
     case Bishop = 3
     case Knight = 5
     case Rook = 7
     case Queen = 9

     func pieceName() -> String {
        switch self {
        case .Pawn:
            return "Pawn"

        case .King:
            return "King"

        case .Bishop:
            return "Bishop"

        case .Knight:
            return "Knight"

        case .Rook:
            return "Rook"

        case .Queen:
            return "Queen"
        }
    }
}

Notice how nicely the code gets coloured in the switch statement, obviously Pawn, King and so on are a part of the same enumeration. Well, not in my case. My copy of Xcode will say "Symbol not found" when I command-click one of the case values in the function. So, what do you think could this be the culprit to my troubles and if yes, how can I fix it?

  • I don't know the fix but I'm seeing the same thing. Editor jumps around to random spots in the file when I try to type. Text disappears and reappears. I've turned off all plugins and all of the code completion stuff and it's still happening. – Kirby Todd Dec 08 '14 at 07:20
  • 3
    @KirbyTodd, I think I have got a solution. If you are using customised colour theme and have different sized fonts and a mixture of italics and bolds, it could lead to what we are seeing. For me removing the italics and equalising all font sizes did the thing. Can you please change your colour theme and come back to me with the result so we can post it as an answer. – Христо Узунов Dec 09 '14 at 10:13
  • The issue disappears after making fonts all the same size in my theme. Good catch! – Kirby Todd Dec 09 '14 at 17:46
  • I had all the same font sizes and this still happened for me. Turns out in xCode8 (and even in xCode7) you get these same issues because the font sizes in Apple's own warning dialogues are not the same. Had to turn off deprecated warnings with CLANG #Pragma pop http://stackoverflow.com/a/40063442/2057171 – Albert Renshaw Oct 15 '16 at 19:44

3 Answers3

33

Equalise all font sizes and remove any italics and bolds in your colour theme.

The answer to this issue I discovered in the Apple Developer forums. Unfortunately, I cannot find the thread there. It basically said that the behaviour I was experiencing was the result of a colour theme I was using having different sized fonts and a combination of italics and bolds. The thing is that there were no more comments after this guy's post, confirming or disproving the solution. For me, it did the thing. And now that @Kirby Todd has confirmed it, I am posting it as an answer.

  • I set my keywords to semi bold and saw another bad effect: the line number gutter (and some other parts) are constantly flickering now on each keypress and often stay empty, instead showing the line numbers. XCode 6 is truly the worst XCode version since a decade. – Mike Lischke Dec 25 '14 at 14:49
  • That flicker you see, I used to have it as well. Once again, it all went away with me using equal font settings throughout the colour theme. – Христо Узунов Dec 25 '14 at 15:12
  • I set my comments font to italics. In Xcode 6 the result is some flickering while typing. I did change my font and color theme to a default one ... now it works correctly again – user3378170 Jul 11 '15 at 12:31
  • Yep... as of 16 July 2015 this problem still exists and the solution is to remove all bold text. – RFAustin Jul 16 '15 at 23:30
  • Yuck. Another confirmation of this problem on XCode 6.4 here. it seems like anything that affects font spacing (excepting non-monospaced fonts) can trigger this issue. Over to AppCode I guess? :-( – Zxaos Jul 17 '15 at 01:57
  • 1
    This issue is still popping up on Xcode 7 beta and it never fails to drive me crazy. I'm going to try this fix and report back. Cheers. thx! – Blessing Lopes Jul 17 '15 at 23:11
  • I have the same issue on both Xcode 6.4 and Xcode 7 beta versions. – pyanfield Aug 26 '15 at 10:12
  • Xcode 7.2beta still sucks monkey nuts. Ta for workaround. – foo Nov 12 '15 at 21:57
  • Been using 7.3 with a heavily modified colour theme for a few days now, and I don't see any of the issues I used to get with that before. There is still hope for Xcode... – Христо Узунов Mar 29 '16 at 12:28
  • 1
    I still these this issue in 7.3. After setting all text to the same font size the jumping around has finally stopped. – Mike Sabatini Apr 05 '16 at 15:21
  • I take my previous comment back. It took Xcode a week to start misbehaving again. So no hope left... – Христо Узунов Apr 07 '16 at 11:13
3

This was happening to me in Xcode 7.1.1 (7B1005). It got so bad I went back to vi for a while!

I considered the discussion above, but I never adjusted my fonts and was using the defaults. I'm on an MacBook Air. There wasn't enough memory pressure or memory used to suggest it was swapping and couldn't keep up, which is another reasonable cause.

However, in my case at least deleting all the "Derived Data" made the problem go away. I didn't even have to quit Xcode!

This is simple to do (provided here for anyone who might possibly not know):

  1. From Xcode's Window menu select Projects.
  2. Make sure the project highlighted on the left is your project (or click on your project to make it so)
  3. Click on the Delete... button next to "Derived Data".
Howard Cohen
  • 135
  • 1
  • 6
  • In line with apple's usual approach to things they have changed this in xcode 8. To access Derived Data you can go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment. Then click over the little grey arrow under Derived data section and select your project folder to delete it. This is guaranteed to change as soon as xcode's developers realise that users are not being tortured enough. – amergin Jan 15 '17 at 19:08
0

I finally solved this.

I had a large project with lots of lines and some deprecated warnings due to me using things like UIAlertView which are no longer supported. It turns out it was the warnings that were causing the line jumps. Editor seems to run on a timer checking for new warnings at an insane rate like every 5 seconds, so every 5 seconds it would see if my code updated and if it did it would run through the whole thing again marking all of the yellow warning tags, which especially was erratic if the number of lines in my project changed since the warning windows would then have to shift down (or up). This would cause rendering issues and the line I was editing would shift up and down, very obnoxious.

Long story short I turned off the deprecated warnings by simply wrapping my .m in #pragma marks and it all went away (also editor became significantly less laggy (this was a 30k line of code .m file btw) very laggy to begin with).

Relevant: How to get rid of deprecated warnings in xCode with #Pragma CLANG

Community
  • 1
  • 1
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195