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?

I am modularizing an iOS app and stumbled across the same use case.
Maybe I think in the wrong direction.
I can provide two binary library product xcframework s in SPM:

  • one in Debug configuration with debug symbols: "LibADebugBin.xcframework"
  • one in Release configuration without debug symbols; "LibABin.xcframework"

Then I have to conditinally link "LibADebugBin.xcframework" and "LibABin.xcframework" depending on the configuration in the XCode app project.

1 Like

Just wondering if this an idea or how you actually solved the issue..?

I'm not sure there's a way to do it in SPM. I've been searching for a way to achieve this even without SPM and embedding directly in the Xcode project, and couldn't find a solid way to do it.

@antranapp Are you able to achieve this without SPM?

My case is I have two xcframeworks once called ABC.xcframework and one called ABC-release.xcframework and I want to link them conditionally based on build configuration.