Xcode / coding code color code not working

EDIT: This is strange ... if I double-click the "Recent Projects" element for a project on the welcome screen, the meaning of the code and coloring will be fine, but if I just click Open (lower right on the welcome screen) it is not. Opening from File > Recent projects does not work either, and it does not double-click on the .xcodeproj file in Finder.




The meaning of the code for the iPhone OS 3.0 project, which I have been working on for several months (through various installations / versions of Xcode), no longer works. For example, if I do NSString *myString , all the code will be black (no coloring, no option + double click, no code completion). Code Sense only "works" for my own classes / methods / properties, but not for any of the SDK classes. If I create a new project from scratch, all of these works for me.

I have already tried changing the “Base SDK for all configurations” in this project. I already tried "Recover Code Meaning Index". I have already tried Clear All Goals.

The documentation in the settings is up and running. For example, if I select NSString above and do Right-Click → Find text in the documentation, I get a window with all the class reference.

Any ideas are welcome.

+67
xcode syntax-highlighting
Oct 26 '09 at 20:05
source share
23 answers

Get project information in Xcode and change the project format to match the version of Xcode used (starting with this entry, "Xcode 3.2-compatible").

You can also delete derived data, but if you have not updated your project format, the error will reappear almost immediately. (This can happen even after updating the format of your project, but I sometimes had to remove DerivedData several times a day, and I think that I did this only once since the project was created.)

As noted in other sections, help with LLVM can help. But when updating this answer (2012), you should still use LLVM.

+9
Dec 08 '09 at 20:59
source share

In Xcode 4, I also could not find the Change Code button, but if you go to Window → Organizer, select the Project tab and click on Delete ... next to Derived Data, it seems to have the same effect. (I got this advice from http://blog.slidetorock.com/xcode-4-code-sense-autocompletion-problems , which indicates that it received it in turn from https://stackoverflow.com/a/11569/ .. . - but I do not see it in any of the answers. Very curious.)

+203
May 11 '11 at 1:42
source share

Just run the terminal every time you need it

 rm -fR ~/Library/Developer/Xcode/DerivedData 

It works great. Underscore and codeword back to me! Make Clean is sometimes required to support work.

note: as I see it removes snapshost and other Xcode4 features. But we do not use it :)

+35
Apr 24 '12 at 9:50
source share

Syntax coloring works after completing the following steps:

  • Go to "Organizer"> "Project"> "Delete Derived Data" from your current project
  • Cleaning and assembly
  • Close and exit Xcode and reopen the project
  • Syntax coloring gets good after redefining a project

PS

  • LLVM Complier 3.0
  • I used -fno-objc-arc Complier Flags for all third-party libraries (e.g. ASIHTTPRequest)
  • My project is created from Xcode 4.2
+34
Oct 06 '11 at 12:52
source share

I had the same problem in Xcode 4 and it was solved by changing the compiler from GCC 4.2 to LLVM GCC 4.2.

+12
Feb 23 '11 at 5:22
source share

I found a way to avoid this error. I saw that an error appears every time I modify a file that is imported into prefix.pch.

Try importing your own file at the top of the imported list above UIKit.h and Fonudation.h and NOT at the end, as everyone does.

In my prefix.pch file:

 #ifdef __OBJC__ #import "myFile.h" #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #endif 
+10
May 24 '12 at 8:13
source share

I also had this problem. I used to turn off indexing to speed up xcode operations and did not understand when it would stop part of the code allocation. If you have done this, you can enable indexing again by typing this into the terminal:

 defaults write com.apple.dt.XCode IDEIndexDisable 0 

if you want to disable indexing, enter this in the terminal:

 defaults write com.apple.dt.XCode IDEIndexDisable 1 
+4
Aug 30 '13 at 18:46
source share

Had the same problems in Xcode 4.0.2. The meaning of the code was each, except for two files, one .m file and the corresponding .h file. I tried everything - except restoring the code index, because I could not find the button anywhere - nothing worked. In the end, I deleted the correlated files, .m, .h and .xib. New files created, now everything works as expected.

+3
Apr 26 2018-11-21T00:
source share

There seem to be many suggested causes and solutions to this problem, and I think I tried most of them. What ultimately worked for me (in Xcode 4.1) was the following:

  • remove links to problem files in the project navigator
  • move problem files from the project folder to Finder
  • in the project navigator, right-click and select Add Files To ...
  • find the files that I just moved and add them back to the project, making sure that “Copy items to destination group folder (if necessary)” is selected.

