Any practice about Swift Package Manager, to write a Objc/Swift mixed framework which don't force user to use different module name?

I want to create the same integration just like you import UIKit.

If you're Objective-C user, you only use Objective-C API.

If you're Swift user, you use some auto Objective-C exported API as well as libSwiftUIKit.dylib pure Swift overlay API. You don't need import SwiftUIKit

However, SwiftPM doesn't allow one Target (Module? Is one target must match one module ?) "contains mixed language source files; feature not supported". This error will prevent you do this thing as raw Xcode Target orgnization.

Note Xcode, Pods/Carthage supports this.

2 Likes

Also post the question on twitter, but seems there are no better solution. I have to either blame my Objc user or blame Swift user.

Getting this error: contains mixed language source files; feature not supported

Any plans to add the mixed objective-c and Swift files in the Swift package manager target?

I'm encountering the same error. Does this mean I can't create a Package, if I need it to contain a bridging header?

Swift Package Manager currently doesn't support mixed language targets, but that should change soon.

Meanwhile you can use @_exported to import your Swift and Objective-C modules with a single command. Just be aware that @_exported is an experimental feature and its use in production software is not recommended.

The current problem I'm having is that if I put both my bridge.swift file and C code in the same directory in the package, I get the above error. If I remove the bridge.swift file, swift-build doesn't give that error, but a function that is in the bridge.swift file is missing and that causes an error. I'm wondering, how do people create packages that include both C and Swift code and a bridge between them?