Post

Replies

Boosts

Views

Activity

Swift Package that has `@objc` in Swift code can’t be used due to Objective-C module failure
When the Xcode target (such as Application) 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 In this example, the dependency is like this. Application Target (Test) → Dynamic Framework (TestFramework) → Swift Package (TestPackage) And error would be <module-includes>:2:9: note: in file included from <module-includes>:2: #import "Headers/TestFramework-Swift.h" 				^ /Users/niw/Library/Developer/Xcode/DerivedData/Test-gcmgljtjqifdtzbblkpxoahggxkj/Build/Products/Debug-iphonesimulator/TestFramework.framework/Headers/TestFramework-Swift.h:192:9: error: module 'TestPackage' not found @import TestPackage; 				^ <unknown>:0: error: could not build Objective-C module 'TestFramework' Is there any good solution to fix or workaround this? Technically I think for now, we can’t safely using @objc at all in Swift Package, and package user may see this error, which is unexpected by the package author for sure. I also reported this issue on Swift JIRA is at https://bugs.swift.org/browse/SR-13075
8
0
5.4k
Jun ’20