Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax color very slow to appear with xcode 6.3.1

Tags:

xcode

xcode6

Since few days (since the last version of xcode?), I noticed that the syntax color takes sometimes a while to appear and sometimes doesn't even appear, then I need to "reload" the file by clicking on another file and going back to the current one.

I tried to solve it by deleting the derived data but it didn't solve my problem. It is quite annoying as it seems I cannot click on a method (and go to its definition) if the syntax color is not ready.

Any idea?

like image 677
Nico Avatar asked May 05 '15 03:05

Nico


1 Answers

So briefly, my problem was about some lines of code that had a hard time to compile and was taking the whole compilation process ages. It was linked to my problem probably because Xcode quickly compiles the file you're working on before enabling any inner link/color for the code.

So if your compilation takes a while here is how you can quickly find out what's the problem (if it is related to some of your lines of code)

So I found some help on some website to find out what it was but I can't give you the links as I don't remember them. So here is how I proceed.

First when you compile, go on the Report Navigator on your left and select the Build being built. Then in your main tab, try to look for the file that takes a while to compile (it is the one that should stay with the arrow longer than the other ones). Once you found it, select the line of the file and on the very right side, there is a button that will expand a tab showing the command to compile your file with Terminal.

Copy the part starting with /Applications/Xcode.app/Contents/Developer/Toolchains to the end (name_of_your_file.o) and paste it in the Terminal.

If you execute it, it should take more than just 3-4 seconds. Then when you execute it, you have to press Ctrl(^) + \, you will send a quit signal and it will cause the process to terminate and dump core, showing you the line and the code it was compiling so most probably the part that was taking a long time.

In my case, one of the problematic lines was

maximumValue = CGFloat(abs(high + (15/100) * (high - low)))

I replace it by

let maximumValue = abs(high + (15/100) * (high - low))
maximumValue = CGFloat(maximumValue)

and it solved my problem. Why this piece of code was causing problem is another question...

like image 86
Nico Avatar answered Oct 20 '22 15:10

Nico