Feature flags for iOS and macOS — remote toggles without App Store updates
Sign up at flagbit.anethoth.com to get your SDK key. The free tier includes 1,000 evaluations/day.
// Add to Package.swift or use URLSession directly
import Foundation
class FlagBit {
static let shared = FlagBit()
private let sdkKey = ProcessInfo.processInfo.environment["FLAGBIT_SDK_KEY"] ?? ""
private var cache: [String: Bool] = [:]
func isEnabled(_ flagKey: String, context: [String: String] = [:]) async -> Bool {
let cacheKey = "\(flagKey):\(context.hashValue)"
if let cached = cache[cacheKey] { return cached }
guard let url = URL(string: "https://flagbit.anethoth.com/api/v1/evaluate") else {
return false
}
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue(sdkKey, forHTTPHeaderField: "X-SDK-Key")
request.httpBody = try? JSONEncoder().encode([
"flag_key": flagKey,
"context": context
])
do {
let (data, _) = try await URLSession.shared.data(for: request)
let response = try JSONDecoder().decode(FlagResponse.self, from: data)
cache[cacheKey] = response.value
return response.value
} catch {
return false
}
}
}
struct FlagResponse: Decodable { let value: Bool }
// SwiftUI usage
struct ContentView: View {
@State private var showNewDesign = false
var body: some View {
Group {
if showNewDesign {
NewDashboardView()
} else {
ClassicDashboardView()
}
}
.task {
showNewDesign = await FlagBit.shared.isEnabled("new-dashboard",
context: ["user_id": userId, "platform": "ios"])
}
}
}
// UIKit usage
class SettingsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Task {
let showBeta = await FlagBit.shared.isEnabled("beta-settings")
if showBeta {
addBetaSection()
}
}
}
}
Toggle features without submitting a new build to App Review — changes take effect immediately.
Enable features only on iPad, or only on iOS 17+, using context-based targeting rules.
Roll out to 5% of users, monitor crash rates, then gradually increase to 100%.
Instantly disable a feature causing crashes — no emergency App Store submission needed.
Define flags in your FlagBit dashboard with targeting rules and rollout percentages.
Call the evaluate endpoint from your Swift/iOS app with user context for targeted rollouts.
Enable, disable, or adjust rollouts in real-time. No redeployment needed.
Cache flag values in UserDefaults. Load cached values first, then refresh from API when online.
Yes — use .task modifier for async flag evaluation as shown above. Bind to @State for reactive updates.
Yes — wrap the async call in a Future publisher for Combine-based architectures.
FlagBit works on any Apple platform with URLSession — watchOS, tvOS, and macOS included.
Free tier includes 1 project, 10 flags, and 1,000 evaluations/day. No credit card required.
Get Your Free API Key