Sense of code restored.

To be more specific, my specific problem is that when I create a new class by right-clicking in the project navigator, about 30-40% of the code time will not work in the new class header file. Interestingly, it really works in implementation.

Things I tried that failed:

  • deleting a folder with derivative data in the organizer
  • delete derived data folder in Finder
  • Creating a whole new class from scratch (why it didn't work, I have no idea.)
  • change syntax coloring language
  • change the compiler several times to and from all parameters
  • specifying a specific header search path

I would like other possible suggestions to put an end to this problem because it is really annoying!

+3
Oct 02 2018-11-11T00:
source share

In addition to tewha, I had to click the "Restore Code Index" button. It is located at the bottom of the General tab in the Get Project Information section.

+2
Aug 28 '10 at 10:03
source share

If you notice that this only happens in some of your files, make sure that the .m file is a member of your target.

+2
Sep 05
source share

Syntax coloring, automatic completion, transition to header files, etc. completely overwhelmed for me with Xcode4. The appearance of my character navigator is completely empty. I didn’t understand how dependent I became on completion, my productivity decreased by a factor. It is strange that my teammates see various combinations of missing functionality - only I was lucky to lose everything. FWIW I am on the latest Gen MBP.

+1
Mar 24 2018-11-21T00:
source share

I had this problem on only one of my .m files, and after you tried a lot of the things above, it turned out that Xcode at some point removed the .m extension. It was still included in the project navigator as “Myclass.m”, but right-clicking and selecting “Show in search” showed that the file was simply called “Myclass” (and was strangely placed in a subfolder of en.lproj!).

Removing the link from the project navigator, renaming and moving the file and re-adding it to the project fixed my problem.

+1
Mar 08 2018-12-12T00:
source share

Find 'GCC_INCREASE_PRECOMPILED_HEADER_SHARING' in the build settings and change it to YES. - It worked for me!

enter image description here

+1
Sep 05 '13 at 11:07 on
source share

What worked for me was to change the compiler to "LLVM Compiler 2.0".

0
Jul 06 2018-11-11T00:
source share

The meaning of the code for most files worked, with the exception of 3 or 4.m / .h files. I tried all the above and the only thing that worked for me was drct's solution. I closed xCode, moved the project to another folder and reopened.

Now I'm in if I right-click on a folder (or group) in the Project Navigator and select "New File". Code Meaning does not work.

If instead I use the main menu and select "File → New → New File", the code works fine.

0
Sep 15 '11 at 10:11
source share

One thing I came across today that influenced the color of the code is that I accidentally added a header (.h) file to Target -> Build Phases -> Compile Sources. After deleting, the color of the code magically returned :)

0
Jan 11 2018-12-12T00:
source share

I had the same problem, but none of the above worked for me, in the end I had to open xcode, go to

 File>Open Recent> Clear Menu 

This fixed the problem for me, it seems that when I imported the github project, which screwed up my code sense after clearing Recents, and then reopened the project, everything worked fine.

0
Jan 30 '12 at 11:37
source share

Sometimes adding multi-line comments at the end of the @end statement in your code prevents it from ending automatically in Xcode 6.0.1. I had the same problem. Just check it out.

0
Jan 03 '15 at 9:00
source share

Why am I happy again :)

I had this problem, but before I turned off the Xcode indexing process.

Allowed it by placing this command in the terminal. Hope this helps someone.

 defaults write com.apple.dt.XCode IDEIndexDisable 0 

And yes, I am using Xcode 7.0

0
Oct. 15 '15 at 7:18
source share

In my case, this problem has only one .m file. Autocomplete pops up well, but it doesn't display everything. For example, when I type "NS", then autocomplete pops up only with "NSMutableDictionary", and nothing else! I tried everything, searched everywhere for 1 hour +, but didn’t fix anything.

Then, out of curiosity, I deleted the comment block that I inserted earlier at the end of the .m file (below the word @end). After removal, this autocomplete works again as usual!

Here is the culprit: enter image description here

So, if your autocomplete doesn't work in just one file, you might want to check this out and delete everything below @end word.

0
Feb 11 '16 at 11:54 on
source share

Try closing and opening the XCODE IDE.

0
Mar 13 '16 at 11:33
source share

For someone else, I don’t know why. Open with Xcode 8.2 for me. It seems the newest Xcode got this problem

-one
Jun 06 '17 at 4:29
source share



All Articles