0

Is it possible to add flags like the below to a Package.swift file?

#if DEBUG
  ...Code
#else

In particular, I'm trying to load one package for DEBUG and one packaged for RELEASE by placing each package inside the conditional compile block respective to their use case (which is just the nomenclature I'm using for CLIENT and SERVER given that I cannot figure how to create custom flags beyond DEBUG and RELEASE). The client uses SQLite and the server uses PostgreSQL. I've written a test library that maps to one file that is conditionally compiled to use the appropriate SQL, so really the only problem now is getting the Package.swift to conditionally compile too.

Ethan Kay
  • 657
  • 6
  • 24

1 Answers1

1

This is a less complete question versus: Swift package manager conditional compile not respecting flags but the short answer is no you cannot do this in your package manifest currently.

For your use case, the expectation would be that you simply define your client and server as parallel products in the package. For now, both will always be built, but in the future we anticipate having options to allow you to build parts of your package.

If you really want them to be built independently, you could build each as a separate package on top of a separate package where you place all your shared functionality.

Community
  • 1
  • 1
Daniel Dunbar
  • 3,465
  • 1
  • 21
  • 13