Repository navigation
Expand file tree
/
Copy pathPackage.swift
More file actions
72 lines (70 loc) · 2.81 KB
/
Copy pathPackage.swift
File metadata and controls
72 lines (70 loc) · 2.81 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
// swift-tools-version:5.9
import PackageDescription
// The `macos` executable is a bare command-line tool, not an .app bundle, so its
// Info.plist is embedded straight into the Mach-O's (__TEXT,__info_plist)
// section at link time. codesign then seals that section into the signature,
// which is what gives the binary a stable bundle identity — the thing macOS
// records a TCC permission grant against. Without it, every rebuild is a new
// identity and every granted permission has to be re-granted.
//
// `Context.packageDirectory` is an absolute path, so the link works regardless
// of the directory `swift build` was invoked from.
let infoPlistPath = Context.packageDirectory + "/Resources/macos-cli-Info.plist"
let package = Package(
name: "macos-cli",
platforms: [.macOS(.v13)],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
],
targets: [
// Pure, framework-light logic that can be unit-tested hermetically
// (no EventKit/Contacts/TCC prompts). The executable target depends on it.
.target(
name: "MacCLICore",
path: "Sources/MacCLICore"
),
.executableTarget(
name: "macos-cli",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"MacCLICore",
],
path: "Sources/macos-cli",
swiftSettings: [
.unsafeFlags([
"-framework", "EventKit",
"-framework", "Contacts",
"-framework", "CoreGraphics",
"-framework", "AppKit",
"-framework", "ApplicationServices",
"-framework", "Vision",
"-framework", "PDFKit",
"-framework", "CoreLocation",
"-framework", "IOBluetooth",
])
],
linkerSettings: [
.unsafeFlags([
"-Xlinker", "-sectcreate",
"-Xlinker", "__TEXT",
"-Xlinker", "__info_plist",
"-Xlinker", infoPlistPath,
])
]
),
// XCTest suite — canonical, runs under `swift test` when a full Xcode is present.
.testTarget(
name: "MacCLICoreTests",
dependencies: ["MacCLICore"],
path: "Tests/MacCLICoreTests"
),
// Dependency-free mirror of the XCTest assertions, runnable on a
// Command-Line-Tools-only toolchain where XCTest is unavailable:
// swift run MacCLICoreTestRunner
.executableTarget(
name: "MacCLICoreTestRunner",
dependencies: ["MacCLICore"],
path: "Sources/MacCLICoreTestRunner"
),
]
)