The iOS SDK for Formbricks
- In Xcode choose File → Add Packages…
- Enter your repo URL (e.g.
https://github.com/formbricks/ios.git) - Choose version rule (e.g. "Up to Next Major" starting at
2.2.0). - Import in your code:
import FormbricksSDK
-
Add the following to your
Podfile:platform :ios, '16.6' use_frameworks! :linkage => :static target 'YourTargetName' do pod 'FormbricksSDK', '2.2.0 (or the latest version)' end
-
Run
pod installin your project directory -
Import in your code:
import FormbricksSDK
import FormbricksSDK
// 1. Build your config (you can also inject userId + attributes here)
let config = FormbricksConfig.Builder(
appUrl: "https://your‑app.bricks.com",
workspaceId: "YOUR_WORKSPACE_ID"
)
.setLogLevel(.debug)
.build()
// Note: `environmentId` is still supported as a deprecated alias for
// `workspaceId` and will be removed in a future release.
// Existing integrations using `environmentId` continue to work:
//
// FormbricksConfig.Builder(
// appUrl: "https://your‑app.bricks.com",
// environmentId: "YOUR_ENV_ID" // deprecated, use workspaceId
// )
// 2. Initialize the SDK (once per launch)
Formbricks.setup(with: config)
// 3. Identify the user
Formbricks.setUserId("user‑123")
// 4. Track events
Formbricks.track("button_pressed")
// 5. Set or add user attributes
Formbricks.setAttribute("blue", forKey: "favoriteColor")
Formbricks.setAttributes([
"plan": "pro",
"tier": "gold"
])
// 6. Change language (no userId required):
Formbricks.setLanguage("de")
// 7. Log out (no userId required):
Formbricks.logout()
// 8. Clean up SDK state (optional):
Formbricks.cleanup(waitForOperations: true) {
print("SDK torn down")
}Surveys render light by default. Call setAppearance to change it:
Formbricks.setAppearance(.dark) // .light, .dark or .system- Works before or after
setup, or pass it in the config with.set(appearance: .dark). Objective-C:[Formbricks setAppearance:@"dark"]. - An open survey switches in place; the typed answer and current question stay.
.systemfollows your app's theme (includingoverrideUserInterfaceStyle), not the phone's, and updates live.- Kept across
logout(), forgotten on app restart, never sent to the server. An unknown value is logged and falls back to light. - Needs a Formbricks server that supports dark mode; an older server keeps surveys light.
Custom CSS configured in Formbricks needs no SDK call; it arrives with the workspace state.