I have a project that uses a dozen of local Swift packages and I am trying to find a way of passing some compilation flags when building those packages from Xcode. Unfortunately, setting SWIFT_ACTIVE_COMPILATION_CONDITIONS has no effect when compiling packages.
It is possible, of course, to do that in the swiftSettings target argument in a manifest file or directly using swift build -Xswiftc, but I need to set the flags based on different build configurations.
Is there a way of configuring the xcodebuild tool the way that the flags are passed to package compiler invocations?
It seems like it was done like this by design, and xcodebuild intentionally ignores setting active compilation conditions for custom build configurations when it comes to compiling packages (expectedly it works only for the predefined debug build configuration). I will probably have to resort to using environment variables to set the flags conditionally in the package manifest file for now.
Fortunately, with your own local packages, you have more freedom, so we decided to pull the build configuration-specific logic from the packages up to the application level, leaving the packages configuration-agnostic.
Thanks for getting back to me.
Yeah, I think that we will have to make the code in the package build settings agnostic and then inject the configuration at the runtime in code in the hosting code side.
Hey,
TLDR; we have dropped this path.
The bottom line is that any non swiftPM way of workaround that you find is not sustainable enough. Even, when you set the Jenkins CI env to have all the flags set per build type, then the problem starts with building the project locally. The swiftPM is disconnected from the main Xcode project.