Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 639d0bb

Browse files
committed
Add environment variable to force building as dynamic library
1 parent da77406 commit 639d0bb

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

Package.swift

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// swift-tools-version:5.1
22
import PackageDescription
3+
import class Foundation.ProcessInfo
34

4-
let libraryType: PackageDescription.Product.Library.LibraryType = .static
5+
// force building as dynamic library
6+
let dynamicLibrary = ProcessInfo.processInfo.environment["SWIFT_BUILD_DYNAMIC_LIBRARY"] != nil
7+
let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrary ? .dynamic : nil
58

6-
let package = Package(
9+
var package = Package(
710
name: "TLVCoding",
811
products: [
912
.library(
@@ -13,7 +16,23 @@ let package = Package(
1316
)
1417
],
1518
targets: [
16-
.target(name: "TLVCoding", path: "./Sources"),
17-
.testTarget(name: "TLVCodingTests", dependencies: ["TLVCoding"])
19+
.target(
20+
name: "TLVCoding",
21+
path: "./Sources"
22+
),
23+
.testTarget(
24+
name: "TLVCodingTests",
25+
dependencies: ["TLVCoding"]
26+
)
1827
]
1928
)
29+
30+
// SwiftPM command plugins are only supported by Swift version 5.6 and later.
31+
#if swift(>=5.6)
32+
let buildDocs = ProcessInfo.processInfo.environment["BUILDING_FOR_DOCUMENTATION_GENERATION"] != nil
33+
if buildDocs {
34+
package.dependencies += [
35+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
36+
]
37+
}
38+
#endif

0 commit comments

Comments
 (0)