Current project build configuration in SPM package's package.swift

168 views Asked by At

I am building an SPM package repository to distribute my XCFrameworks (built using Flutter CLI), and I want to conditionally set the paths for these binary targets based on the build configuration (Debug or Release). I've tried using conditional compilation with #if DEBUG and #else, and I've set the -DDEBUG flag in my Xcode project's build settings for the Debug configuration, but it is seems like the DEBUG variable is not accessible in the package's package.swift file. Here is some code for reference.

import PackageDescription

let package = Package(
    name: "flutter_module_ios",
    products: [
        .library(
            name: "flutter_module_ios",
            targets: ["App", "Flutter"])
    ],
    targets: [
        .binaryTarget(
            name: "App",
            path: {
                #if DEBUG
                return "Debug/App.xcframework"
                #else
                return "Release/App.xcframework"
                #endif
            }()
        ),
        .binaryTarget(
            name: "Flutter",
            path: {
                #if DEBUG
                return "Debug/Flutter.xcframework"
                #else
                return "Release/Flutter.xcframework"
                #endif
            }()
        )
    ]
)

Is there a step I might be missing, or is there an alternative approach I should consider to achieve this conditional path setting for binary targets in Swift Package Manager?

Any help or insights would be greatly appreciated!

0

There are 0 answers