Swift umbrella from another target
I have a project with multiple goals. The main goal is to combine Swift and Objective-C classes and objc files that use Swift classes, including the ModuleName-Swift.h probe header. However, when I include the same source files in multiple targets, the umbrella header cannot be found other than the main target. The module name in the header import must be different for each target. How do you achieve this?
So far, I haven't found any other way other than to set the same product module name for all targets. This has no side effects.
source to share
I have the same problem while writing a Today Extension for my application. I have a file named for example Items.swift located in the Today Extension component and included in this target. Therefore, I have the following situation: the main project is completely written in Objective-C and today the extension is written in Swift
I want to include Items.swift file in my main project and use it
- Make sure to be
included in the main target of the application.
- Important ( !!! ), you must create
and add a link to this file in the project file (Objective-C Bridging Header) even if your main target contains only Objective-C code
must inherit from NSObject or its descendants
- Then add
to place where you want. to use
and click "Build"
Finally you can go to
and make sure the interface is generated than you can use the Objective-C version of your class
ProductModuleName which you can see in build settings -> Packaging -> Product module name
source to share