-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.swift
88 lines (79 loc) · 2.55 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.2
import PackageDescription
import Foundation
let projectDir = URL(fileURLWithPath: #filePath).deletingLastPathComponent()
@dynamicMemberLookup struct TheosConfiguration {
private let dict: [String: String]
init(at path: String) {
let configURL = URL(fileURLWithPath: path, relativeTo: projectDir)
guard let infoString = try? String(contentsOf: configURL) else {
fatalError("""
Could not find Theos SPM config. Have you run `make spm` yet?
""")
}
let pairs = infoString.split(separator: "\n").map {
$0.split(
separator: "=", maxSplits: 1,
omittingEmptySubsequences: false
).map(String.init)
}.map { ($0[0], $0[1]) }
dict = Dictionary(uniqueKeysWithValues: pairs)
}
subscript(
key: String,
or defaultValue: @autoclosure () -> String? = nil
) -> String {
if let value = dict[key] {
return value
} else if let def = defaultValue() {
return def
} else {
fatalError("""
Could not get value of key '\(key)' from Theos SPM config. \
Try running `make spm` again.
""")
}
}
subscript(dynamicMember key: String) -> String { self[key] }
}
let conf = TheosConfiguration(at: ".theos/spm_config")
let theosPath = conf.theos
let sdk = conf.sdk
let resourceDir = conf.swiftResourceDir
let deploymentTarget = conf.deploymentTarget
let triple = "arm64-apple-ios\(deploymentTarget)"
let libFlags: [String] = [
"-F\(theosPath)/vendor/lib", "-F\(theosPath)/lib",
"-I\(theosPath)/vendor/include", "-I\(theosPath)/include"
]
let cFlags: [String] = libFlags + [
"-target", triple, "-isysroot", sdk,
"-Wno-unused-command-line-argument", "-Qunused-arguments",
]
let cxxFlags: [String] = [
]
let swiftFlags: [String] = libFlags + [
"-target", triple, "-sdk", sdk, "-resource-dir", resourceDir,
]
let package = Package(
name: "ForceInsetGrouped",
platforms: [.iOS(.v13)],
products: [
.library(
name: "ForceUITableViewStyle",
targets: ["ForceUITableViewStyle"]
),
],
targets: [
.target(
name: "ForceUITableViewStyleC",
cSettings: [.unsafeFlags(cFlags)],
cxxSettings: [.unsafeFlags(cxxFlags)]
),
.target(
name: "ForceUITableViewStyle",
dependencies: ["ForceUITableViewStyleC"],
swiftSettings: [.unsafeFlags(swiftFlags)]
),
]
)