How to make Swift Package Manager package for multiple platforms
There’s no way to have platform specific sources or targets today, so you’ll have to take a different approach. I would recommend wrapping all OS specific files in #if os and just having one target. For tests, you could do something similar, one test target, but conditional tests
Every files are in
Sources folder, so we can use platform and version checks. For example Omnia is a Swift Package Manager that supports iOS, tvOS, watchOS, macOS and Catalyst.
For macOS only code, need to check for AppKit and Catalyst
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
For SwiftUI feature, need to check for iOS 13 and macOS 10.15
13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)(iOS