Issue with third party dependencies inside a XCFramework through SwiftPM

Hi @brunobasas,
I'm running into almost same issue (just with AppAuth rather than Facebook dependency) - have you been able to find a solution?

Actually, for your case (defining dependency for the binary target and getting it auto-pulled) there is an improvement/workaround in your Manifest file by making use of a regular source target as wrapper and define the binary target as dependency on it:

// swift-tools-version:5.3
import PackageDescription
let package = Package(
    name: "TestSDKFramework",
    platforms: [
        .iOS(.v13)
    ],
    products: [
        .library(
            name: "TestSDKFramework",
            targets: ["TestSDKFrameworkWrapper"])    // <--- reference the wrapper here
    ],
    dependencies: [
        .package(
            url: "https://github.com/facebook/facebook-ios-sdk",
            from: "8.1.0"
        )
    ],
    targets: [
        .target(
            name: "TestSDKFrameworkWrapper",         // <--- new wrapper
            dependencies: [
                .product(name: "Facebook", package: "Facebook")
                .target(name: "TestSDKFramework")    // <-- reference the actual binary target here
            ],
            path: "Sources/TestWrapper",
            publicHeadersPath: ""
        ),
        .binaryTarget(
            name: "TestSDKFramework",
            path: "TestSDKFramework.xcframework")
    ])

(the Sources/TestWrapper directory only needs to contain an empty .swift file, cmp. the Firebase implementation as mentioned here)

However, this will probably only save the step

We tried to add the Facebook dependency in the final client project

Still, for me the "No such module" remains :frowning:

The only way I could somehow get my framework and the final client app to build properly was to add the 3rd party dependency's XCFramework folder manually via drag'n'drop rather than SPM, which probably works as the Framework Search Path is then finding the dependency properly.
Interestingly, if you make an "import Facebook" in the client's app itself the SPM dependency is found, just not from within the .swiftinterface files :confused:

Any feedback/help from the other experts on this topic possible? I also tried to play around with explicitly adding linkerSetting: [ .linkedFramework("AppAuth") ], without success ...

2 Likes