Developer
1//...2 dependencies: [3 .package(url: "https://github.com/launchdarkly/ios-client-sdk.git", .upToNextMajor(from: "9.15.0")),4 ],5 targets: [6 .target(7 name: "YOUR_TARGET",8 dependencies: ["LaunchDarkly"]9 )10 ],11//...
1import LaunchDarkly23// This is your mobile key.4let config = LDConfig(mobileKey: "YOUR_MOBILE_KEY", autoEnvAttributes: .enabled)56// A "context" is a data object representing users, devices, organizations, and other entities.7let contextBuilder = LDContextBuilder(key: "EXAMPLE_CONTEXT_KEY")8guard case .success(let context) = contextBuilder.build()9else { return }1011LDClient.start(config: config, context: context, startWaitSeconds: 5) { timedOut in12 if timedOut {13 print("SDK didn't initialize in 5 seconds. SDK is still running and trying to get latest flags.")14 } else {15 print("SDK successfully initialized with the latest flags")16 }17}1819print("SDK started.")
You can find your server-side SDK keys, mobile keys, and client-side ID on the SDK keys page under Settings.
To learn more, read Initialize the client in the iOS SDK reference guide.