Xcode 8.3 autocomplete and syntax highlighting not working
I am very new to Xcode and Objective C, although I have been developing Unity / C # for a while now. I'm having a hard time trying to get autocomplete and syntax highlighting to work "correctly" in Xcode 8.3. For these last two days, I have searched all over the internet and tried all the recommended solutions and workarounds I found with no luck. So I decided to open a new question. Steps to reproduce my problem:
- In Xcode, create a new "Single View Application" project.
- Create a new class "TestClass".
- In TestClass.h, try entering NSAr ... Expected Result: Xcode should suggest NSArray (because the Foundation.h file was imported automatically). Actual result: no. no autocomplete
- Import UIKit.h into TestClass.h, and in TestClass.m try calling UIViewController methods. Expected Result: Xcode should offer the UIViewController as input and then highlight the class name. Actual result: it doesn't. no syntax highlighting
What I have tried:
- Delete the DerivedData folder.
- Restart Xcode / Computer (many times)
- Make sure the .m file is added to the target (in the Target Membership window).
- Add base structure explicitly in build phases> Link to binaries with libraries
- Set the Framework search paths in build preferences to the Frameworks folder
- Download iOS and Xcode documentation under Preferences> Components
- Install Xcode 7.3.1 and 7.0 to see no difference.
I'm probably missing something basic, but I think it's reasonable to expect such a feature to work out of the box, without too many problems?
Any help would be greatly appreciated!
UPDATE:
I've also tried:
- Add $ (SRCROOT) / to the title search path.
- Increase the log level: by default, write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3 and look for errors in the file not found in Console.app code (no such errors found).
Also the test app is very simple with a few lines of code and it works great. The only warning is the "unused variable" for the UIViewController * vc variable (second screenshot).
source to share
It turned out that the problem was caused by my own action (error).
A long time ago, when I had my first short interaction with Xcode, I deliberately tried to turn off its indexing , because on my Mac (which hadn't been updated by then) it's taking too long. So I did it by typing this in the terminal:
defaults write com.apple.dt.XCode IDEIndexDisable 1
And here it is. I completely forgot about it until I had to touch Xcode again and was confused by the autocomplete and syntax highlighting "doesn't work". There is no Xcode bug. All I had to do to get it working was to re-enable indexing by typing this in the terminal:
defaults delete com.apple.dt.Xcode IDEIndexDisable
I obviously created my own problem, but hopefully this information will be helpful to someone else.
Thanks everyone for your help.
source to share