.testTarget wont build with xcframework as .binaryTarget

G'day folks!

Trying to create a distributable library using SPM.
I have 3 targets: library_ios(pure swift code), library_ios_objc(obj-c and c code) and library-Tests defined in Package.swift:

// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
        name: "library_ios",
        defaultLocalization: "en",
        platforms: [
        products: [
             .library(name: "library_ios", targets: ["library_ios"]),
        dependencies: [
            .package(url: "https://github.com/lukepistrol/SwiftLintPlugin", from: "0.2.2")
    targets: [
            name: "library_ios",
            dependencies: ["library_ios_objc"],
            resources: [.process("Resources")],
            plugins: [
                .plugin(name: "SwiftLint", package: "SwiftLintPlugin"),
            name: "library_ios_objc",
            dependencies: ["openssl"],
            publicHeadersPath: "Include"),
            name: "library-Tests",
            dependencies: ["library_ios"]
        .binaryTarget(name: "openssl", path: "./Frameworks/openssl.xcframework"),

The targets library_ios and library_ios_objc are building successfully.

But the testing target build fails, and gives me this error message:

ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: Undefined symbols:
  _initKeypairWithData, referenced from:  {{ ....here the compiler references place where i call a pure C funtion... }}

(Obviosuly CoreAudioTypes has nothing to do here, since i don't use this framework in my lib)

Xcframework contains ios-arm64, ios-arm64-simulator and macos-arm64 static frameworks (without modulemaps) generate by xcodebuild -create-xcframework.

Any idea why this happens?

1 Like

Okay, i found my issue. Maybe it will help someone else...

Basically i had two functions which similar names:
initWithKeypairData and initWithKeypairData:publicKeyOctets:

One was a pure C function, and the other was inside Obj-C class.

For some reason Xcode was not able to build testing Target, but other targets were building.
Changing the name of the pure C function did the trick.