這邊我們要先用第一個 lib SourceKitten
透過 SourceKitten.Module
取得 某 Target
的 file list
.
以及編譯時的參數‧
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "LeakDetect",
dependencies: [
.package(url: "https://github.com/jpsim/SourceKitten", from: "0.34.1"),
],
targets: [
.target(
name: "LeakDetectKit",
dependencies: [
.product(name: "SourceKittenFramework", package: "SourceKitten"),
]
),
]
)
import SourceKittenFramework
let arguments: [String] = []
// .target(name: "LeakDetectKit")
let moduleName = "LeakDetectKit"
let path = "~/LeakDetect"
Module(spmArguments: arguments, spmName: moduleName, inPath: path)
import SourceKittenFramework
let scheme = "My Module"
let target = "My_Module"
let arguments: [String] = [
"-project", "/path/to/xxx.xcodeproj",
"-scheme", scheme,
]
Module(xcodeBuildArguments: arguments, name: target)
import SourceKittenFramework
let scheme = "My Module"
let target = "My_Module"
let arguments: [String] = [
"-workspace", "/path/to/xxx.xcworkspace",
"-scheme", scheme,
]
Module(xcodeBuildArguments: arguments, name: target)
/// 某 `Target` 底下所有的 file list
module.sourceFiles
/// 編譯此 `Target` 所需的編譯參數
module.compilerArguments