Does anyone know of a way to use code from an optional subspec in the core subspec of a pod?
Example:
SometimesAvailableProtocol
#if canImport(SometimesAvailableProtocol)
var sometimesAvailableVar: SometimesAvailableProtocol
#endif
However, unfortunately canImport
only works with modules and we have noticed that if you use something like canImport(MyPod.SometimesAvailableProtocol)
it works or fails randomly.
For future reference, you can use:
optional_subspec.ios.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "$(inherited) -D MY_SUBSPEC" }
optional_subspec.tvos.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "$(inherited) -D MY_SUBSPEC" }
and then in the core just do #if MY_SUBSPEC