Quickstart
The Eppo iOS SDK enables feature flags and experiments in your iOS applications with just a few lines of code. It handles flag evaluation and experiment assignments locally on the device, making it fast and reliable for your users.
Installation
While in XCode:
- Choose
Package Dependencies
- Click
+
and enter package URL:git@github.com:Eppo-exp/eppo-ios-sdk.git
- Set dependency rule to
Up to Next Minor Version
and selectAdd Package
- Add to your project's target.
Feature Flags
Feature flags are a way to toggle features on and off without needing to deploy code.
Initialize the SDK
First, initialize the SDK with your API key. You'll need to do this early in your application lifecycle:
import EppoFlagging
Task {
try await EppoClient.initialize(sdkKey: "SDK-KEY-FROM-DASHBOARD");
}
Get your SDK key from the Eppo web interface.
Make Assignments
Once initialized, you can start using feature flags anywhere in your app:
let eppoClient = EppoClient.shared()
// Check if a feature should be enabled
let userId = getCurrentUserId() // Your user identification logic
var attributes = ["userType": "premium", "country": "US"]
let isEnabled = try eppoClient.getBooleanAssignment(
flagKey: "new-feature",
subjectKey: userId,
subjectAttributes: attributes,
defaultValue: false
)
if isEnabled {
// Show new feature
showNewFeature()
} else {
// Show existing feature
showExistingFeature()
}
Running Experiments
To run experiments, you'll need to add a logging callback during initialization to track assignments:
// Example of a simple assignmentLogger function
func segmentAssignmentLogger(assignment: Assignment) {
let assignmentDictionary: [String: Any] = [
"allocation": assignment.allocation,
"experiment": assignment.experiment,
"featureFlag": assignment.featureFlag,
"variation": assignment.variation,
"subject": assignment.subject,
"timestamp": assignment.timestamp
]
analytics.track(
name: "Eppo Assignment",
properties: TrackProperties(assignmentDictionary)
)
}
eppoClient = try await EppoClient.initialize(sdkKey: "<SDK-KEY>", assignmentLogger: segmentAssignmentLogger)
Then use the SDK to make experiment assignments:
let assignment = try eppoClient.getStringAssignment(
flagKey: "new-user-onboarding",
subjectKey: user.id,
subjectAttributes: user.attributes,
defaultValue: "control"
);
// Use the variant value to determine which component to render
if assignment == "version-a" {
showVersionA()
} else if assignment == "version-b" {
showVersionB()
} else {
showControl()
}
Next Steps
Now that you have the basics working, here are some advanced topics to explore: