Skip to content

Swift Configuration

let client = try Flags.builder()
.withAuth(Auth(
projectId: "your-project-id",
agentId: "your-agent-id",
environmentId: "your-environment-id"
))
.withBaseURL("https://custom-api.flags.gg")
.withMaxRetries(5)
.withErrorCallback { error in
print("Flag error: \(error)")
}
.build()
MethodDefaultDescription
withAuth(Auth)Required. Authentication credentials
withBaseURL(String)https://api.flags.ggCustom API endpoint
withMaxRetries(Int)3Max retry attempts
withErrorCallback((FlagsError) -> Void)Error callback handler
ErrorDescription
httpErrorNetwork or HTTP errors
cacheErrorCache operation errors
authErrorAuthentication errors
apiErrorAPI response errors
builderErrorConfiguration errors

You can use the client with only local flags (environment variables):

let client = try Flags.builder().build()
// Only checks FLAGS_* environment variables
let enabled = await client.is("my-feature").enabled()

The client uses Swift actors for thread safety. All operations are safe for concurrent access without explicit locking.