# How to Configure Environment Variables for Palmier Pro: Complete Setup Guide

> Learn how to configure environment variables for Palmier Pro. This guide covers `.env` file setup, Swift ProcessInfo, and Bash sourcing for AI service and build automation. Get your Palmier Pro project running smoothly.

- Repository: [Palmier/palmier-pro](https://github.com/palmier-io/palmier-pro)
- Tags: how-to-guide
- Published: 2026-06-23

---

**Palmier Pro reads environment variables from `.env` files to configure AI services at runtime and automate release builds, using Swift's `ProcessInfo` for runtime access and Bash sourcing for build scripts.**

Configuring environment variables for Palmier Pro connects the application to external AI services and enables automated release management. The palmier-io/palmier-pro repository implements a dual-layer configuration system that separates runtime credentials from build-time metadata, reading values from `.env` files located in the repository root.

## Required Environment Variables

Palmier Pro recognizes six distinct environment variables, categorized by their usage context.

### Runtime Variables

The application reads these variables during execution via `ProcessInfo.processInfo.environment`.

- **ANTHROPIC_API_KEY**: API key for the Anthropic LLM service used by the built-in AI assistant. The [`AnthropicClient.swift`](https://github.com/palmier-io/palmier-pro/blob/main/AnthropicClient.swift) file fetches this key directly from the environment. If absent, the AI client disables itself automatically.
- **SIGLIP2_BUILD**: Path to the SigLIP-2 model assets used by the visual-search subsystem. The test suite in [`VisualEmbedderParityTests.swift`](https://github.com/palmier-io/palmier-pro/blob/main/VisualEmbedderParityTests.swift) references this variable to locate model files, falling back to a default `"build"` directory if unspecified.

### Build-Time Variables

The release scripts consume these variables during packaging and signing operations.

- **VERSION**: Release version string (e.g., `1.2.3`)
- **NEW_BUILD**: Incremental build number (e.g., `20240621`)
- **PUBDATE**: Publication date in ISO-8601 format (e.g., `2024-06-21`)
- **LENGTH**: Duration in seconds for release notes video metadata
- **SIGNATURE**: Code-signing signature for the release pipeline

These variables are optional for local development but required for executing [`scripts/release.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/release.sh).

## Creating the Environment Configuration File

Place a `.env` file in the repository root (the directory containing [`Package.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Package.swift)) to store your configuration.

### Local Development Setup

Create a standard `.env` file for everyday development work:

```text

# Runtime configuration

ANTHROPIC_API_KEY=sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

# Optional: Custom model path for visual search testing

SIGLIP2_BUILD=../models/siglip2/build

```

The Swift runtime automatically detects these values without additional loading code.

### Production Builds

For release builds, create a `.env.prod` file. The [`scripts/bundle.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/bundle.sh) script automatically selects this file when `CONFIG=release`:

```bash

# scripts/bundle.sh – environment file selection

ENV_FILE=".env"
if [ "$CONFIG" = "release" ] && [ -f "$ROOT/.env.prod" ]; then
  ENV_FILE=".env.prod"
fi
source "$ROOT/$ENV_FILE"

```

A production `.env.prod` includes both runtime and build variables:

```text
ANTHROPIC_API_KEY=sk-production-key-here
SIGLIP2_BUILD=/opt/models/siglip2/build
VERSION=1.2.3
NEW_BUILD=20240621
PUBDATE=2024-06-21
LENGTH=120
SIGNATURE=abcdef1234567890

```

## How Palmier Pro Reads Environment Variables

Understanding the loading mechanisms ensures proper configuration across different execution contexts.

### Swift Runtime Access

The application accesses environment variables directly through Foundation's `ProcessInfo` class. In [`Sources/PalmierPro/Agent/Clients/AnthropicClient.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/Agent/Clients/AnthropicClient.swift), the Anthropic client implementation retrieves the API key:

```swift
if let env = ProcessInfo.processInfo.environment["ANTHROPIC_API_KEY"],
   !env.isEmpty {
    return env
}

```

Similarly, the test harness in [`Tests/PalmierProTests/Search/VisualEmbedderParityTests.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Tests/PalmierProTests/Search/VisualEmbedderParityTests.swift) reads the model path:

```swift
let modelPath = ProcessInfo.processInfo.environment["SIGLIP2_BUILD"] ?? "build"
let modelURL = URL(fileURLWithPath: modelPath)

```

### Build Script Sourcing

The Bash scripts [`scripts/bundle.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/bundle.sh) and [`scripts/release.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/release.sh) load variables using the `source` command. This approach makes the variables available to the shell session before executing packaging commands.

The [`scripts/release.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/release.sh) script consumes the build-time variables to generate release metadata and apply code signatures. If these variables are undefined, the script uses sensible defaults or prompts for required values depending on the execution context.

## Configuration File Locations

Maintain consistency by placing environment files in the expected locations:

- `.env` — Local development configuration consumed by the Swift runtime (`ProcessInfo`) and build scripts
- `.env.prod` — Production release configuration consumed by [`scripts/bundle.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/bundle.sh) when `CONFIG=release`
- [`Package.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Package.swift) — Indicates the repository root where environment files must reside

## Summary

- **ANTHROPIC_API_KEY** enables the AI assistant in [`AnthropicClient.swift`](https://github.com/palmier-io/palmier-pro/blob/main/AnthropicClient.swift) and is read via `ProcessInfo.processInfo.environment`
- **SIGLIP2_BUILD** specifies model asset paths for visual search functionality, used in [`VisualEmbedderParityTests.swift`](https://github.com/palmier-io/palmier-pro/blob/main/VisualEmbedderParityTests.swift)
- **Build-time variables** (`VERSION`, `NEW_BUILD`, `PUBDATE`, `LENGTH`, `SIGNATURE`) are consumed by [`scripts/release.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/release.sh) for automated packaging
- Create a `.env` file in the repository root for local development, and `.env.prod` for release builds
- The [`scripts/bundle.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/bundle.sh) script automatically selects `.env.prod` when `CONFIG=release` is set
- Swift code reads environment variables directly without additional loading libraries

## Frequently Asked Questions

### What happens if ANTHROPIC_API_KEY is not set?

If the `ANTHROPIC_API_KEY` variable is absent or empty, the Anthropic client initialization fails gracefully and disables the AI assistant feature. The application continues to function without AI capabilities, as implemented in the conditional check within [`AnthropicClient.swift`](https://github.com/palmier-io/palmier-pro/blob/main/AnthropicClient.swift).

### Can I use a different file name instead of .env?

The [`scripts/bundle.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/bundle.sh) script specifically looks for `.env` (or `.env.prod` for release builds) in the repository root. While the Swift runtime can read any environment variable present in the shell context, the automated build system expects these specific filenames. You can override the `ENV_FILE` variable in the script if you need custom naming conventions.

### Are the build-time variables required for local development?

No. The build-time variables (`VERSION`, `NEW_BUILD`, `PUBDATE`, `LENGTH`, `SIGNATURE`) are only required when executing [`scripts/release.sh`](https://github.com/palmier-io/palmier-pro/blob/main/scripts/release.sh) for distribution. Local development and testing within Xcode or Swift Package Manager function correctly without these variables defined.

### How does Palmier Pro handle environment variables in test environments?

The test suite accesses environment variables through the same `ProcessInfo.processInfo.environment` API used in production code. The [`VisualEmbedderParityTests.swift`](https://github.com/palmier-io/palmier-pro/blob/main/VisualEmbedderParityTests.swift) file specifically uses the `SIGLIP2_BUILD` variable to locate test model assets, providing a default value of `"build"` if the variable is undefined to ensure tests can run in CI environments without explicit configuration.