This is the Swift + Cocoa implementation of Agora RTC SDK examples for macOS. Before making any changes, read ARCHITECTURE.md to understand the structural rules.
# Install dependencies
pod install
# Build in Xcode
xcodebuild -workspace APIExample.xcworkspace -scheme APIExample -configuration Release
# Or open in Xcode and build manually
open APIExample.xcworkspaceConfigure your Agora App ID in APIExample/Common/KeyCenter.swift:
struct KeyCenter {
static let AppId: String = "<#YOUR_APP_ID#>"
// Token is optional for testing, but required for production
static func Token(channelName: String) -> String {
return "<#YOUR_TOKEN#>"
}
}Do NOT:
- Introduce UIKit or SwiftUI — use Cocoa (AppKit) only
- Use Combine or async/await patterns unless already present in the file being modified
- Create examples outside the
APIExample/Examples/[Basic|Advanced]/directory structure - Forget to call
leaveChannel()anddestroy()when closing an example - Update UI from background threads — always dispatch to main thread
- Share engine instances between examples — each example manages its own lifecycle
All work must conform to the rules defined in ARCHITECTURE.md:
- Every example is a self-contained class implementing
AgoraRtcEngineDelegate - Each example manages its own Agora engine lifecycle
- Configuration is passed via initialization or property injection
- All examples are registered in
APIExample/ViewController.swift
- Language is Swift — do not introduce Objective-C files
- UI framework is Cocoa (AppKit) — do not introduce UIKit or SwiftUI
- State management uses instance variables and delegate callbacks — do not introduce Combine or async/await patterns unless they already exist in the file being modified
- Match the code style, naming, and patterns of existing examples
Each example may contain a SKILL.md file in its folder. When working on or referencing a specific example:
- Check whether a
SKILL.mdexists in that example's directory - If it exists, read it before making changes — it describes the API usage, call flow, and known constraints
- If it does not exist, one will be created in the future; proceed using the source code as the reference
SKILL.md location pattern: APIExample/Examples/[Basic|Advanced]/<ExampleName>/SKILL.md
For broader tasks, use the skills in .agent/skills/:
| Task | Skill | When to use |
|---|---|---|
| Add or modify an example | .agent/skills/upsert-case/ |
Need to create a new API demo or update an existing one |
| Code review | .agent/skills/review-case/ |
Review example code for lifecycle, thread safety, and convention compliance |