Xcode - File not found but build successful

2019-03-09 23:38发布

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"

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".

I use in my code a NSMutableArrayCustom class.

I never include 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

I've tried in the build settings Always search user pathat YES and NO, it's the same.

What is the problem? Why do I have this error? How make it disappear?

6条回答
老娘就宠你
2楼-- · 2019-03-10 00:05

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".

查看更多
在下西门庆
3楼-- · 2019-03-10 00:08

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.

What a major PITA.

查看更多
Bombasti
4楼-- · 2019-03-10 00:13

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!

查看更多
我想做一个坏孩纸
5楼-- · 2019-03-10 00:18

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.

You could try to remove the index by deleting everything in ~/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.

查看更多
欢心
6楼-- · 2019-03-10 00:24

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.

查看更多
可以哭但决不认输i
7楼-- · 2019-03-10 00:25

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.

查看更多
登录 后发表回答