I have an existing Objective-C iOS project and I want to add swift files to it. The project has 2 targets.
I created the bridging header MyProject-Bridging-Header.h file and the automatically created bridging header MyProject-Swift.h is generated by Xcode as expected. But only for target "A".
Target "B" doesn't see the MyProject-Swift.h file. The reason is, that the target doesn't have the 'swift compiler code generation' that is responsible for the automatic generation of this file.
I tried to set the file on in the project level - I expected I would be inherited to the targets. But this doesn't work.
How do I get he 'swift compiler code generation' into the existing targets build settings manually?
I found out by accident how to do it: create a new swift file and include all necessary targets (Xcode asks at the end of the file setup). Then Xcode asked me if I wanted the Bridging Header to be created and - much more important - added the Swift section to the target
For any new users the setting you are looking for is under "swift compiler - general"
Just scroll down from swift compiler - code generation. Also make sure you select "all" and not "basic" (at the top) basic hides some features.
Building was an important step for me. Adding the Swift file to the target of interest, creating the bridging header, and building the project with these files included. It's not enough to just add it, then delete them and expect Xcode to update the project build settings for you.
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