---
title: iOS SDK configuration
description: >-
  The following configuration will require a Workspace Key. You can get your
  workspace key in the Access Keys section of the Survicate panel.
source_url:
  html: 'https://developers.survicate.com/mobile-sdk/ios/configuration/'
  md: 'https://developers.survicate.com/mobile-sdk/ios/configuration.md'
---
# iOS SDK configuration

The following configuration will require a Workspace Key. You can get your workspace key in the [Access Keys section](https://panel.survicate.com/o/0/w/0/settings/access-keys) of the Survicate panel.

1. Add workspace key to your `Info.plist` file.
   - Create `Survicate` _Dictionary_.
   - Define `WorkspaceKey` _String_ in `Survicate` _Dictionary_.
     This is how your `Info.plist` file should look like:
     ![Info.plist example](/ios-infoplist.png)

As an alternative to the main way of specifying the Workspace Key, you can also use the `setWorkspaceKey()` method.

Important:

- Using `setWorkspaceKey()` method overrides the Workspace Key defined in the configuration.
- `setWorkspaceKey()` method must be used before `init()` method is called.

```swift title="Swift"
try? SurvicateSdk.shared.setWorkspaceKey("your_workspace_key")
```

```objective-c title="Objective-C"
NSError *error;
[SurvicateSdk shared] setWorkspaceKey:@"your_workspace_key" error: &error];
```

2. Initialize the SDK using the `initialize` method. Choose an initialization method described below based on whether your project utilizes 'AppDelegate' class.

Make sure that `import Survicate` line exists in all classes where you call SDK methods.

```swift title="Swift"
// ...
import Survicate

class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        SurvicateSdk.shared.initialize()
        return true
    }
}
```

```objective-c title="Objective-C"
// ...
@import Survicate;

@implementation AppDelegate
// ...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[SurvicateSdk shared] initialize];
    return YES;
}
@end
```

Survicate iOS SDK can be used in SwiftUI projects. If your SwiftUI project doesn't use the `AppDelegate` class, the initialization of the Survicate Mobile SDK can be done in the constructor of the main application class:

```swift title="Initialization in SwiftUI projects, with no AppDelegate class"
// ...
import Survicate

@main
struct SwiftUIApp: App {

    init() {
        SurvicateSdk.shared.initialize()
    }
    // ...
}
```

**Enable debug messaging**

To enable debug console messages from the SDK, use the `setDebuggable(log:)` method with the desired log level. The SDK provides four log levels:

- `.none`
- `.error`
- `.info`
- `.verbose`

```swift title="Swift"
SurvicateSdk.shared.setDebuggable(log: .verbose)
```

```objective-c title="Objective-C"
[[SurvicateSdk shared] setDebuggableWithLog:LogLevelVerbose];
```

This is useful for development and debugging purposes. Make sure to disable it (`.none`) in production builds.
