I'm working in an Objective-C project and trying to introduce Swift. I've got bridging headers working so that the code compiles, however none of the Objective-C classes are being picked up by autocomplete.
I've tried:
However, these suggestions didn't work for me.
Autocomplete works fine for UIKit, etc., and for my other Swift code. It's only the Objective-C code exposed by the bridging header that will not autocomplete.
Any suggestions?
I think I figured this one out:
Our project has multiple targets, and most of the files belong to multiple targets. If you want autocompletion, the header you are importing has to be imported in the bridging header for every target the file belongs to.
When I imported the header I wanted in each bridging header, autocompletion started working as expected.
Update: Seems like you can consolidate down to one bridging header if that setup works for your project. That would prevent you having to update multiple headers every time you wanted to add an import.
Thanks to joel.d answer, I've fixed the same problem in my project.
In bridging-header I had line:
#import "BTData.h"
Please note that it was some sdk from cocoa pod, and recently we have updated all pods, so probably thats when autocompletion problems has started. Replacing above line with this one below fixed the issue and now all obj-c classes are autocompleting in swift files.
#import <Braintree/BTData.h>
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