-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPackage.swift
More file actions
53 lines (50 loc) · 2.17 KB
/
Copy pathPackage.swift
File metadata and controls
53 lines (50 loc) · 2.17 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
// swift-tools-version: 5.9
import Foundation
import PackageDescription
// The bindings ship as a prebuilt xcframework — odrcore is a large C++ project
// with conan dependencies, which SwiftPM cannot build.
//
// The url and checksum below are stamped by `release.yml` onto the commit it
// tags, so off a release tag they say `UNRELEASED` and resolve to nothing. Only
// tags are consumable.
//
// `ODR_XCFRAMEWORK` points at a locally built one, which is how the test target
// and a developer working on `apple/` exercise what they just built rather than
// the last release. Consumers never set it and get the release artifact.
//
// It must be **relative to the package root** — SwiftPM rejects an absolute
// path for a binary target outright. `apple/build_xcframework.py assemble`
// writes to the repo root, so the value is normally just the bundle name:
//
// ODR_XCFRAMEWORK=OdrCoreObjC.xcframework swift build
let binary: Target = ProcessInfo.processInfo.environment["ODR_XCFRAMEWORK"]
.map { Target.binaryTarget(name: "OdrCoreObjC", path: $0) }
?? Target.binaryTarget(
name: "OdrCoreObjC",
url:
"https://github.com/opendocument-app/OpenDocument.core/releases/download/v7.2.2/OdrCoreObjC.xcframework.zip",
checksum: "03ac4ca6e300101076e7d7a67a21483e50007449a88ce0bb3d7437938c247503"
)
let package = Package(
name: "OdrCore",
// Must not be below what the slices were built for; the conan `apple-*`
// profiles pin the same values.
platforms: [
.iOS(.v15),
.macOS(.v12),
],
products: [
.library(name: "OdrCore", targets: ["OdrCore"])
],
targets: [
binary,
// Everything Apple lives under `apple/`, so the targets point there
// rather than at the conventional `Sources/`.
.target(name: "OdrCore", dependencies: ["OdrCoreObjC"], path: "apple/swift"),
// `.copy`, not `.process`: the fixture is an input to decode verbatim,
// and processing an .odt would be a resource pipeline guessing at a zip.
.testTarget(
name: "OdrCoreTests", dependencies: ["OdrCore"], path: "apple/tests",
resources: [.copy("Fixtures")]),
]
)