3

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).

pt5011
  • 51
  • 1
  • 7
  • what is the subclass for that Testclass – NAVEEN KUMAR Apr 04 '17 at 04:50
  • 1
    Try Below Links: http://stackoverflow.com/a/2264010/5929147 http://stackoverflow.com/a/7676487/5929147 http://stackoverflow.com/a/10245076/5929147 http://stackoverflow.com/questions/39598543/xcode-8-syntax-highlighting-doesnt-work?noredirect=1&lq=1 – bala Apr 04 '17 at 06:21
  • @NAVEENKUMAR TestClass is a subclass of NSObject as in the screenshot and has no subclass of its own. – pt5011 Apr 04 '17 at 06:50
  • @bala Thanks for links. I believe I came across all of them in my previous searches. Anyway I went through them once again and performed the recommended fixes (add $(SRCROOT)/ to header search path, increase log level and look for errors in Console.app, etc.) without luck. Also this is just a test app with a few lines of code and it builds fine. – pt5011 Apr 04 '17 at 06:55
  • If the problem still there, please check my answer at http://stackoverflow.com/questions/9784175/issue-with-code-autocompletion-syntax-highlighting-in-xcode-4-x/43975833#43975833 – Sauvik Dolui May 15 '17 at 09:29

1 Answers1

2

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.

pt5011
  • 51
  • 1
  • 7