Swift Rules Engine

Open source Swift rules engine for iOS apps. Offline-capable business rule evaluation with native performance.

Step 1

Add the Package

Add the GoRules engine to your Swift package or Xcode project.

// Package.swift
dependencies: [
    .package(url: "https://github.com/gorules/zen-ios", from: "0.1.0")
]
Step 2

Load a Decision

Create an engine and load your decision graph from a JSON file.

import ZenEngine

let engine = ZenEngine()
let content = try String(contentsOfFile: "decision.json")
let decision = try engine.createDecision(content: content)
Step 3

Evaluate Rules

Pass your input data and receive the decision result.

let input: [String: Any] = [
    "customer": ["tier": "premium", "country": "US"],
    "cart": ["total": 150, "items": 3]
]

let result = try decision.evaluate(input)
print(result.result) // ["discount": 15, "freeShipping": true]

Why Swift?

Built for performance and developer experience

Native Swift API

Idiomatic Swift with strong typing, optionals, and error handling via throwing functions.

Offline Capable

Evaluate rules entirely on-device. No network required after loading the decision graph.

Apple Platform Support

Full support for iOS. Works with SwiftUI and UIKit.

About the Swift SDK

GoRules brings high-performance business rules evaluation to the Apple ecosystem. The Swift SDK provides native bindings to our Rust core, delivering exceptional performance for iOS applications.

Designed with Swift idioms in mind, the SDK offers a clean, type-safe API that feels natural to Swift developers. Whether you're building mobile apps that need offline rule evaluation or server-side Swift applications with Vapor, GoRules integrates seamlessly with your codebase.

The engine runs entirely on-device, making it perfect for apps that need to evaluate business rules without network connectivity. All processing happens locally with no external API calls, ensuring user privacy and instant response times.

Ready to get started?

Start building business rules in minutes with our free tier.