> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Add Prism to your Swift project. Client apps, server APIs, or both.

# Installation

Prism is distributed as a Swift package. No Homebrew, no CocoaPods — add it to your `Package.swift`.

## Requirements

| Requirement                             | Minimum |
| --------------------------------------- | ------- |
| Swift                                   | 6.3+    |
| Xcode                                   | 16.4+   |
| iOS / macOS / tvOS / watchOS / visionOS | 26+     |

<Warning>
  PrismServer uses Network.framework — macOS only for server targets. Client modules work on all Apple platforms.
</Warning>

## Swift Package Manager

### Client app (iOS/macOS)

```swift title="Package.swift" theme={null}
// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "my-app",
    platforms: [.iOS(.v17), .macOS(.v14)],
    dependencies: [
        .package(url: "https://github.com/byescaleira/prism.git", from: "4.4.0")
    ],
    targets: [
        .target(
            name: "my-app",
            dependencies: [
                .product(name: "Prism", package: "prism")
            ]
        )
    ]
)
```

`import Prism` gives you [PrismUI](/ui/theme), [PrismArchitecture](/architecture/store), [PrismNetwork](/network/client), [PrismStorage](/storage/overview), [PrismSecurity](/security/overview), [PrismIntelligence](/intelligence/overview), and [PrismCapabilities](/capabilities/auth).

### Server API

```swift title="Package.swift" theme={null}
// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "my-server",
    platforms: [.macOS(.v14)],
    dependencies: [
        .package(url: "https://github.com/byescaleira/prism.git", from: "4.4.0")
    ],
    targets: [
        .executableTarget(
            name: "my-server",
            dependencies: [
                .product(name: "PrismServer", package: "prism")
            ]
        )
    ]
)
```

### Full-stack (client + server)

```swift title="Package.swift" theme={null}
// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "my-project",
    platforms: [.iOS(.v17), .macOS(.v14)],
    dependencies: [
        .package(url: "https://github.com/byescaleira/prism.git", from: "4.4.0")
    ],
    targets: [
        .target(name: "App", dependencies: [.product(name: "Prism", package: "prism")]),
        .executableTarget(name: "Server", dependencies: [.product(name: "PrismServer", package: "prism")])
    ]
)
```

<Tip>
  Pin to a specific version for production: `.package(url: "...", exact: "4.4.0")`. Use `from:` for automatic minor/patch updates.
</Tip>

## Available Products

Import only what you need:

