iOS Low-Code Integration
Use the LowCodeMobile iOS SDK to display personalized content in your iOS app with minimal setup. The SDK renders out-of-the-box Banner and Recommendations components and supports custom components for fully custom UI.
- Install the SDK
- Initialize the SDK
- Display a Content Zone
- Out-of-the-Box Components
- Custom Components
- Engagement Tracking
- Preview
- Design-Time Rendering
- Error Handling
In Xcode, add the LowCodeMobile package to your project. The Personalization, Data 360, and Salesforce Marketing Cloud SDK packages are pulled in transitively. Xcode limits updates to within the same major version by default when you specify the package.
Selecting your app target when adding the package should automatically add the LowCodeMobile framework to it, but it’s worth confirming under General > Frameworks, Libraries, and Embedded Content.
Add the pods to your app’s Podfile. The Personalization, Data 360, and Salesforce Marketing Cloud SDK packages are pulled in transitively. Limit updates to within the same major version to avoid unexpected breaking changes:
Then run:
Open the .xcworkspace file, then clean and build.
Your app’s SDK levels must meet or exceed the following minimums.
| Setting | Required |
|---|---|
| iOS deployment target | 15.0+ |
| Xcode | 26.2+ |
| Swift | 5.9+ |
The host app owns SDK initialization. Initialize both the Data 360 (CDP) and Personalization modules early in your application lifecycle: in SwiftUI, call this from your App type’s init(); in UIKit, call it from AppDelegate.application(_:didFinishLaunchingWithOptions:). The SDK queues any content zone requests made before initialization completes, so you do not need to gate your UI on init status.
In your production application, you must explicitly manage user consent using the solution provided in the Engagement Mobile SDK. See Data 360 Consent Management.
- Replace
<Your CDP App ID>,<Your CDP Endpoint>, and<Your CDN URL>with the values provided by your Salesforce Marketing Cloud administrator. - To avoid committing credentials, read these values from
Info.plistor a build configuration file. - To enable debug logging during development, add
SFMCSdk.setLogger(logLevel: .debug)beforeSFMCSdk.initializeSdk(...), so logging is active for the whole init sequence. Remove this before building for production.
Once the SDK is initialized, use ContentZone in your SwiftUI views to display personalized content.
Pass the content zone identifier and a list of components the zone is allowed to render. The SDK fetches a decision from the backend, matches the component name returned, and renders the matching component.
After adding a ContentZone to your app code, create the matching content zone record in Salesforce Personalization. See Set Up Mobile Content Zones for instructions on defining personalization points, assigning components, and configuring engagement definitions.
ContentZone is a standard SwiftUI view - place it anywhere in your layout alongside other content. The Pull-to-refresh example below shows it embedded within a scrollable screen.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The content zone identifier, matching your backend configuration (case-sensitive). |
allowedComponents | Yes | The Components the zone may render. If the backend returns a name not in this list, the fallback is shown. |
decisionsRequestContext | No | Optional context to bias personalization decisions. |
timeoutSeconds | No | Fetch timeout in seconds. Default: 10. |
controller | No | ContentZoneController for programmatic refresh. |
loading | No | View shown while content is loading. |
fallback | No | View shown when content cannot be loaded or no component matches. |
Use a ContentZoneController to refresh the zone programmatically:
The SDK ships with two pre-built components - SalesforceBanner and SalesforceRecommendations - that handle layout, styling, and configuration-driven engagement tracking out of the box. Use these when you want to display personalized content without writing a custom UI. Both support an onTap callback for custom tap handling; by default, tapping opens the ctaUrl if one is provided by the backend.
These components are available out-of-the-box in the UI and are registered under the names "Salesforce_Banner" and "Salesforce_Recommendations".
Pass a DecisionsRequestContext to bias recommendations based on what the user is currently viewing. All fields are optional - if you only supply anchorId, the system infers the type automatically.
Override the default appearance of out-of-the-box components by passing a style object:
Implement the Component protocol to render a content zone with your own UI. Each component defines:
static var name: String - The component name that matches the backend experience template name.validateAndCreateComponentModel(unvalidatedJson:componentContext:) - Decodes and validates the JSON payload and returns a typed model, or throws a PersonalizationErrorcompose(model:componentContext:) - Returns the SwiftUI view for the component.
Define a custom component with its own component name, model, and associated experience template in the backend. Give the component a unique name (for example, CustomHero), then create a matching experience template in the Core UI and a matching custom component in your app. Your model’s fields and types must match the experience template’s schema, though you don’t need to use all of them.
For a component that renders a list (like SalesforceRecommendations), use the per-item variants of the engagement functions to report engagement for each item in the list.
Out-of-the-box components (SalesforceBanner, SalesforceRecommendations) track View and Click engagement automatically. These are the only two actions currently supported end-to-end. The SDK accepts custom action strings for future expansion.
For custom components, engagement is not automatic - you must call these methods explicitly from your component code:
| Function | Use for |
|---|---|
componentContext.trackEngagement(action:) | Clicks on a single-item component (e.g. CustomHero) |
componentContext.trackEngagementPerItem(index:action:) | Clicks on an item within a multi-item component (e.g. CustomItemList) |
.sfpTrackEngagementViewOnce(componentContext) | Views of a single-item component - a View modifier, applied once per personalization |
.sfpTrackEngagementViewOncePerItem(componentContext, index:) | Views of an item within a multi-item component - a View modifier, applied once per item per personalization |
See Define a custom component and Define a multi-item custom component above for both in use.
The SDK supports previewing personalized content via QR code or preview URL. When a URL containing the sfp-preview parameter is opened, the SDK renders preview content in all active content zones.
Before using preview, ensure:
- Your app is configured to handle URL schemes or Universal Links (via Associated Domains and your app’s entitlements).
- The base URL is set in your Data 360 mobile connector configuration.
The appropriate URL-handling method depends on your app’s lifecycle and the iOS versions you support (e.g. application(_:open:options:), scene(_:openURLContexts:) for SceneDelegate, or Universal Links via application(_:continue:restorationHandler:)). The example below uses the AppDelegate method:
Use MockDataContentZone to render components with mock data for styling and layout without any backend setup or networking. This is not related to QR-code based previewing - it simply lets you see how components look during development.
To try out your fallback view, throw an error from the closure:
The SDK uses the PersonalizationError enum for error reporting:
| Error Case | Description |
|---|---|
.unknown | An unknown error occurred. |
.initialization | The SDK has not been initialized or failed to initialize. |
.consent | User consent is not set to opt-in. |
.requestInvalid | The request parameters are invalid. |
.network | A network error occurred during the fetch. |
.responseInvalid | The server response could not be parsed. |
.timeout | The fetch request exceeded the timeout duration. |
ContentZone handles errors internally. If no fallback is provided, the zone logs the error and shows nothing - this is the typical production behavior. If you want to display fallback content, pass a fallback view. The following example is for illustration only - consider what behavior is appropriate for your production app: