Contentful Personalization & Analytics
    Preparing search index...

    Contentful Logo

    Contentful Personalization & Analytics

    iOS Reference App

    Readme · Guides · Reference · Contributing

    Warning

    The Optimization SDK Suite is pre-release (alpha). Breaking changes can be published at any time.

    Reference app for native iOS bridge and preview-panel validation work. This app exercises two iOS shells against the mock server in lib/mocks/ and hosts the XCUITest suite.

    Note

    This is not a published iOS SDK package. For package status, see packages/ios.

    Use this app when you need to validate native iOS bridge and preview-panel behavior against the shared mock API. The app includes two host shells:

    • OptimizationAppSwiftUI - SwiftUI shell, with sources under swiftui/.
    • OptimizationAppUIKit - UIKit shell, with sources under uikit/.

    Both apps share shared/ for configuration, Contentful fetching, and analytics event storage. They run the same UI test source tree from uitests/ against their respective host apps so SDK behavior can be compared across UI frameworks.

    • Xcode with an iOS Simulator available.
    • pnpm workspace dependencies installed from the monorepo root.
    • XcodeGen for changes that add, rename, or move iOS source files.
    • The mock server running at http://localhost:8000.

    The Xcode project is generated by XcodeGen from project.yml. Regenerate the project after you add, rename, or move a source file:

    brew install xcodegen
    xcodegen generate

    From the monorepo root, start the mock API server before running UI tests:

    pnpm serve:mocks
    

    Run the full suite against both app shells from implementations/ios-sdk/:

    xcodebuild test \
    -project OptimizationApp.xcodeproj \
    -scheme OptimizationAppSwiftUI \
    -destination 'platform=iOS Simulator,name=iPhone 16'

    xcodebuild test \
    -project OptimizationApp.xcodeproj \
    -scheme OptimizationAppUIKit \
    -destination 'platform=iOS Simulator,name=iPhone 16'

    Run a single test class against the SwiftUI shell:

    xcodebuild test \
    -project OptimizationApp.xcodeproj \
    -scheme OptimizationAppSwiftUI \
    -destination 'platform=iOS Simulator,name=iPhone 16' \
    -only-testing:OptimizationAppUITestsSwiftUI/PreviewPanelOverridesTests

    Add the .swift file to uitests/Tests/ and run xcodegen generate. Both UI test bundles pick up the file from the generated project.

    The preview-panel override suite mirrors the React Native Detox suite in implementations/react-native-sdk/e2e/preview-panel-overrides.test.js. Both reference the shared contract document at implementations/PREVIEW_PANEL_SCENARIOS.md. Keep scenario names and fixture IDs identical across platforms so cross-platform regressions are visible in CI diffs.