|
1 | | -# Contentstack Swift CDA SDK – Agent Guide |
| 1 | +# Contentstack Swift CDA SDK – Agent guide |
2 | 2 |
|
3 | | -This document is the main entry point for AI agents working in this repository. |
| 3 | +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. |
4 | 4 |
|
5 | | -## Project |
| 5 | +## What this repo is |
6 | 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) |
| 7 | +| Field | Detail | |
| 8 | +|--------|--------| |
| 9 | +| **Name:** | [contentstack-swift](https://github.com/contentstack/contentstack-swift) (SwiftPM product **ContentstackSwift**) | |
| 10 | +| **Purpose:** | Swift Package for Contentstack Content Delivery—queries, entries, sync, etc.—for Apple platforms. | |
| 11 | +| **Out of scope:** | Not the legacy Objective-C iOS CocoaPods SDK (`contentstack-ios`); new apps should prefer this Swift SDK per product direction. | |
10 | 12 |
|
11 | | -## Tech stack |
| 13 | +## Tech stack (at a glance) |
12 | 14 |
|
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) |
| 15 | +| Area | Details | |
| 16 | +|------|---------| |
| 17 | +| Language | Swift (Package.swift tools **5.6+**); platforms include iOS 13+, macOS 10.15+, tvOS, watchOS per `Package.swift` | |
| 18 | +| Build | SwiftPM; Xcode workspace **`ContentstackSwift.xcworkspace`**; Carthage used in CI | |
| 19 | +| Tests | XCTest in **`Tests/`**; CI runs `xcodebuild test` (see `.github/workflows/ci.yml`) | |
| 20 | +| Lint / coverage | SwiftLint **`.swiftlint.yml`** | |
| 21 | +| CI | `.github/workflows/ci.yml`, `check-branch.yml`, `sca-scan.yml`, `policy-scan.yml`, `publish-cocoapods.yml` | |
18 | 22 |
|
19 | | -## Main entry points |
| 23 | +## Commands (quick reference) |
20 | 24 |
|
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 | +| Command type | Command | |
| 26 | +|--------------|---------| |
| 27 | +| SPM | `swift build` / `swift test` | |
| 28 | +| Lint | `swiftlint` (if installed) | |
| 29 | +| Xcode (CI-style) | `xcodebuild test -workspace ContentstackSwift.xcworkspace -scheme "ContentstackSwift macOS Tests" ...` (see `ci.yml`) | |
25 | 30 |
|
26 | | -## Commands |
| 31 | +## Where the documentation lives: skills |
27 | 32 |
|
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 | +| Skill | Path | What it covers | |
| 34 | +|-------|------|----------------| |
| 35 | +| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Branches, CI, Carthage, SPM resolve | |
| 36 | +| **Swift CDA SDK** | [`skills/contentstack-swift-cda/SKILL.md`](skills/contentstack-swift-cda/SKILL.md) | Public API, Stack types, dependencies on utils | |
| 37 | +| **Swift style & layout** | [`skills/swift-style/SKILL.md`](skills/swift-style/SKILL.md) | `Sources/`, `Tests/`, SwiftLint | |
| 38 | +| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | XCTest, DVR, `Tests/config.json` for CI | |
| 39 | +| **Build & platform** | [`skills/framework/SKILL.md`](skills/framework/SKILL.md) | Workspace, schemes, CocoaPods publish | |
| 40 | +| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist | |
33 | 41 |
|
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. |
| 42 | +## Using Cursor (optional) |
35 | 43 |
|
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. |
| 44 | +If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else. |
0 commit comments