SPB Git

Repository Public

Package.swift 5.1 KB 80 lines swift

1// swift-tools-version: 6.22// Author: Simon-Pierre Boucher — contact@spboucher.ai3// File: Package.swift4// Description: Single manifest for every shared Local Chat module (Packages/*, Services/*) used by the macOS and iOS apps.5import PackageDescription67let mlx: [Target.Dependency] = [8    .product(name: "MLXLLM", package: "mlx-swift-lm"),9    .product(name: "MLXVLM", package: "mlx-swift-lm"),10    .product(name: "MLXLMCommon", package: "mlx-swift-lm"),11    .product(name: "MLXEmbedders", package: "mlx-swift-lm"),12    .product(name: "MLX", package: "mlx-swift"),13    .product(name: "Tokenizers", package: "swift-transformers"),14    .product(name: "Jinja", package: "swift-jinja"),15]1617func module(_ name: String, in root: String = "Packages", _ deps: [Target.Dependency] = [], resources: [Resource]? = nil) -> Target {18    .target(name: name, dependencies: deps, path: "\(root)/\(name)/Sources", resources: resources,19            swiftSettings: [.swiftLanguageMode(.v6)])20}21func tests(_ name: String, _ deps: [Target.Dependency]) -> Target {22    .testTarget(name: name, dependencies: deps, path: "Tests/\(name)", swiftSettings: [.swiftLanguageMode(.v6)])23}2425// LC_NO_MLX=1 leaves out the modules that need MLX / llama.cpp (and the UI that links them), so the pure-Swift modules build and test in seconds.26let light = Context.environment["LC_NO_MLX"] == "1"27let heavyTargets: Set<String> = ["LocalChatInference", "LocalChatUI", "LocalChatInferenceTests", "LocalChatAppTests"]2829let package = Package(30    name: "LocalChatKit",31    defaultLocalization: "en",32    platforms: [.macOS(.v15), .iOS(.v18)],33    products: [34        .library(name: "LocalChatKit", targets: [35            "LocalChatCore", "LocalChatSecurity", "LocalChatNetworking", "LocalChatInference", "LocalChatModelHub",36            "LocalChatConversations", "LocalChatKnowledge", "LocalChatAgents", "LocalChatBenchmarks", "LocalChatSync",37            "RemoteInference", "LocalAPIServer", "LocalChatUI",38        ].filter { !light || !heavyTargets.contains($0) }),39    ],40    dependencies: (light ? [] : [41        .package(url: "https://github.com/ml-explore/mlx-swift-lm", exact: "3.33.0"),42        .package(url: "https://github.com/ml-explore/mlx-swift", .upToNextMinor(from: "0.33.0")),43        .package(url: "https://github.com/huggingface/swift-transformers", exact: "1.4.0"),44        .package(url: "https://github.com/huggingface/swift-jinja.git", "2.4.2"..<"4.0.0"),45        .package(url: "https://github.com/mattt/llama.swift", exact: "3.0.0"),46        .package(url: "https://github.com/mgriebling/SwiftMath.git", exact: "1.7.3"),47        .package(url: "https://github.com/swiftlang/swift-markdown.git", exact: "0.7.3"),48    ]) + [49        .package(url: "https://github.com/groue/GRDB.swift", exact: "7.12.0"),50    ],51    targets: [52        module("LocalChatCore"),53        module("LocalChatSecurity", ["LocalChatCore"]),54        module("LocalChatNetworking", ["LocalChatCore"]),55        module("LocalChatInference", ["LocalChatCore"] + mlx + [56            // the upstream llama.cpp XCFramework ships macOS and iOS-device slices only (no iOS Simulator): GGUF is macOS-only here57            .product(name: "LlamaSwift", package: "llama.swift", condition: .when(platforms: [.macOS])),58        ]),59        module("LocalChatModelHub", ["LocalChatCore", "LocalChatNetworking"]),60        module("LocalChatConversations", ["LocalChatCore", .product(name: "GRDB", package: "GRDB.swift")]),61        module("LocalChatKnowledge", ["LocalChatCore", .product(name: "GRDB", package: "GRDB.swift")]),62        module("LocalChatAgents", ["LocalChatCore"]),63        module("LocalChatBenchmarks", ["LocalChatCore", .product(name: "GRDB", package: "GRDB.swift")]),64        module("LocalChatSync", ["LocalChatCore", "LocalChatSecurity", "LocalChatNetworking"]),65        module("RemoteInference", in: "Services", ["LocalChatCore", "LocalChatNetworking"]),66        module("LocalAPIServer", in: "Services", ["LocalChatCore", "LocalChatNetworking", "LocalChatSecurity"]),67        module("LocalChatUI", [68            "LocalChatCore", "LocalChatSecurity", "LocalChatNetworking", "LocalChatInference", "LocalChatModelHub",69            "LocalChatConversations", "LocalChatKnowledge", "LocalChatAgents", "LocalChatBenchmarks", "LocalChatSync",70            "RemoteInference", "LocalAPIServer", .product(name: "SwiftMath", package: "SwiftMath"),71            .product(name: "Markdown", package: "swift-markdown"),72        ], resources: [.process("Resources")]),73        tests("LocalChatCoreTests", ["LocalChatCore", "LocalChatSecurity", "LocalChatNetworking"]),74        tests("LocalChatDataTests", ["LocalChatCore", "LocalChatConversations", "LocalChatKnowledge", "LocalChatBenchmarks", "LocalChatModelHub"]),75        tests("LocalChatServiceTests", ["LocalChatCore", "LocalChatAgents", "LocalChatSync", "RemoteInference", "LocalAPIServer"]),76        tests("LocalChatInferenceTests", ["LocalChatCore", "LocalChatInference", "LocalChatModelHub"]),77        tests("LocalChatAppTests", ["LocalChatUI", "LocalChatCore", "LocalChatModelHub", "LocalChatConversations", "LocalChatInference", "LocalChatKnowledge"]),78    ].filter { !light || !heavyTargets.contains($0.name) }79)80
Files main
Menu

Theme