Xcode - 找不到文件但构建成功
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5574291/
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 - File not found but build successful
提问by Oliver
In my project, I've include a full "shared" folder by link (not copy) that is outside my project folder.
在我的项目中,我通过链接(不是复制)在我的项目文件夹之外包含了一个完整的“共享”文件夹。
In the .pch file, I have #import "MyStandardHeader.h"
在 .pch 文件中,我有 #import "MyStandardHeader.h"
My Build settings does not have any search path to the "shared" folder.
我的构建设置没有“共享”文件夹的任何搜索路径。
In the "MyStandardHeader.h", I have #import "NSMutableArrayCustom.h"
that is inside a subfolder of "shared".
在“MyStandardHeader.h”中,我将#import "NSMutableArrayCustom.h"
它放在“共享”子文件夹中。
I use in my code a NSMutableArrayCustom class.
我在我的代码中使用了一个 NSMutableArrayCustom 类。
I never include NSMutableArrayCustom.h
我从不包括 NSMutableArrayCustom.h
I've clean the project, quitted XCode, launched it again, build, run on both iPhone and simulator : everything works fine, but I have a red compile error: MyStandardHeader.h - No such file or directory
我清理了项目,退出了 XCode,再次启动,构建,在 iPhone 和模拟器上运行:一切正常,但我有一个红色的编译错误: MyStandardHeader.h - No such file or directory
I've tried in the build settings Always search user path
at YES and NO, it's the same.
我已经在构建设置Always search user path
中尝试过YES 和 NO,它是一样的。
What is the problem? Why do I have this error? How make it disappear?
问题是什么?为什么我有这个错误?怎么让它消失?
回答by patrick-fitzgerald
I tried the steps mentioned above, but to fix the error I had to remove the file from "Copy Bundle Resources" in the project "Build Phases".
我尝试了上面提到的步骤,但为了修复错误,我必须从“构建阶段”项目中的“复制捆绑资源”中删除文件。
回答by amattn
I've seen this too: files that clearly exist get wonky. Oddly, sometimes it fixes itself. It may be an Xcode bug, since the build always succeeds. I've had success with touching the file. sometimes a clean helps. and sometimes quitting xcode helps.... Voodoo really.
我也见过这个:明显存在的文件变得不稳定。奇怪的是,有时它会自行修复。这可能是一个 Xcode 错误,因为构建总是成功的。我已经成功地触摸了文件。有时清洁会有所帮助。有时退出 xcode 会有所帮助.... Voodoo 真的。
You could try to remove the index by deleting everything in ~/Library/Developer/Xcode/DerivedData
您可以尝试通过删除所有内容来删除索引 ~/Library/Developer/Xcode/DerivedData
That directory is a combined version of the old Build and Intermediates directories from Xcode 1,2 and 3. Basically it's all the temporary and generated files from your project: object files, indexes, etc.
该目录是 Xcode 1,2 和 3 中旧 Build 和 Intermediates 目录的组合版本。基本上它是项目中的所有临时文件和生成文件:目标文件、索引等。
回答by TomSwift
Another thing to try -- just deleting Derived Data wasn't working for me, but this did:
另一件要尝试的事情——只是删除派生数据对我不起作用,但这样做了:
Delete Derived Data using the Organizer window, Projects tab.
In your target settings delete the value (path) set for "Prefix Header"
Close XCode and restart. Reload your project. Let it re-index.
Restore the "Prefix Header" setting.
使用管理器窗口的项目选项卡删除派生数据。
在您的目标设置中删除为“前缀标题”设置的值(路径)
关闭 XCode 并重新启动。重新加载您的项目。让它重新索引。
恢复“前缀标题”设置。
What a major PITA.
多么重要的 PITA。
回答by neelamc23
If deleting data and Prefix Header path doesn't work then, try to click on the File (that is not found) in the Project Navigator and uncheck the target under Target Membership in File Inspector. Then deleted the files from Project Project Navigator and add again. This is the only thing that worked for me.
如果删除数据和前缀标题路径不起作用,请尝试单击项目导航器中的文件(未找到)并取消选中文件检查器中目标成员资格下的目标。然后从 Project Project Navigator 中删除文件并重新添加。这是唯一对我有用的东西。
回答by weezma2004
Merely closing XCode (6.4) fixed my particular case of this issue. I opened it back up, cleaned the project, and built. Warnings were gone! Before I closed XCode, I cleaned and built and the warnings would not leave. So something about closing XCode did it. Hope this helps others!
仅仅关闭 XCode (6.4) 就解决了我在这个问题上的特殊情况。我重新打开它,清理项目,然后构建。警告消失了!在我关闭 XCode 之前,我进行了清理和构建,警告不会消失。所以关于关闭 XCode 的事情做到了。希望这对其他人有帮助!
回答by Chuck Krutsinger
I deleted the #import, then moved to a different line and used autocomplete to reenter the import. That error and all others like it disappeared. Strange bug.
我删除了#import,然后移到另一行并使用自动完成重新输入导入。那个错误和所有其他类似的错误都消失了。奇怪的错误。