iOS Salesforce Mobile SDK Integration
This skill integrates the Salesforce Mobile SDK into iOS Swift applications. It is consumed by autonomous coding agents — every reference file is self-contained and contains exact source-of-truth code, file paths, and CLI commands.
Scenarios
Pick the reference file that matches the task. Scenarios are layered: each later one assumes the previous is already wired up.
| Scenario | Reference | Preconditions |
|---|---|---|
| Create a new iOS Swift app from scratch | references/create-new-app.md |
none |
| Add Mobile SDK authentication to an existing app | references/add-mobile-sdk.md |
An iOS Swift app target exists |
| Add SmartStore (encrypted local DB) | references/add-smartstore.md |
SalesforceManager.initializeSDK() is called and bootconfig.plist exists |
| Add MobileSync (sObject ⇄ soup sync) | references/add-mobilesync.md |
SmartStoreSDKManager.initializeSDK() is called and userstore.json exists |
| Add Biometric Authentication (Face ID / Touch ID) | references/add-biometric-auth.md |
Mobile SDK is initialized in AppDelegate |
| Add Dark Mode (system / forced / user toggle) | references/add-dark-mode.md |
Mobile SDK is initialized in AppDelegate |
Cross-cutting references:
| Topic | Reference |
|---|---|
Swift ↔ Objective-C name mapping (NS_SWIFT_NAME) |
references/api-reference.md |
| Build / login / SmartStore / biometric error symptoms | references/troubleshooting.md |
Detection Rules
When the user request is ambiguous, run these checks against the working directory and pick the first scenario in the list below whose precondition is not met — even if the user asked for a later capability (e.g. a "sync" request lands on add-smartstore.md if userstore.json is not yet present, then chains forward):
- No Xcode project (
*.xcodeprojor*.xcworkspace) at the repo root →create-new-app.md. - Project exists but no
import SalesforceSDKCore(or any SDK module) anywhere in*.swift→add-mobile-sdk.md. - SDK imported, but no
userstore.jsonin the target's source folder →add-smartstore.md. userstore.jsonexists, but nousersyncs.json→add-mobilesync.md.- Biometric requested but no
biometricAuthenticationManager()reference →add-biometric-auth.md.
Invariants Across All Scenarios
These hold regardless of which scenario runs:
- Project shape: detect from disk in priority order. (1)
Podfile+project.yml→ hybrid (Option A for the SDK; xcodegen for sources). (2)Podfileonly → CocoaPods (Option A). (3)project.ymlonly → xcodegen + SPM (Option B-i). (4).xcodeprojonly → plain SPM (Option B-ii). Use the matching path inreferences/add-mobile-sdk.md. - CocoaPods workspace rule: after
pod install, the build/open target is<AppName>.xcworkspace, never<AppName>.xcodeproj. project.ymlis the source-of-truth signal. Whenproject.ymlis not present, do not author one and do not runxcodegen generateagainst the existing.xcodeproj— regenerating drops the project's hand-maintained target/scheme configuration. Whenproject.ymlis present (with or without aPodfile), it is the source of truth andxcodegen generateis the correct way to land new files. The "Create New App" scenario authorsproject.ymland runsxcodegen generatefrom scratch.- Code signing for simulator builds: use ad-hoc signing (
CODE_SIGN_IDENTITY=-). Never passCODE_SIGNING_ALLOWED=NO— it strips the keychain entitlement and silently breaks login (seereferences/troubleshooting.md). - Login host default:
login.salesforce.comfor production,test.salesforce.comfor sandboxes. - Smoke test UI: each
setupRootViewController()example installs a labeled placeholder view — replace it with the real root view controller after the smoke test passes.
Source of Truth
When the SDK API in this skill disagrees with reality, the upstream Objective-C headers in https://github.com/forcedotcom/SalesforceMobileSDK-iOS win. Resolve a Swift name by grepping the SDK source for NS_SWIFT_NAME(<name>).