Files
hapi/ios/Packages/HapiKit/Package.swift
T
weishu 3510a0f4f1 fix(ios): Linux compile + full package test round — fixtures green locally (A-CI-local)
ios/scripts/linux-test.sh stages HapiKit + shared/fixtures at repo depth
into a persistent tmp dir and runs swift test in swift:6.1-noble; the
manifest drops HapiUI (SwiftUI/swift-markdown/Highlightr) under
#if os(Linux). 458 tests green, including all 48 chat and 11 pagination
golden fixtures.

Fixes that fell out of the first real compile of the blind-written port:
- ChatTypes.CodexReview.wireValue + SummaryPatching legacy id fallback:
  split expressions that exceeded the Swift 6 type-checker budget
- FileEndpointsTests: raw string containing "# terminated the literal
  early (never compiled anywhere) — now ##-delimited
- SSEClient.backoffSleep: Task { try? ... } inferred Task<()?, Never>
- Darwin gates: Security/Keychain behind canImport(Security) (tests use
  InMemoryCredentialStore via CredentialStoring), CryptoKit digest with
  FNV-1a filename fallback, FoundationNetworking imports for URLSession
  types, corelibs URLCache diskPath: initializer, get-only
  waitsForConnectivity, delegate-based SSE transport where
  URLSession.bytes(for:) does not exist
2026-08-18 11:51:57 +08:00

67 lines
2.6 KiB
Swift

// swift-tools-version: 6.0
import PackageDescription
// HapiUI (SwiftUI + swift-markdown + Highlightr) cannot build on Linux, but
// HapiProtocol and HapiClient are pure Foundation and are compile- and
// fixture-verified in a Linux container by `ios/scripts/linux-test.sh`.
// Package manifests are Swift evaluated on the build host, so `#if os(Linux)`
// is the supported way to drop the UI product/targets (and their third-party
// dependencies) from the Linux build while keeping one manifest.
var products: [Product] = [
.library(name: "HapiProtocol", targets: ["HapiProtocol"]),
.library(name: "HapiClient", targets: ["HapiClient"]),
]
var dependencies: [Package.Dependency] = []
var targets: [Target] = [
// Pure protocol layer: wire models, chat pipeline, window logic.
// Must stay Foundation-only so it can be verified against
// shared/fixtures/** without any UI or transport concerns.
.target(name: "HapiProtocol"),
// Transport layer: APIClient, auth, SSE, stores (lands in M1).
.target(name: "HapiClient", dependencies: ["HapiProtocol"]),
.testTarget(name: "HapiProtocolTests", dependencies: ["HapiProtocol"]),
// HapiProtocol is named directly by SSE tests (SyncEvent assertions).
.testTarget(name: "HapiClientTests", dependencies: ["HapiClient", "HapiProtocol"]),
]
#if !os(Linux)
products.append(.library(name: "HapiUI", targets: ["HapiUI"]))
dependencies += [
// GFM parsing for the custom SwiftUI markdown renderer (HapiUI).
// The org moved from `apple` to `swiftlang`; product name is `Markdown`.
.package(url: "https://github.com/swiftlang/swift-markdown.git", from: "0.5.0"),
// JavaScriptCore-backed highlight.js wrapper for code blocks. Kept
// behind the `SyntaxHighlighting` protocol so it can be swapped out.
.package(url: "https://github.com/raspu/Highlightr.git", from: "2.2.0"),
]
targets += [
// Rendering foundation: markdown renderer + pre-parse transforms,
// code blocks with syntax highlighting, unified-diff view, theme.
.target(
name: "HapiUI",
dependencies: [
"HapiProtocol",
.product(name: "Markdown", package: "swift-markdown"),
.product(name: "Highlightr", package: "Highlightr"),
]
),
.testTarget(name: "HapiUITests", dependencies: ["HapiUI"]),
]
#endif
let package = Package(
name: "HapiKit",
platforms: [
// The app targets iOS 17+. macOS is declared so `swift test` can run
// the package on macOS CI runners (the code is pure Foundation).
.iOS(.v17),
.macOS(.v14),
],
products: products,
dependencies: dependencies,
targets: targets
)