| Product             | Includes                                                                                                                                                                                                                                                   |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Prism`             | Umbrella — [UI](/ui/theme), [Architecture](/architecture/store), [Network](/network/client), [Foundation](/foundation/protocols), [Intelligence](/intelligence/overview), [Capabilities](/capabilities/auth), [Video](/video/overview)                     |
| `PrismServer`       | [HTTP server](/server/core/server), [routing](/server/core/routing), [middleware](/server/middleware/cors), [database](/server/database/overview), [WebSocket](/server/realtime/websocket), [GraphQL](/server/graphql/schema), [MCP](/server/mcp/overview) |
| `PrismUI`           | [100+ components](/ui/components), [design tokens](/ui/tokens), [theming](/ui/theme)                                                                                                                                                                       |
| `PrismArchitecture` | [Store](/architecture/store), [reducer](/architecture/reducer), [middleware](/architecture/middleware), [router](/architecture/router)                                                                                                                     |
| `PrismNetwork`      | [HTTP client](/network/client), [WebSocket client](/network/websocket-client), cache, retry                                                                                                                                                                |
| `PrismStorage`      | [Defaults](/storage/defaults-disk), [Disk](/storage/defaults-disk), [Memory](/storage/memory-keychain), [SwiftData](/storage/swiftdata), [Keychain](/storage/memory-keychain)                                                                              |
| `PrismSecurity`     | [Biometrics](/security/permissions-biometrics), [encryption](/security/encryption-keychain), [cert pinning](/security/cert-pinning-integrity), [JWT](/security/audit-token-privacy)                                                                        |
| `PrismIntelligence` | [CoreML](/intelligence/training), [Apple Intelligence](/intelligence/apple-intelligence), [NLP/RAG](/intelligence/nlp-rag)                                                                                                                                 |
| `PrismGamification` | [Challenges](/gamification/challenges), [streaks](/gamification/streaks-badges), [leaderboards](/gamification/leaderboards)                                                                                                                                |
| `PrismCapabilities` | [StoreKit](/capabilities/platform), [HealthKit](/capabilities/health), [Camera](/capabilities/media), [Location](/capabilities/location)                                                                                                                   |
| `PrismFoundation`   | Core utilities — logging, extensions, protocols                                                                                                                                                                                                            |

## Verify Installation

<Tabs>
  <Tab title="Client">
    ```swift title="ContentView.swift" theme={null}
    import Prism

    struct ContentView: View {
        var body: some View {
            PrismButton("Hello, Prism!", variant: .filled) {
                print("It works!")
            }
            .prismTheme(.default)
        }
    }
    ```

    ```bash theme={null}
    swift build
    ```

    If it compiles, you're good. Open in Xcode to run on simulator.
  </Tab>

  <Tab title="Server">
    ```swift title="Sources/main.swift" theme={null}
    import PrismServer

    let server = PrismHTTPServer(port: 8080)

    await server.get("/") { _ in
        .json(["status": "ok", "framework": "Prism"])
    }

    try await server.start()
    try await Task.sleep(for: .seconds(.max))
    ```

    ```bash theme={null}
    swift run
    curl http://localhost:8080
    # {"status":"ok","framework":"Prism"}
    ```
  </Tab>
</Tabs>

## IDE Setup

<Tabs>
  <Tab title="Xcode">
    ```bash theme={null}
    open Package.swift
    ```

    Xcode resolves dependencies automatically. Full autocomplete, jump-to-definition, and debugging.
  </Tab>

  <Tab title="VS Code">
    Install the [Swift extension](https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang) for SourceKit-LSP integration.

    ```bash theme={null}
    code .
    ```
  </Tab>

  <Tab title="Terminal">
    ```bash theme={null}
    swift build   # Compile
    swift run     # Build and run
    swift test    # Run tests
    ```
  </Tab>
</Tabs>

## Server: Docker & Scaffolding

<Accordion title="Docker deployment">
  ```dockerfile title="Dockerfile" theme={null}
  # Build stage
  FROM swift:6.0-jammy AS builder
  WORKDIR /app
  COPY Package.swift Package.resolved ./
  RUN swift package resolve
  COPY Sources/ Sources/
  RUN swift build -c release

  # Run stage
  FROM swift:6.0-jammy-slim
  WORKDIR /app
  COPY --from=builder /app/.build/release/my-server .
  EXPOSE 8080
  CMD ["./my-server"]
  ```

  ```bash theme={null}
  docker build -t my-server .
  docker run -p 8080:8080 my-server
  ```
</Accordion>

<Accordion title="Project scaffolding">
  ```swift theme={null}
  import PrismServer

  try PrismServerScaffold.generate(name: "my-api", directory: "./my-api")
  ```

  Creates a ready-to-run project with `Package.swift`, `main.swift`, `Dockerfile`, and `.gitignore`.
</Accordion>

<Accordion title="Server configuration (.env)">
  Prism reads configuration from environment variables and `.env` files via [`PrismConfig`](/server/infrastructure/config):

  ```bash title=".env" theme={null}
  PORT=3000
  HOST=0.0.0.0
  DATABASE_PATH=./data/app.db
  PRISM_ENV=production
  ```

  ```swift theme={null}
  let config = PrismConfig.load()
  let port = config.port              // from PORT (default 8080)
  let isProd = config.isProduction    // checks PRISM_ENV == "production"
  let dbPath = config.get("DATABASE_PATH", default: ":memory:")
  ```

  Supports environment profiles: `.env` → `.env.{PRISM_ENV}` → environment variables (highest priority).
</Accordion>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Build an iOS app or server API — pick your path.
  </Card>

  <Card title="UI Components" icon="palette" href="/ui/components">
    Explore 100+ SwiftUI components with design tokens.
  </Card>

  <Card title="State Management" icon="sitemap" href="/architecture/store">
    Build reactive apps with PrismStore and reducers.
  </Card>

  <Card title="Server Core" icon="server" href="/server/core/server">
    Routing, middleware pipeline, request/response lifecycle.
  </Card>
</CardGroup>
