简体   繁体   English

C ++中的Xcode 8.3.3错误语法突出显示

[英]Xcode 8.3.3 Bad Syntax Highlighting in C++

I've noticed some rather peculiar syntax highlighting inconsistencies. 我注意到一些语法异常突出的地方。 The class , if , else , while and break keywords are not colorized for some reason. 由于某种原因, classifelsewhilebreak关键字未着色。 This problem persists even after changing color themes and restarting Xcode. 即使更改颜色主题并重新启动Xcode,此问题仍然存在。 I am using the Civic theme which is one of the defaults in Xcode. 我正在使用Civic主题,它是Xcode中的默认主题之一。 The problem seems to be language-specific since this only happens for C++ while it doesn't for objective-c or Python. 这个问题似乎是特定于语言的,因为这仅在C ++中发生,而在Objective-C或Python中则没有。

在此处输入图片说明

I've found a solution which is far from ideal and from the looks of it, it seems to be an Xcode bug. 我发现了一个不理想的解决方案,从外观上看,它似乎是一个Xcode错误。

  1. Open the Preferences window 打开“ Preferences窗口
  2. Go to the Locations tab 转到Locations标签
  3. Click on the arrow next to /Users/Library/Developer/Xcode/DerivedData 单击/Users/Library/Developer/Xcode/DerivedData旁边的箭头
  4. Go to User Data 转到User Data
  5. Go to FontAndColorThemes 转到FontAndColorThemes
  6. Open any .xccolortheme file with Xcode 使用Xcode打开任何.xccolortheme文件

     <key>xcode.syntax.identifier.class</key> <string>0.115602 0.660894 0.635056 1</string> <key>xcode.syntax.identifier.class.system</key> <string>0.221291 0.537118 0.556094 1</string> # change this line <key>xcode.syntax.identifier.function</key> <string>0.115602 0.660894 0.635056 1</string> <key>xcode.syntax.identifier.function.system</key> <string>0.221291 0.537118 0.556094 1</string> 

The color code for the xcode.syntax.identifier.class.system was not equivalent to that of xcode.syntax.identifier.function.system which caused the class keyword to not be colorized. 为颜色代码xcode.syntax.identifier.class.system并不等同于的xcode.syntax.identifier.function.system这引起了class关键字不被着色。 So the solution is to make them the same. 因此解决方案是使它们相同。 Do the same for all the other keywords. 对所有其他关键字执行相同的操作。

For a reason which I cannot understand, changing that line for a single color theme automatically fixes this bug for all color themes. 由于我无法理解的原因,更改单个颜色主题的行会自动修复所有颜色主题的错误。 Also, I've yet to figure out why this bug was language-specific for C++. 另外,我还没有弄清楚为什么此错误是C ++语言特定的。 Nevertheless, the solution works. 尽管如此,该解决方案仍然有效。

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

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