Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Existing target has no 'swift compiler code generation' section

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?

like image 692
brainray Avatar asked Apr 21 '16 13:04

brainray


3 Answers

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

like image 144
brainray Avatar answered Nov 02 '22 20:11

brainray


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.

like image 20
Remigius Kalimba Jr Avatar answered Nov 02 '22 22:11

Remigius Kalimba Jr


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.

like image 22
visc Avatar answered Nov 02 '22 21:11

visc