Swiftpack.co - adobe/aepsdk-rulesengine-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A simple, generic, extensible Rules Engine in Swift
.package(url: "https://github.com/adobe/aepsdk-rulesengine-ios.git", from: "1.0.1")


Cocoapods SPM Build Code Coverage GitHub


A simple, generic, extensible Rules Engine in Swift.


  • Xcode 11.0 (or newer)
  • Swift 5.1 (or newer)



# Podfile

target 'YOUR_TARGET_NAME' do
    pod 'AEPRulesEngine'

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Swift Package Manager

To add the AEPRulesEngine package to your application, from the Xcode menu select:

File > Swift Packages > Add Package Dependency...

Enter the URL for the AEPRulesEngine package repository: https://github.com/adobe/aepsdk-rulesengine-ios.git.

When prompted, input a specific version or a range of versions.

Alternatively, if your project has a Package.swift file, you can add AEPRulesEngine directly to your dependencies:

dependencies: [
    .package(url: "https://github.com/adobe/aepsdk-rulesengine-ios.git", .upToNextMajor(from: "1.0.1"))


Initialize the Rules Engine

To create a RulesEngine instance, define an Evaluator and pass it to the RulesEngine's initializer:

let evaluator = ConditionEvaluator(options: .caseInsensitive)
let rulesEngine = RulesEngine(evaluator: evaluator)

Define Rules

Anything that conforms to the Rule protocol can be used as rule:

public class MobileRule: Rule {
    init(condition: Evaluable) { self.condition = condition }
    var condition: Evaluable
let condition = ComparisonExpression(lhs: "abc", operationName: "equals", rhs: "abc")
let rule = MobileRule(condition: condition)
rulesEngine.addRules(rules: [rule])

A rule without the flexibility to dynamically fetch a value will always evaluate to true or false. To fetch the value for a rule at runtime, use a Mustache Token:

let mustache = Operand<String>(mustache: "{{company}}")
let condition = ComparisonExpression(lhs: mustache, operationName: "equals", rhs: "adobe")
let rule = MobileRule(condition: condition)
rulesEngine.addRules(rules: [rule])

Evaluate data

Use the evaluate method to process Traversable data through the RulesEngine:

let matchedRules = rulesEngine.evaluate(data: ["company":"adobe"])


Contributions are welcomed! Read the Contributing Guide for more information.


This project is licensed under the Apache V2 License. See LICENSE for more information.


Stars: 8
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

23 weeks ago

What’s Changed

  • remove dynamic callable (#44) @shalehaha
  • validate codecov bash (SHASUM) (#43) @yangyansong-adbe

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics