Conditional linking to a binary target depending on the build type

I have 2 binaries for the same framework, one is built in debug mode, and one is built in release mode.

Now I want to link to those binaries from a local swift package conditionally.

  • When the app is built in Debug mode, the debug binary should be linked.
  • When the app is built in Release mode, the release binary should be linked.
// swift-tools-version:5.3

import PackageDescription

let package = Package(
    name: "MyLocalSPM",
    products: [
            name: "MyLocalSPM",
            targets: ["MyLocalSPM"]
    dependencies: [],
    targets: [
            name: "BinaryXCFramework",
            path: "./Libs/Release/BinaryXCFramework.xcframework" // <-- Here, I want to link to Debug/BinaryXCFramework.xcframework when the app is built in Debug configuration

            name: "MyLocalSPM",
            dependencies: [

Anyone knows how I can do that?


I want to do the same thing on my project.

any advance on this matter?