Skip to content

Latest commit

 

History

History
100 lines (79 loc) · 5.04 KB

File metadata and controls

100 lines (79 loc) · 5.04 KB

Contentful Logo

Contentful Personalization & Analytics

Optimization iOS SDK

Warning

The Optimization iOS SDK is in beta. Breaking changes can be published at any time.

The Optimization iOS SDK is a beta Swift Package for native iOS applications. It is part of the Contentful Optimization SDK Suite and runs shared optimization behavior through the local JavaScriptCore bridge while Swift code owns native app concerns such as persistence, networking, lifecycle handling, SwiftUI views, and preview-panel UI.

Table of Contents

Current status

  • The native Swift package exists under ContentfulOptimization.
  • The shared JavaScriptCore adapter package lives under optimization-js-bridge and compiles the bridge bundle consumed by Swift.
  • The native iOS reference app validates current bridge and preview-panel behavior against the shared mock API.
  • OptimizationConfig.locale is the SDK Experience API and default event locale. Runtime locale changes use OptimizationClient.setLocale(_:). Explicit invalid locale values throw.
  • Applications query the Contentful Delivery API by content type and slug, using one concrete application locale, then pass the fetched entry to OptimizedEntry or resolveOptimizedEntry(...). The native iOS SDK does not provide managed entry fetching. Do not pass all-locale CDA responses from withAllLocales or locale=*; see Entry personalization and variant resolution. For the broader locale model, see Locale handling in the Optimization SDK Suite.
  • Treat this surface as beta-stage implementation work. The API, setup flow, and bridge contract are subject to change until a stable native iOS SDK release is declared.

When to use this package

Use this directory when working on the native iOS SDK, SwiftUI integration, JavaScriptCore bridge handoff, preview-panel behavior, or cross-platform native validation. Application teams that need a JavaScript mobile integration can start with the @contentful/optimization-react-native package.

Package layout

  • ContentfulOptimization/ - Swift Package source, public Swift API, native runtime, resources, and tests
  • optimization-js-bridge/ - shared internal TypeScript bridge compiled into the JavaScriptCore UMD bundle consumed by the Swift Package
  • CODE_MAP.md - architecture map for the current native iOS implementation

Releasing

The Swift Package is published to a separate distribution repository, contentful/optimization.swift, so consumers can add it by URL (from: "x.y.z") without cloning the monorepo. Publishing is automated by publish-spm.yaml: on each v* release it builds the JS bridge (stamping the version into the UMD), assembles the package payload, and pushes a commit and tag to the distribution repo.

The distribution repo is generated output, like an npm dist/: nobody pushes to it by hand. The UMD bundle is no longer committed to the monorepo — it is built on demand (and gitignored). Build it locally before swift build/swift test with pnpm run ios:bridge, or use the convenience scripts pnpm run ios:build and pnpm run ios:test from the repo root.

Related