I have a Package.swift file with the following structure
var package = Package(
  name: "MyProject",
  targets: [
    Target(name: "MyProject")
  ],
  dependencies: [],
  exclude: ["Exclude"]
)
#if DEBUG
  package.dependencies.append(Package.Dependency.Package(url: "Dependency-One.git", majorVersion: 0, minor: 0))
#else
  package.dependencies.append(Package.Dependency.Package(url: "Dependency-Two.git", majorVersion: 0, minor: 0))
#endif
When I build this with any of the following:
swift build
swift build -c release
swift build -c debug
swift build -c RELEASE
swift build -c DEBUG
It still always downloads Dependency-Two.git. This remains true if I prepend all of the above with
rm -rf .build/ && rm -rf Packages/
So I don't think it's because it's reusing some cache. Is it possible to do what I'm intending here?
Still not available. My workaround has been to create multiple Package.swift files, named like Package-DEBUG.swift and have a script copy the appropriate one to Package.swift at build time.
This is a really mindless workaround and the SPM developers really need to implement command-line flags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With