-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathPackage.swift
More file actions
104 lines (98 loc) · 3.85 KB
/
Package.swift
File metadata and controls
104 lines (98 loc) · 3.85 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// swift-tools-version: 6.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
//
// NOTE: This file MUST remain at the repository root for Swift Package Manager
// to resolve this package. SPM requires Package.swift at the root of a git
// repository. Do not move it into sdks/ios/ or any subdirectory.
import Foundation
import PackageDescription
let thisPackagePath = URL(fileURLWithPath: #filePath).deletingLastPathComponent().path
let useLocalBinary = FileManager.default.fileExists(
atPath: "\(thisPackagePath)/bindings/mobile/build/swift/LibXMTPSwiftFFI.xcframework"
)
let useLocalDynamicBinary = FileManager.default.fileExists(
atPath: "\(thisPackagePath)/bindings/mobile/build/swift/LibXMTPSwiftFFIDynamic.xcframework"
)
// Include the dynamic binary target when it exists locally OR for remote consumers.
// SPM downloads ALL declared binary targets (even trait-gated ones), so we must omit the
// dynamic target when only the static xcframework was built locally — otherwise both
// xcframeworks define the same `xmtpv3FFI` clang module, causing a redefinition error.
let includeDynamicTarget = useLocalDynamicBinary || !useLocalBinary
var packageTargets: [Target] = [
useLocalBinary
? .binaryTarget(
name: "LibXMTPSwiftFFI",
path: "bindings/mobile/build/swift/LibXMTPSwiftFFI.xcframework"
)
: .binaryTarget(
name: "LibXMTPSwiftFFI",
url:
"https://github.com/xmtp/libxmtp/releases/download/libxmtp-ios-b8bed44/LibXMTPSwiftFFI.zip",
checksum: "6cd91e456c494f38e71f0ec7786d9ff11f0dcb81b476a2f01e5b43ad3a68fe74"
),
.target(
name: "XMTPiOS",
dependencies: [
.product(name: "Connect", package: "connect-swift"),
.target(name: "LibXMTPSwiftFFI", condition: .when(traits: ["static"])),
.product(name: "CryptoSwift", package: "CryptoSwift"),
]
+ (includeDynamicTarget
? [.target(name: "LibXMTPSwiftFFIDynamic", condition: .when(traits: ["dynamic"]))]
: []),
path: "sdks/ios/Sources/XMTPiOS"
),
.target(
name: "XMTPTestHelpers",
dependencies: ["XMTPiOS"],
path: "sdks/ios/Sources/XMTPTestHelpers"
),
.testTarget(
name: "XMTPTests",
dependencies: ["XMTPiOS", "XMTPTestHelpers"],
path: "sdks/ios/Tests/XMTPTests"
),
]
if includeDynamicTarget {
packageTargets.insert(
useLocalDynamicBinary
? .binaryTarget(
name: "LibXMTPSwiftFFIDynamic",
path: "bindings/mobile/build/swift/LibXMTPSwiftFFIDynamic.xcframework"
)
: .binaryTarget(
name: "LibXMTPSwiftFFIDynamic",
url:
"https://github.com/xmtp/libxmtp/releases/download/libxmtp-ios-b8bed44/LibXMTPSwiftFFIDynamic.zip",
checksum: "93c57d1cde0532c42e5a781772701424e50ae1f177f9216a325f625c3ab8c00f"
),
at: 1
)
}
let package = Package(
name: "XMTPiOS",
platforms: [.iOS(.v14), .macOS(.v11)],
products: [
.library(
name: "XMTPiOS",
targets: ["XMTPiOS"]
),
.library(
name: "XMTPTestHelpers",
targets: ["XMTPTestHelpers"]
),
],
traits: [
"static",
"dynamic",
.default(enabledTraits: ["static"]),
],
dependencies: [
.package(url: "https://github.com/bufbuild/connect-swift", exact: "1.2.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.3"),
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", "1.8.4"..<"2.0.0"),
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "0.62.1"),
],
targets: packageTargets,
swiftLanguageModes: [.v5]
)