Open niw opened 4 years ago
This is also asked in https://developer.apple.com/forums/thread/650935 at WWDC20.
This is also filed as FB https://feedbackassistant.apple.com/feedback/7799213, https://feedbackassistant.apple.com/feedback/9039984 alongside as the original https://feedbackassistant.apple.com/feedback/7781285
Comment by Jonathan Gilbert (JIRA)
I think the reason is simply because the .framework built from the Swift Package will be missing a Headers directory. If I make an Xcode project from the same code as my Swift Package, but now I add a Copy Headers phase and add an umbrella header that imports ModuleName-Swift.h compatibility header, now the problem disappears. It seems like it would be easy to update SPM to add a Copy Headers phase for all Swift targets that have any @objc files.
Environment
- Xcode 11.5 (11E608c) - Xcode 12.0 beta (12A6159)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 6 | |Component/s | Package Manager | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: d0de46f3d4acb3486ea389af9cfdde7ais blocked by:
Issue Description:
When the Xcode target (such as Application) has a transitive dependency to the Swift Package, such as it is importing a dynamic framework that is importing Swift Package that has public
@objc
interface, such as a delegate protocol, we can’t build the target due to Objective-C module failure.Reproducible project is at https://github.com/niw/swift_package_objc_module_failure.
Error message you will see is like this.
In this example, the dependency is like this.
Since if the middle dynamic link library is using Swift package or not is unrelated to both the application target owner and package owner, all Swift packages that have
@objc
can have this issue.Therefore, currently basically
@objc
can't be use feely in Swift Package.A few observations:
This is caused by missing
-Xcc -module-map-file
forswift -frontend
for the transitive Swift package dependency used for the Swift files in the application target.This is not happening if the module that Swift Package provided is written in Objective-C.