Existing target has no 'swift compiler code generation' section
Asked Answered
T

3

8

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?

Tetratomic answered 21/4, 2016 at 13:13 Comment(0)
T
13

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

Tetratomic answered 22/4, 2016 at 9:35 Comment(1)
Helpful! Note that, for this to work, you must first deselect the target for any existing Swift files.Ratfink
I
12

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.

Irony answered 7/4, 2017 at 5:22 Comment(0)
B
3

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.

Bosch answered 19/7, 2019 at 2:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.