SPB Git

Repository Public

Package.swift 4.5 KB 88 lines swift

1// swift-tools-version: 6.02// SP Notes Core3// File: Package.swift4// Description: Shared, UI-free core of the native SP Notes apps (iOS, iPadOS, macOS): document model, local store, sync.5//              Set SPN_ONLY=Document|Store|API|Sync|Design to build and test a single module in isolation (parallel development).6//7// Author: Simon-Pierre Boucher8// Contact: contact@spboucher.ai9import PackageDescription10import Foundation1112let only = ProcessInfo.processInfo.environment["SPN_ONLY"]13func on(_ name: String) -> Bool { only == nil || only == name }1415let swift: [SwiftSetting] = [.swiftLanguageMode(.v6)]16var targets: [Target] = []17var products: [Product] = []1819if on("Document") {20    targets += [21        .target(name: "SPNotesDocument", swiftSettings: swift),22        .testTarget(name: "SPNotesDocumentTests", dependencies: ["SPNotesDocument"], resources: [.copy("Fixtures")], swiftSettings: swift),23    ]24    products.append(.library(name: "SPNotesDocument", targets: ["SPNotesDocument"]))25}26if on("Store") {27    targets += [28        .target(name: "SPNotesStore", swiftSettings: swift, linkerSettings: [.linkedLibrary("sqlite3")]),29        .testTarget(name: "SPNotesStoreTests", dependencies: ["SPNotesStore"], resources: [.copy("Fixtures")], swiftSettings: swift),30    ]31    products.append(.library(name: "SPNotesStore", targets: ["SPNotesStore"]))32}33if on("API") {34    targets += [35        .target(name: "SPNotesAPI", swiftSettings: swift),36        .testTarget(name: "SPNotesAPITests", dependencies: ["SPNotesAPI"], resources: [.copy("Fixtures")], swiftSettings: swift),37    ]38    products.append(.library(name: "SPNotesAPI", targets: ["SPNotesAPI"]))39}40if only == nil || only == "Sync" {41    // Sync depends on the two others: it is only declared when they are.42    if only == "Sync" {43        targets += [44            .target(name: "SPNotesDocument", swiftSettings: swift),45            .target(name: "SPNotesStore", swiftSettings: swift, linkerSettings: [.linkedLibrary("sqlite3")]),46            .target(name: "SPNotesAPI", swiftSettings: swift),47        ]48    }49    targets += [50        .target(name: "SPNotesSync", dependencies: ["SPNotesDocument", "SPNotesStore", "SPNotesAPI"], swiftSettings: swift),51        // In-memory fake of the backend (URLProtocol) for the unit tests of this package AND of the apps. Never linked in an app target.52        .target(name: "SPNotesTestSupport", dependencies: ["SPNotesAPI"], swiftSettings: swift),53        .testTarget(name: "SPNotesSyncTests", dependencies: ["SPNotesSync", "SPNotesTestSupport"], swiftSettings: swift),54    ]55    products.append(.library(name: "SPNotesSync", targets: ["SPNotesSync"]))56    products.append(.library(name: "SPNotesTestSupport", targets: ["SPNotesTestSupport"]))57}58if on("Design") {59    // Note Visual System 2.0 (SwiftUI tokens and components). Independent of the other modules; not part of the umbrella.60    targets += [61        .target(name: "SPNotesDesign", swiftSettings: swift),62        .testTarget(name: "SPNotesDesignTests", dependencies: ["SPNotesDesign"], swiftSettings: swift),63    ]64    products.append(.library(name: "SPNotesDesign", targets: ["SPNotesDesign"]))65}66if only == nil {67    // Cross-platform SwiftUI feature screens of SP Note Next Generation (SPEC §8). Not part of the umbrella: `import SPNotesFeatures`.68    targets += [69        .target(name: "SPNotesFeatures", dependencies: ["SPNotesDesign", "SPNotesSync", "SPNotesStore", "SPNotesAPI", "SPNotesDocument"],70                resources: [.process("Resources")], swiftSettings: swift),71        // Debug gallery of every screen over the fake backend (`FeatureCatalogView`). Never linked in a shipping app target.72        .target(name: "SPNotesFeaturesCatalog", dependencies: ["SPNotesFeatures", "SPNotesTestSupport"], resources: [.copy("Samples")], swiftSettings: swift),73        .testTarget(name: "SPNotesFeaturesTests", dependencies: ["SPNotesFeatures", "SPNotesFeaturesCatalog", "SPNotesTestSupport"], swiftSettings: swift),74    ]75    products.append(.library(name: "SPNotesFeatures", targets: ["SPNotesFeatures"]))76    products.append(.library(name: "SPNotesFeaturesCatalog", targets: ["SPNotesFeaturesCatalog"]))77    targets.append(.target(name: "SPNotesCore", dependencies: ["SPNotesDocument", "SPNotesStore", "SPNotesAPI", "SPNotesSync"], swiftSettings: swift))78    products.append(.library(name: "SPNotesCore", targets: ["SPNotesCore"]))79}8081let package = Package(82    name: "SPNotesCore",83    defaultLocalization: "fr",84    platforms: [.iOS(.v18), .macOS(.v15)],85    products: products,86    targets: targets87)88
Files main
Menu

Theme