|
| 1 | +# Contentstack Swift CDA SDK – Agent Guide |
| 2 | + |
| 3 | +This document is the main entry point for AI agents working in this repository. |
| 4 | + |
| 5 | +## Project |
| 6 | + |
| 7 | +- **Name:** Contentstack Swift CDA SDK (contentstack-swift) |
| 8 | +- **Purpose:** Swift client for the Contentstack **Content Delivery API (CDA)**. It fetches content (entries, assets, content types, sync, taxonomy, global fields) from Contentstack for iOS, macOS, tvOS, watchOS, and Swift Package Manager consumers. |
| 9 | +- **Repo:** [contentstack-swift](https://github.com/contentstack/contentstack-swift) |
| 10 | + |
| 11 | +## Tech stack |
| 12 | + |
| 13 | +- **Language:** Swift (SPM minimum **swift-tools-version 5.6**; align with Xcode requirements in README) |
| 14 | +- **Build:** Swift Package Manager (`Package.swift`), **Xcode** (`ContentstackSwift.xcodeproj`) for multi-platform frameworks and CocoaPods (`ContentstackSwift.podspec`) |
| 15 | +- **Testing:** **XCTest** (`Tests/`), optional **DVR** (HTTP recording) for some tests; integration-style tests may use `Tests/config.json` / stack credentials |
| 16 | +- **HTTP:** **URLSession** (configured via `ContentstackConfig.sessionConfiguration`), optional **`CSURLSessionDelegate`** (SSL pinning / customization) |
| 17 | +- **Other:** [contentstack-utils-swift](https://github.com/contentstack/contentstack-utils-swift) (Rich text rendering) |
| 18 | + |
| 19 | +## Main entry points |
| 20 | + |
| 21 | +- **`Contentstack`** – Static factory: `Contentstack.stack(apiKey:deliveryToken:environment:region:host:apiVersion:branch:config:)` returns a `Stack`. |
| 22 | +- **`Stack`** – Main API surface: content types, entries, assets, sync, taxonomy, queries, cache policy, JSON decoding. |
| 23 | +- **`ContentstackConfig`** – Optional configuration: `URLSessionConfiguration`, date/time zone decoding, early access headers, `urlSessionDelegate`, user agent. |
| 24 | +- **Paths:** `Sources/` (library target **ContentstackSwift**), `Tests/` (test target **ContentstackTests**). |
| 25 | + |
| 26 | +## Commands |
| 27 | + |
| 28 | +- **SPM build:** `swift build` |
| 29 | +- **SPM tests:** `swift test` |
| 30 | +- **Xcode:** Open `ContentstackSwift.xcodeproj`, then build/test schemes such as **ContentstackSwift iOS**, **ContentstackSwift macOS**, **ContentstackSwift tvOS** (and matching test targets). |
| 31 | +- **xcodebuild (example – adjust simulator/OS):** |
| 32 | + `xcodebuild -project ContentstackSwift.xcodeproj -scheme "ContentstackSwift iOS" -destination 'platform=iOS Simulator,name=iPhone 16' build test` |
| 33 | + |
| 34 | +Run tests before opening a PR. API/integration tests that hit a live stack need valid credentials (see test helpers and `Tests/config.json` where applicable); do not commit secrets. |
| 35 | + |
| 36 | +## Rules and skills |
| 37 | + |
| 38 | +- **`.cursor/rules/`** – Cursor rules for this repo: |
| 39 | + - **README.md** – Index of all rules and when each applies (globs / always-on). |
| 40 | + - **dev-workflow.md** – Development workflow (branches, tests, PR expectations). |
| 41 | + - **swift.mdc** – Applies to `**/*.swift`: Swift style, module layout, logging, optionals. |
| 42 | + - **contentstack-swift-cda.mdc** – Applies to `Sources/**/*.swift`: CDA patterns, Stack/Config, host/version/region/branch, callbacks, alignment with Content Delivery API. |
| 43 | + - **testing.mdc** – Applies to `Tests/**/*.swift`: test naming, unit vs integration, XCTest. |
| 44 | + - **code-review.mdc** – Always applied: PR/review checklist (aligned with other Contentstack CDA SDKs). |
| 45 | +- **`skills/`** – Reusable skill docs: |
| 46 | + - Use **contentstack-swift-cda** when implementing or changing CDA API usage or SDK core behavior. |
| 47 | + - Use **testing** when adding or refactoring tests. |
| 48 | + - Use **code-review** when reviewing PRs or before opening one. |
| 49 | + - Use **framework** when changing config, URL session setup, or HTTP-related behavior (`ContentstackConfig`, `Stack` networking). |
| 50 | + |
| 51 | +Refer to `.cursor/rules/README.md` for when each rule applies and to `skills/README.md` for skill details. |
0 commit comments