-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathPackage.swift
More file actions
79 lines (75 loc) · 3.23 KB
/
Copy pathPackage.swift
File metadata and controls
79 lines (75 loc) · 3.23 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
78
79
// swift-tools-version:5.9
import PackageDescription
import Foundation
// Single source of truth for the Swift package. The `Iroh` xcframework binary
// is resolved one of two ways, chosen at manifest-evaluation time:
//
// * a locally built xcframework, when this is a source checkout that has
// actually been built (`cargo make swift-xcframework` / `test-swift`).
// This is what local dev, CI, and source consumers (e.g. an app pointing
// at a local clone) get — so the binding always matches the source.
// * otherwise (git-URL / Swift Package Index consumers): the pinned,
// prebuilt xcframework zip attached to a GitHub release.
//
// Presence is keyed on the macOS slice's static lib. The whole xcframework
// directory is gitignored (build artifact only — Apple regenerates it from
// the cargo-built .a files via `xcodebuild -create-xcframework -library`),
// so a fresh consumer checkout has nothing local to find and falls through
// to the release zip. Set IROH_FORCE_REMOTE_XCFRAMEWORK to force the release
// zip even in a built checkout.
//
// `releaseTag` is rewritten locally by `cargo make prepare-release <V>`.
// `releaseChecksum` is rewritten on PR CI by `release_swift.yml` (one bot
// commit on the release branch, marked `[skip swift-release]`), so the value
// here always matches the IrohLib.xcframework.zip attached to the GitHub
// release — never a cross-host determinism game.
let releaseTag = "v1.0.0"
let releaseChecksum = "514b147f7965fe17acaece9a1157cf9421463b6c9282224983e871ea868b86ef"
let packageDir = URL(fileURLWithPath: #filePath).deletingLastPathComponent()
let localBuiltBinary = packageDir
.appendingPathComponent("Iroh.xcframework/macos-arm64/libiroh_ffi.a")
let forceRemote = ProcessInfo.processInfo.environment["IROH_FORCE_REMOTE_XCFRAMEWORK"] != nil
let useLocalXcframework = !forceRemote
&& FileManager.default.fileExists(atPath: localBuiltBinary.path)
let irohBinary: Target = useLocalXcframework
? .binaryTarget(
name: "Iroh",
path: "Iroh.xcframework")
: .binaryTarget(
name: "Iroh",
url: "https://github.com/n0-computer/iroh-ffi/releases/download/\(releaseTag)/IrohLib.xcframework.zip",
checksum: releaseChecksum)
let package = Package(
name: "IrohLib",
platforms: [
.iOS("17.5"),
.macOS("14.5")
],
products: [
.library(
name: "IrohLib",
targets: ["IrohLib", "Iroh"]),
],
dependencies: [],
targets: [
.target(
name: "IrohLib",
dependencies: [
.byName(name: "Iroh")
],
path: "IrohLib/Sources/IrohLib",
linkerSettings: [
.linkedFramework("SystemConfiguration"),
// iroh's netdev uses Network.framework for interface enumeration
// (the nw_* / nw_path_monitor_* symbols) on Apple platforms.
.linkedFramework("Network"),
// iroh's netwatch queries WiFi interfaces via CoreWLAN on macOS.
.linkedFramework("CoreWLAN", .when(platforms: [.macOS]))
]),
irohBinary,
.testTarget(
name: "IrohLibTests",
dependencies: ["IrohLib"],
path: "IrohLib/Tests/IrohLibTests"),
]
)