I have a project written mostly in objective-c. Adding a swift file that is a UIViewController that uses some other of our custom classes. I have these all listed in the bridging file.
When I run it in the emulator, everything is ok. But when I go to open the swift file in the editor, it then complains about undeclared types, as if I didn't add them in the bridging file. If I run in the simulator, those errors go away, and they stay away until I edit this swift file again.
Is there something I do not understand about the timing of the bridging header? Is this just an annoying bug in Xcode or am I doing something wrong?
It appears like this is one of the many Xcode's bugs related to swift. I would recommend you to do following steps:
check if your bridging header is set correctly: go to project -> Build settings -> find "Objective-C Bridging Header" line under "Swift Compiler - Code Generation". The path to your bridging header should be written there.
check if there are no errors in your bridging file (unlikely but still).
all your imports should be written in form like:
#import "MyFile.h"
or
#import <MyLib/MyFile.h>
go to window -> organizer -> select "Projects" in the top pane -> select your project in the left pane -> click on "Delete" next to the "Derived Data" label
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With