error: multiple products named 'KituraNet' in: Kitura-NIO, Kitura-net
error: multiple targets named 'KituraNet' in: Kitura-NIO, Kitura-net
I could create separate branches, but then I lose the version selection capability that SwiftPM offers.
Does anyone else have any good suggestions? Has anyone seen a similar problem before?
Thanks
It's a hack, but if you go the environment variable route, the integrated manifest loader will inherit Xcode's environment, so something like KITURA_NIO=1 open Package.swift -a Xcode should select the appropriate dependency. It's not a very good solution, but I think it's the best one available today and is used by a few of the Swift repos.
In the long term, a better solution will likely involve some sort of mechanism for feature toggles that can be exposed to package clients.
owenv:
It's a hack, but if you go the environment variable route, the integrated manifest loader will inherit Xcode's environment, so something like KITURA_NIO=1 open Package.swift -a Xcode should select the appropriate dependency. It's not a very good solution, but I think it's the best one available today and is used by a few of the Swift repos.
One caveat to keep in mind for the hack, it only works if Xcode isn't running already.
I've used this same "set an environment variable" hack. The key to getting it to work with Xcode is launching Xcode from the space that had the environment variable set: so in effect, set an environment, then use open Package.swift or the open Package.swift -a Xcode commands to propagate that environment TO Xcode.
If you click on the app icon, that only picks up your default shell/environment background, which makes it a complete PITA to set and unset variables. That said, this "hack" mechanism has been pretty and effective stable for me - and I leverage the same setup when invoking Xcodebuild or swift build / swift test commands in CI to run and validate code.
I use the following snippet in Package.swift to set feature flags, and be able to easily override them in my editor:
let interposable = "FEATURE_INTERPOSABLE"
if hasFeature(interposable, override: nil) {
// do stuff
// Package API Extensions
func hasFeature(_ featureName: String, override: Bool?) -> Bool {
let key = "SWIFT_MMIO_\(featureName)"
let environment = ProcessInfo.processInfo.environment[key] != nil
return override ?? environment