How mix Swift with C++ and pure C

I have this Package.swift

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

import PackageDescription

let package = Package(
    name: "swift",
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .executableTarget(
            name: "Src",
            dependencies: [
                "CLib", "CxxLib"
            ],
            swiftSettings: [.interoperabilityMode(.Cxx)]
        ),
        .target(
            name: "CLib"
        ),
        .target(
            name: "CxxLib"
        )
    ]
)

This gives link errors from CLib
If I move interoperabilityMode into CxxLib target, then this target not build

Suggest you do something like this

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

import PackageDescription

let package = Package(
    name: "swift",
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .executableTarget(
            name: "Src",
            dependencies: [
                "CLibShim", "CxxLib"
            ],
            swiftSettings: [.interoperabilityMode(.Cxx)]
        ),
        .target(
            name: "CLib"
        ),
        .target(
            name: "CxxLib"
        ), 
       .target(name: "CLibShim", 
         dependencies: ["CLib"], 
         swiftSettings: [.interoperabilityMode(.C)]
        )
        ]
)

Nothing one more layer of abstraction can't solve :wink: