Xcode 显示许多错误,但程序编译并运行良好(在模拟器和设备中) [英] Xcode shows many errors but program compiles and runs fine (in both simulator and device)

查看:41
本文介绍了Xcode 显示许多错误,但程序编译并运行良好(在模拟器和设备中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装 CocoaLumberjack 的日志压缩器类后,我遇到了这种烦人的行为:Xcode 抱怨有许多未声明的标识符并给我许多错误(不是警告,而是带有红色图标的错误).

After installing the CocoaLumberjack' log compressor class I've been getting this annoying behavior: Xcode complains that there are many undeclared identifiers and gives me many errors (not warnings but errors with the red icon).

问题是我可以很好地编译和运行我的 iPad 应用程序,但 Xcode 不会做任何自动完成.我尝试清理构建文件夹(Product > option + Clean),并删除派生数据.我也重启了也没用.

The thing is that I can compile and run my iPad app just fine but Xcode won't do any autocompletion. I tried cleaning the build folder (Product > option + Clean), and also deleting derived data. I've also rebooted to no avail.

正如您想象的那样,这是一种痛苦的工作.我之前在以前版本的 Xcode 上确实发生过这种行为;它与我预编译的头文件中的内容有关,但使用上面的解决方案总是可以解决它.我目前使用的是 Xcode 4.4 (4F250).

As you can imagine this is a pain to work with. I did have this behavior happen before on a previous version of Xcode; it had something to do with stuff in my precompiled headers file but using the solution above would always fix it. I'm currently using Xcode 4.4 (4F250).

我收到的示例错误:

语义错误:使用未声明的标识符DDTTYLogger"

即使是我自己编写的类也会发生上述情况,并且自从安装 CocoaLumberjack 压缩器类后没有改变.

The above happens even with classes that I wrote myself and that have not changed since installing the CocoaLumberjack compressor class.

推荐答案

经过多次尝试,我终于解决了这个问题:

I finally solved this after MANY attempts using the following:

从我的 Prefix.pch 中删除最后一个 #import 并重新构建.错误会发生(显然).将线放回并重新构建.不会显示任何错误,10 秒左右后,错误会再次出现.

Remove the last #import from my Prefix.pch and build again. Errors would happen (obviously). Put the line back and build again. No errors would show and after 10 seconds or so, errors would come back again.

重复上述操作,除了最后一个 #import,删除最后两个导入,然后是三个、四个等等.我这样做直到我删除了五个导入,当我把它们放回去等待时,Xcode 停止抱怨.

Repeat the above except instead of the last #import, remove the last TWO imports, then three, four, etc. I did this until I removed five imports and when I put them back and waited, Xcode stopped complaining.

请注意,我根本没有想到这一点.我在某处的博客上阅读了此解决方案.

Note that this didn't occur to me at all. I read this solution on a blog somewhere.

奇怪的错误...

这篇关于Xcode 显示许多错误,但程序编译并运行良好(在模拟器和设备中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