-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPackage.swift
More file actions
77 lines (66 loc) · 2.62 KB
/
Package.swift
File metadata and controls
77 lines (66 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// swift-tools-version: 6.0
import PackageDescription
import Foundation
let isRunningFromCommandLine: Bool = { ProcessInfo.processInfo.environment["XPC_SERVICE_NAME"] == "0" }()
let buildingDocumentation = getenv("BUILDING_FOR_DOCUMENTATION_GENERATION") != nil
var excluded = [
"TestPlans",
"Resources/SampleModel/Fixtures/README.md"
]
var resources: [Resource] = [
.copy("Resources/SampleModel/Fixtures/SampleModel_V1.sqlite"),
.copy("Resources/SampleModel/Fixtures/SampleModel_V2.sqlite"),
.copy("Resources/SampleModel2/Fixtures/SampleModel2_V1.sqlite"),
.copy("Resources/SampleModel2/Fixtures/SampleModel2_V2.sqlite"),
.copy("Resources/SampleModel3/Fixtures/SampleModel3_V1.sqlite"),
]
if isRunningFromCommandLine {
// When running tests from terminal, these resources needs to be copied in the test bundle,
// viceversa when running tests from Xcode, Xcode will create automatically these binaries automatically.
resources.append(contentsOf: [
.copy("Resources/SampleModel/Fixtures/SampleModel.momd"),
.copy("Resources/SampleModel/Fixtures/V2toV3.cdm"),
.copy("Resources/SampleModel3/Fixtures/SampleModel3.momd"),
])
} else {
// When running tests from Xcode, these resources needs to be excluded
// because they are automatically created by Xcode
excluded.append(contentsOf: [
"Resources/SampleModel/Fixtures/SampleModel.momd",
"Resources/SampleModel/Fixtures/V2toV3.cdm",
"Resources/SampleModel3/Fixtures/SampleModel3.momd"
])
}
// Remove warnings when building documentation or runnning test from CLI
if isRunningFromCommandLine || buildingDocumentation {
excluded += [
"Resources/SampleModel/MappingModels/V2toV3.xcmappingmodel",
"Resources/SampleModel/SampleModel.xcdatamodeld",
"Resources/SampleModel3/SampleModel3.xcdatamodeld"]
}
let swiftSettings: [SwiftSetting] = []
let package = Package(
name: "CoreDataPlus",
platforms: [.macOS(.v13), .iOS(.v16), .tvOS(.v16), .watchOS(.v9), .visionOS(.v1)],
products: [
.library(name: "CoreDataPlus", targets: ["CoreDataPlus"])
],
targets: [
.target(name: "CoreDataPlus",
path: "Sources",
swiftSettings: swiftSettings
),
.testTarget(name: "Tests",
dependencies: ["CoreDataPlus"],
path: "Tests",
exclude: excluded,
resources: resources,
swiftSettings: swiftSettings
),
],
swiftLanguageModes: [.v6]
)
// Only require the docc plugin when building documentation
package.dependencies += buildingDocumentation ? [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.2.0"),
] : []