Skip to content

Quick Start

Get started with the Ascend iOS SDK in just a few steps.


import SwiftUI
import Ascend
@main
struct MyApp: App {
init() {
setupAscendSDK()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
private func setupAscendSDK() {
// 1. Configure Core Settings
let coreConfig = AscendCoreConfig(
apiKey: "your-api-key",
environment: "development",
enableDebugLogging: true
)
// 2. Configure HTTP Settings
let httpConfig = HTTPConfig(
apiBaseUrl: "https://api.ascend.com",
timeout: 30.0,
shouldRetry: true,
maxRetries: 3,
defaultHeaders: ["api-key": "your-api-key"]
)
// 3. Configure Experiments Plugin
let experimentsConfig = AscendExperimentsConfiguration.development(
apiBaseUrl: "https://api.ascend.com",
apiEndpoint: "/v1/allocations",
defaultValues: [
"button_color": .dictionary([
"color": .string("blue")
])
],
headers: ["api-key": "your-api-key"]
)
// 4. Create SDK Configuration
let config = AscendConfig(
plugins: [AscendPlugin(type: .experiments, config: experimentsConfig)],
httpConfig: httpConfig,
coreConfig: coreConfig
)
// 5. Initialize the SDK
do {
try Ascend.initialize(with: config)
print("✅ Ascend SDK initialized successfully")
// Set a user (required for experiments)
Ascend.user.setUser(userId: "user-123")
} catch {
print("❌ Failed to initialize Ascend SDK: \(error)")
}
}
}

// Get the experiments plugin
let experiments = try Ascend.getPlugin(AscendExperiments.self)
// Get string value
let buttonColor = experiments.getStringValue(for: "button_color", with: "color")
print("Button color: \(buttonColor)")
// Get boolean value
let isEnabled = experiments.getBoolValue(for: "feature_toggle", with: "enabled")
print("Feature enabled: \(isEnabled)")
// Get integer value
let maxRetries = experiments.getIntValue(for: "retry_config", with: "max_attempts")
print("Max retries: \(maxRetries)")

let experiments = try Ascend.getPlugin(AscendExperiments.self)
experiments.fetchExperiments(for: [
"button_color": .dictionary([
"color": .string("blue")
])
]) { response, error in
if let error = error {
print("Error: \(error)")
} else if let response = response {
print("Fetched \(response.data?.count ?? 0) experiments")
}
}

Coming soon…