We have a custom Capacitor plugin being used by our Capacitor mobile app on the iOS platform. The custom plugin requires a 3rd-party package that is distributed to us in the form of a “.xcframework” package. We have been building this plugin successfully in Capacitor 7, but now that we’ve upgraded to Capacitor 8, it cannot resolve the 3rd-party package.
I see that all plugins generated with “create-plugin” do have a file called Package.swift that is automatically generated. XCode documentation suggests that you can add a “.binaryTarget” to the Package.swift file to link against a 3rd-party library. Of course I’ve added such a line to the Package.swift file, but it does not work. The line of Swift code “import ThirdPartyModuleName” produces an error “No such module ‘ThirdPartyModuleName’”, and the project will not build. Here is the Package.swift file (note the .binaryTarget entry referencing the 3rd-party library package):
import PackageDescription
let package = Package(
name: "ValmarcCortex",
platforms: [.iOS(.v15)],
products: [
.library(
name: "ValmarcCortex",
targets: ["CortexPlugin"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
],
targets: [
.target(
name: "CortexPlugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")
],
path: "ios/Sources/CortexPlugin"),
.binaryTarget(
name: "CortexDecoder",
path: "ios/CortexDecoder.xcframework"),
.testTarget(
name: "CortexPluginTests",
dependencies: ["CortexPlugin"],
path: "ios/Tests/CortexPluginTests")
]
)
Since the above Package.swift suggestion doesn’t work, my question is as follows: In Capacitor 8 with SWP, what is the recommended way to link against a 3rd-party “.xcframework” library with a custom capacitor plugin? The Capacitor documentation doesn’t really cover this case.
Thank you for any help you can offer.