> For the complete documentation index, see [llms.txt](https://docs.winga.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.winga.me/integrations/swift.md).

# Swift

There is no dedicated `@winga/swift` SDK. Use the [Evaluation API](/api-reference/evaluation-api.md) directly with `URLSession`. Load the flag map once, then read it synchronously.

```swift
import Foundation

struct FlagState: Decodable {
  let enabled: Bool
}

struct FlagsResponse: Decodable {
  let flags: [String: FlagState]
}

final class WingaClient {
  let apiKey: String
  let environment: String
  private var flags: [String: FlagState] = [:]

  init(apiKey: String, environment: String) {
    self.apiKey = apiKey
    self.environment = environment
  }

  func load() async throws {
    let url = URL(string: "https://api.winga.me/v1/flags?env=\(environment)")!
    var request = URLRequest(url: url)
    request.setValue(apiKey, forHTTPHeaderField: "X-Winga-Key")
    let (data, _) = try await URLSession.shared.data(for: request)
    flags = try JSONDecoder().decode(FlagsResponse.self, from: data).flags
  }

  func isEnabled(_ key: String) -> Bool {
    flags[key]?.enabled ?? false
  }
}

// Usage
let ff = WingaClient(apiKey: "proj_live_xxx", environment: "production")
try await ff.load()

if ff.isEnabled("new-onboarding") {
  // show new onboarding
}
```

For realtime updates, open a streaming request to `GET /v1/stream?env=<environment>` and re-decode the flag map on each frame.
