build: gate lib-vt xcframework on emit-xcframework with xcodebuild detection

This commit is contained in:
0xDVC
2026-04-23 17:07:40 +00:00
committed by Mitchell Hashimoto
parent caad13e232
commit 44a2d8740a
3 changed files with 25 additions and 48 deletions

View File

@@ -1,35 +1,6 @@
// swift-tools-version: 5.9
import Foundation
import PackageDescription
func existingXCFrameworkPath() -> String {
let fm = FileManager.default
let candidates = [
"../../zig-out/lib/ghostty-vt.xcframework",
"../../zig-out/xcframeworks/ghostty-vt.xcframework",
"../../zig-out/ghostty-vt.xcframework",
]
for rel in candidates {
let plist = "\(rel)/Info.plist"
var isDir: ObjCBool = false
if fm.fileExists(atPath: rel, isDirectory: &isDir),
isDir.boolValue,
fm.fileExists(atPath: plist)
{
return rel // important to return relative path
}
}
fatalError(
"""
GhosttyVt XCFramework not found.
Build it first (must produce a valid *.xcframework with Info.plist).
Tried:
\(candidates.joined(separator: "\n"))
""")
}
let package = Package(
name: "swift-vt-xcframework",
platforms: [.macOS(.v13)],
@@ -38,11 +9,13 @@ let package = Package(
name: "swift-vt-xcframework",
dependencies: ["GhosttyVt"],
path: "Sources",
linkerSettings: [.linkedLibrary("c++")]
linkerSettings: [
.linkedLibrary("c++"),
]
),
.binaryTarget(
name: "GhosttyVt",
path: existingXCFrameworkPath()
path: "../../zig-out/lib/ghostty-vt.xcframework"
),
]
)