A small SwiftUI application showing how to use the Featurevisor Swift SDK.
The application downloads a Featurevisor datafile, creates an SDK instance, and evaluates the mobile_experience feature as a flag, variation, and string variable.
You need Xcode 16 or newer. The application targets iOS 14 or newer.
- Open
FeaturevisorExampleIOS.xcodeprojin Xcode. - Wait for Swift Package Manager to resolve the Featurevisor dependency.
- Select an iPhone simulator.
- Run the
FeaturevisorExampleIOSscheme.
The application fetches this production datafile:
https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-mobile.json
The important SDK usage is in FeaturevisorViewModel.swift:
let datafile = try DatafileContent.fromData(data)
let f = createFeaturevisor(
FeaturevisorOptions(datafile: datafile)
)
let context: Context = [
"userId": .string("mobile-user"),
"country": .string("nl")
]
let enabled = f.isEnabled("mobile_experience", context)
let variation = f.getVariation("mobile_experience", context)
let message = f.getVariableString(
"mobile_experience",
"welcome_message",
context
)Learn more in the Featurevisor Swift SDK documentation.