diff --git a/Package.swift b/Package.swift index feceb9d..1fc7d80 100644 --- a/Package.swift +++ b/Package.swift @@ -1,7 +1,10 @@ // swift-tools-version:5.5 import PackageDescription +import class Foundation.ProcessInfo -let libraryType: PackageDescription.Product.Library.LibraryType = .static +// force building as dynamic library +let dynamicLibrary = ProcessInfo.processInfo.environment["SWIFT_BUILD_DYNAMIC_LIBRARY"] != nil +let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrary ? .dynamic : nil let package = Package( name: "GATT", @@ -88,3 +91,13 @@ let package = Package( ) ] ) + +// SwiftPM command plugins are only supported by Swift version 5.6 and later. +#if swift(>=5.6) +let buildDocs = ProcessInfo.processInfo.environment["BUILDING_FOR_DOCUMENTATION_GENERATION"] != nil +if buildDocs { + package.dependencies += [ + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + ] +} +#endif