Skip to main content
Install the ZEN Engine and evaluate your first decision in iOS.

Installation

Or in Xcode: File → Add Package Dependencies → Enter the repository URL.

Basic usage

Loader

ZenEngine accepts an optional ZenLoader that serves decisions by key. Use the static, filesystem, or zip variants for common backends, or callback for custom loading logic.

Static

Register decisions in memory. Use this for rules shipped in your app bundle:

File system

Load decisions from files under a root directory, such as the Documents directory. Keys resolve to paths relative to the root:

Zip archive

Pass the bytes of a zip archive. Every .json entry becomes a decision keyed by its path within the archive. This pairs naturally with BRMS release ZIPs - download the release once and hand the bytes to the engine:

Custom loader

For any other backend, implement ZenDecisionLoaderCallback and wrap it in the callback variant:
Returning nil from the callback reports the key as not found.

Batch evaluation

Evaluate many requests in one call. Each result reports its own success or failure, so one bad input never fails the batch:

Async/Await

Evaluation functions are async, integrating natively with Swift concurrency:

Error handling

Tracing

Enable tracing to inspect decision execution:

Expression utilities

Evaluate ZEN expressions outside of a decision context:

Best practices

Initialize the engine once. Create a single ZenEngine instance at application startup and reuse it for all evaluations.
Cache decisions persistently. Use the Caches or Documents directory to cache downloaded decisions for offline use. Evaluate off the main thread. Use Task or Task.detached to avoid blocking the main thread during evaluation. Bundle fallback decisions. Include decisions in your app bundle as fallback for first launch or network failures.