简体   繁体   中英

Xcode 8.3 autocomplete and syntax highlighting not working

I'm very new to Xcode and Objective C, though I've been developing with Unity/C# for some time now. I'm having a hard time trying to get the autocompletion and syntax highlighting to work "properly" in Xcode 8.3. Over that last two days, I've been searching all over the internet and tried all the recommended solutions and workarounds that I found without any luck. So I decided to open a new question. Steps to reproduce my issue:

  • In Xcode create new "Single View Application" project.
  • Create a new class "TestClass".
  • In TestClass.h try typing NSAr... Expected result: Xcode should suggest NSArray (because the Foundation.h was imported automatically). Actual result: it doesn't. no autocompletion
  • Import UIKit.h to TestClass.h, and in TestClass.m try calling UIViewController methods. Expected result: Xcode should suggest UIViewController as typing, and then highlight the class name. Actual result: it does neither. no syntax highlighting

What I tried:

  • Delete the DerivedData folder.
  • Restart Xcode/computer (many times)
  • Make sure the .m file is added to the target (in Target Membership window)
  • Add the Foundation framework explicitly in Build Phases > Link Binary With Libraries
  • Set the Framework Search Paths in Build Settings to the Frameworks folder
  • Download the iOS and Xcode documentations in Preferences > Components
  • Install Xcode 7.3.1 and 7.0, to see no difference.

I'm probably missing something basic here, but I think it's reasonable to expect such feature to work out-of-the-box, without much hassle?

Any help would be much appreciated!

UPDATE:

I also tried:

  • Add $(SRCROOT)/ to Header Search Path.
  • Increase log level: defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3 and look for Xcode-specific "file not found" errors in the Console.app (no such errors found).

Also the test app is a very simple one with few lines of code and it builds fine. The only warning is the "unused variable" for the UIViewController *vc variable (2nd screenshot).

Turned out the issue was caused by my own action (mistake).

Long ago, when I had my first brief interaction with Xcode, I deliberately tried to disable its indexing , because it took too long on my Mac (which was not upgraded by that time). So I did that by typing this in the Terminal:

defaults write com.apple.dt.XCode IDEIndexDisable 1

And there it was. I totally forgot about this until I had to touch Xcode again recently, and was driven mad by the autocomplete and syntax highlighting "not working". There's no Xcode fault whatsoever. All I needed to do to make it work is enable indexing again, by typing this in the Terminal:

defaults delete com.apple.dt.Xcode IDEIndexDisable

I obviously created my own trouble, but hopefully this information will be helpful to someone else.

Thank everyone for your help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM