简体   繁体   English

Xcode 8.3自动完成和语法高亮不起作用

[英]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. 我是Xcode和Objective C的新手,虽然我已经用Unity / C#开发了一段时间了。 I'm having a hard time trying to get the autocompletion and syntax highlighting to work "properly" in Xcode 8.3. 我正在努力让自动完成和语法突出显示在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. 在Xcode中创建新的“单一视图应用程序”项目。
  • Create a new class "TestClass". 创建一个新类“TestClass”。
  • In TestClass.h try typing NSAr... Expected result: Xcode should suggest NSArray (because the Foundation.h was imported automatically). 在TestClass.h中尝试输入NSAr ...预期结果:Xcode应该建议NSArray(因为Foundation.h是自动导入的)。 Actual result: it doesn't. 实际结果:它没有。 no autocompletion 没有自动完成
  • Import UIKit.h to TestClass.h, and in TestClass.m try calling UIViewController methods. 将UIKit.h导入TestClass.h,并在TestClass.m中尝试调用UIViewController方法。 Expected result: Xcode should suggest UIViewController as typing, and then highlight the class name. 预期结果:Xcode应该建议输入UIViewController,然后突出显示类名。 Actual result: it does neither. 实际结果:它既没有。 no syntax highlighting 没有语法突出显示

What I tried: 我尝试了什么:

  • Delete the DerivedData folder. 删除DerivedData文件夹。
  • Restart Xcode/computer (many times) 重启Xcode /电脑(多次)
  • Make sure the .m file is added to the target (in Target Membership window) 确保将.m文件添加到目标(在“目标成员资格”窗口中)
  • Add the Foundation framework explicitly in Build Phases > Link Binary With Libraries 在Build Phases> Link Binary With Libraries中显式添加Foundation框架
  • Set the Framework Search Paths in Build Settings to the Frameworks folder 将Build Settings中的Framework Search Paths设置为Frameworks文件夹
  • Download the iOS and Xcode documentations in Preferences > Components 在Preferences> Components中下载iOS和Xcode文档
  • Install Xcode 7.3.1 and 7.0, to see no difference. 安装Xcode 7.3.1和7.0,看看没有区别。

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. 将$(SRCROOT)/添加到标题搜索路径。
  • 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). 增加日志级别:默认写入com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3并在Console.app中查找特定于Xcode的“找不到文件”错误(未找到此类错误)。

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). 唯一的警告是UIViewController * vc变量的“未使用的变量”(第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). 很久以前,当我第一次与Xcode进行简短的交互时,我故意试图禁用它的索引 ,因为我的Mac上花了太长时间(当时没有升级)。 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". 我完全忘了这个,直到最近我不得不再次触摸Xcode,并被自动完成和语法突出显示“不工作”而疯狂。 There's no Xcode fault whatsoever. 没有任何Xcode错误。 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. 感谢大家的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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