0

I have my bridging header file where I added new objective c file:

#import "MyFile.h"

Then I hit run and project is not building. I got errors like:

Cannot find interface declaration

Expected type

Cannot find protocol declaration

failed to emit precompiled header '/Users/user/Library/Developer/Xcode/DerivedData....

And others. Xcode tells that errors randomly. I cleaned project and got different other errors. Then, I remove MyFile from bridging header file. And now project is building correctly without any errors. Why? How to solve it?

neo
  • 1,314
  • 2
  • 14
  • 34
  • 1
    For a starter, it should be `#import "MyFile.h"` (with double quotation marks). – Martin R Sep 24 '20 at 09:27
  • Edited question. Sorry. It is not a problem – neo Sep 24 '20 at 09:29
  • 3
    I love it when people don't post their real code :( – My next guess: You have some circular import. Does "MyFile.h" import the generated Swift header ("YourProject-Swift.h")? – Martin R Sep 24 '20 at 09:31
  • 1
    is Objective-C Bridging Header path in Build Settings correct? – Vadim Nikolaev Sep 24 '20 at 09:32
  • 2
    Check this: https://stackoverflow.com/questions/25670431/how-to-prevent-circular-reference-when-swift-bridging-header-imports-a-file-that. – Martin R Sep 24 '20 at 09:33
  • @MartinR Yes, it is pretty sad when people don't post code. But, I think it is not needed here. Yes, MyFile.h has #import "MyProject-Swift.h". It seems problem. – neo Sep 24 '20 at 09:36
  • You should import "MyProject-Swift.h" in the implementation file "MyFile.m" only. If that is not possible (and if the other Q&A does not answer your question) then we need a [mcve]. – Martin R Sep 24 '20 at 09:44

0 Answers0