从 Xcode 3 导入项目时,Xcode 4 代码会丢失语法着色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5365212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4 code loses syntax coloring when importing project from Xcode 3
提问by MartinMoizard
I have just upgraded to the new Xcode 4 and the code is not colored has it should be. I am trying to use a project that I created on Xcode 3.
我刚刚升级到新的 Xcode 4,代码没有着色,应该是。我正在尝试使用我在 Xcode 3 上创建的项目。
For instance, the string 'NSString' is not colored in my custom code, but when I switch to Apple's code (NSString.h for ex.) everything is well colored.
例如,字符串 'NSString' 在我的自定义代码中没有着色,但是当我切换到 Apple 的代码(例如 NSString.h)时,一切都很好着色。
How can I fix that?
我该如何解决?
Thanks a lot, Martin
非常感谢,马丁
回答by Rob Keniger
Open the Organizer (Window > Organizer
) and select the Projectsmode. Select your project in the left-hand view and then click the Delete…
button for the project's Derived Data.
打开管理器 ( Window > Organizer
) 并选择项目模式。在左侧视图中选择您的项目,然后单击Delete…
项目的派生数据按钮。
This will delete the code sense index for the project and force Xcode to rebuild the index, which should fix the problem.
这将删除项目的代码感知索引并强制 Xcode 重建索引,这应该可以解决问题。
回答by Fredrik
I got it to work by prefixing all my project search paths with "$(SOURCE_ROOT)/" instead of just using a project relative path. Eg "Include" becomes "$(SOURCE_ROOT)/Include".
我通过在所有项目搜索路径前加上“$(SOURCE_ROOT)/”而不是仅使用项目相对路径来使其工作。例如,“Include”变成“$(SOURCE_ROOT)/Include”。
Do this and then force a rebuild of the index by deleting the projects derived data from the organizer.
执行此操作,然后通过从管理器中删除项目派生数据来强制重建索引。
回答by Tyler White
After trying most, if not all, of the steps above, I have succeeded in restoring my colorful Xcode eye candy by finding and deleting (in Finder) all of the derived data created from my project (there were several folders for my project that were lingering even after deletion from the Window > Organizer menu).
在尝试了上述大多数步骤(如果不是全部)之后,我通过查找和删除(在 Finder 中)从我的项目创建的所有派生数据(我的项目有几个文件夹)成功地恢复了我多彩的 Xcode 眼睛糖果即使从“窗口”>“管理器”菜单中删除后仍然存在)。
My project's folders that needed deletion were located in ~Library/Developer/Xcode/DerivedData
我需要删除的项目文件夹位于 ~Library/Developer/Xcode/DerivedData
回答by Ameet Dhas
Also try this, select all(command + A) from your Prefix.pch file -> cut it(command + X) -> Build(command + B)(don't worry for error) -> paste(whatever you copy from Prefic.pch file in that file only)(commmand + V) -> Build again (command + B).
也试试这个,从你的 Prefix.pch 文件中选择 all(command + A) -> cut it(command + X) -> Build(command + B)(不要担心错误)-> paste(无论你从什么复制仅在该文件中的 Prefic.pch 文件)(命令 + V)-> 再次构建(命令 + B)。
回答by Jorge Vicente Mendoza
There is another cause for this issue, it had been happening to me with beta versions of Xcode, you need to check that the .m file is added to the target in order to make it add color to the classes and enable the autocompletion.
这个问题还有另一个原因,它发生在我的 Xcode 测试版中,您需要检查 .m 文件是否已添加到目标中,以使其为类添加颜色并启用自动完成。
You can check it out in the Xcode inspector
您可以在 Xcode 检查器中查看
Hope this helps,
希望这可以帮助,
best regards,
此致,
Jorge.
乔治。
回答by Sebastian
Try Product -> Clean and then Product -> Build
尝试产品 -> 清洁,然后产品 -> 构建
回答by Fabio
Remove the files from your project (just remove, don't delete them!) and re-import them.
从您的项目中删除文件(只需删除,不要删除它们!)并重新导入它们。
回答by Brian
Its possible that the permissions on the folder where Xcode stores the code-sense cache is broken. If the cache cannot be correctly written or read when you launch Xcode, it will behave as you describe.
Xcode 存储代码感知缓存的文件夹的权限可能已损坏。如果在您启动 Xcode 时无法正确写入或读取缓存,它将按照您的描述运行。
Try locating the folder (you can locate it in the organizer. Hit the arrow next to the path.) and reset its permissions in the Get Info dialog.
尝试找到文件夹(您可以在管理器中找到它。点击路径旁边的箭头。)并在“获取信息”对话框中重置其权限。