-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathPackage.swift
88 lines (79 loc) · 2.72 KB
/
Package.swift
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
// swift-tools-version:5.7
import PackageDescription
import Foundation
struct Theos {
let path: String
let resources: String
let sdk: String
let target: String
init() {
let configURL: URL = .init(fileURLWithPath: #filePath)
.deletingLastPathComponent()
.appendingPathComponent(".theos")
.appendingPathComponent("spm_config")
guard let data: Data = try? .init(contentsOf: configURL),
let lines: [String] = String(data: data, encoding: .utf8)?.components(separatedBy: "\n"),
let tmpPath: String = lines[0].components(separatedBy: "=").last,
let tmpSdk: String = lines[1].components(separatedBy: "=").last,
let tmpTarget: String = lines[2].components(separatedBy: "=").last,
let tmpResources: String = lines[3].components(separatedBy: "=").last
else {
path = ("~/theos" as NSString).expandingTildeInPath
resources = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/swift"
sdk = path + "/sdks/iPhoneOS16.2.sdk/"
target = "15.0"
return
}
path = tmpPath
resources = tmpResources
sdk = tmpSdk
target = tmpTarget
}
}
let theos: Theos = .init()
let theosPath: String = theos.path
let packageRoot = URL(fileURLWithPath: #file.replacingOccurrences(of: "Package.swift", with: ""))
let swiftFlags: [String] = [
"-F\(theosPath)/vendor/lib",
"-F\(theosPath)/lib",
"-I\(theosPath)/vendor/include",
"-I\(theosPath)/include",
"-I\(packageRoot.path)/Sources/include",
"-target", "arm64-apple-ios\(theos.target)",
"-sdk", theos.sdk,
"-resource-dir", theos.resources
]
let package: Package = .init(
name: "mldecrypt",
platforms: [.iOS(theos.target)],
products: [
.library(
name: "mldecrypt",
targets: ["mldecrypt"]
),
],
dependencies: [
.package(url: "https://github.com/weichsel/ZIPFoundation.git", .upToNextMajor(from: "0.9.0"))
],
targets: [
.target(
name: "mldecrypt",
dependencies: [
.product(name:"ZIPFoundation", package: "ZIPFoundation")
],
swiftSettings: [.unsafeFlags(swiftFlags)]
),
.target(
name: "mldecryptapp",
dependencies: [
.product(name:"ZIPFoundation", package: "ZIPFoundation")
],
swiftSettings: [.unsafeFlags(swiftFlags)]
),
.target(
name: "mldecryptor",
dependencies: [],
swiftSettings: [.unsafeFlags(swiftFlags)]
)
]
)