Skip to content

Commit f998430

Browse files
author
HeZhengQing
committed
[FEAT] ios skills agents.md
1 parent b7b1350 commit f998430

13 files changed

Lines changed: 1378 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
name: api-example-conventions
3+
description: Structure conventions for iOS APIExample projects, including UIKit, SwiftUI, Objective-C, and Audio implementations
4+
compatibility: [Cursor, Kiro, Windsurf, Claude, Copilot]
5+
license: MIT
6+
metadata:
7+
author: APIExample Team
8+
version: 2.0.0
9+
platform: iOS
10+
---
11+
12+
# iOS API Example Conventions
13+
14+
This SKILL contains structure conventions for different APIExample implementations on iOS platform. Load the corresponding convention document on demand based on your target project type.
15+
16+
## iOS Project Types
17+
18+
This repository contains the following iOS example projects:
19+
20+
### 1. APIExample (Standard UIKit)
21+
22+
**Directory:** `APIExample/`
23+
24+
**Core Rules:**
25+
- **Example Directory:** `APIExample/APIExample/Examples/[Basic|Advanced]/<ExampleName>/`
26+
- **Files:**
27+
- `<ExampleName>.swift` - Entry and Main classes
28+
- `Base.lproj/<ExampleName>.storyboard`
29+
- **Classes:**
30+
- Entry: `<ExampleName>Entry` inherits from `UIViewController`
31+
- Main: `<ExampleName>Main` inherits from `BaseViewController`
32+
- **Storyboard IDs:**
33+
- Entry scene: `EntryViewController`
34+
- Main scene: `<ExampleName>`
35+
- **Menu Registration:** Add `MenuItem` to the `menus` array in `APIExample/APIExample/ViewController.swift`
36+
37+
**Detailed Conventions:** Read `references/ios-uikit-conventions.md`
38+
39+
### 2. APIExample-SwiftUI
40+
41+
**Directory:** `APIExample-SwiftUI/`
42+
43+
**Core Rules:**
44+
- Uses SwiftUI framework
45+
- Uses `@StateObject` and `@ObservableObject` for state management
46+
- Uses `UIViewRepresentable` to wrap video rendering views
47+
48+
**Detailed Conventions:** Read `references/ios-swiftui-conventions.md`
49+
50+
### 3. APIExample-OC (Objective-C)
51+
52+
**Directory:** `APIExample-OC/`
53+
54+
**Core Rules:**
55+
- Uses Objective-C language
56+
- Similar Entry/Main pattern as UIKit
57+
- Uses `.h` and `.m` files
58+
59+
**Detailed Conventions:** Read `references/ios-objc-conventions.md`
60+
61+
### 4. APIExample-Audio
62+
63+
**Directory:** `APIExample-Audio/`
64+
65+
**Core Rules:**
66+
- Focuses on audio-related features
67+
- Simplified UI implementation
68+
- Audio-specific API calls
69+
70+
**Detailed Conventions:** Read `references/ios-audio-conventions.md`
71+
72+
## Common Conventions
73+
74+
Conventions shared across all iOS projects:
75+
76+
1. **Example Naming:** Use PascalCase (e.g., `JoinChannelVideo`)
77+
2. **Categories:** Basic (basic features) and Advanced (advanced features)
78+
3. **SKILL Documentation:** Each example may include `SKILL.md` providing API usage guide
79+
4. **Code Style:** Follow official Swift/Objective-C coding standards
80+
5. **Configuration Management:** Use `KeyCenter` to manage App ID and Token
81+
6. **Global Settings:** Use `GlobalSettings.shared` to manage common configurations
82+
83+
## Load on Demand
84+
85+
When you need to work with specific example types:
86+
87+
1. **UIKit Standard Examples:** Read `references/ios-uikit-conventions.md`
88+
2. **SwiftUI Examples:** Read `references/ios-swiftui-conventions.md`
89+
3. **Objective-C Examples:** Read `references/ios-objc-conventions.md`
90+
4. **Audio-Focused Examples:** Read `references/ios-audio-conventions.md`
91+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# iOS Audio Platform API Example Conventions
2+
3+
This document describes the structure conventions for examples in the `APIExample-Audio/` project.
4+
5+
## Directory Structure
6+
7+
- **Basic Examples:** `APIExample-Audio/APIExample-Audio/Examples/Basic/<ExampleName>/`
8+
- **Advanced Examples:** `APIExample-Audio/APIExample-Audio/Examples/Advanced/<ExampleName>/`
9+
10+
## File Composition
11+
12+
Similar to standard UIKit version, but focused on audio features:
13+
- Entry and Main classes
14+
- Simplified UI (no video rendering views)
15+
- Audio-specific configuration and controls
16+
17+
## Audio-Specific Conventions
18+
19+
### Audio-Focused Features
20+
21+
- Audio capture and playback
22+
- Audio effects (reverb, voice changer, etc.)
23+
- Audio mixing
24+
- Custom audio source
25+
- Audio routing control
26+
27+
### Simplified UI
28+
29+
Since no video is involved, UI is more concise:
30+
- Channel control buttons
31+
- Audio status indicators
32+
- Audio effect parameter adjustments
33+
34+
### API Call Focus
35+
36+
```swift
37+
// Enable audio
38+
agoraKit.enableAudio()
39+
40+
// Audio configuration
41+
agoraKit.setAudioProfile(.musicHighQuality)
42+
agoraKit.setAudioScenario(.gameStreaming)
43+
44+
// Audio effects
45+
agoraKit.setLocalVoicePitch(1.0)
46+
agoraKit.setLocalVoiceEqualization(.band31, withGain: 0)
47+
```
48+
49+
## Menu Registration
50+
51+
Register example entry in `ViewController.swift`.
52+
53+
## Detailed Conventions
54+
55+
(To be supplemented with complete Audio platform conventions)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# iOS Objective-C Platform API Example Conventions
2+
3+
This document describes the structure conventions for examples in the `APIExample-OC/` project.
4+
5+
## Directory Structure
6+
7+
- **Basic Examples:** `APIExample-OC/APIExample-OC/Examples/Basic/<ExampleName>/`
8+
- **Advanced Examples:** `APIExample-OC/APIExample-OC/Examples/Advanced/<ExampleName>/`
9+
10+
## File Composition
11+
12+
Each example typically contains:
13+
- Header file: `<ExampleName>.h`
14+
- Implementation file: `<ExampleName>.m`
15+
- Storyboard: `Base.lproj/<ExampleName>.storyboard`
16+
17+
## Objective-C Specific Conventions
18+
19+
### Entry and Main Pattern
20+
21+
Similar to Swift version, but using Objective-C syntax:
22+
23+
**Entry Class:**
24+
```objc
25+
@interface <ExampleName>Entry : UIViewController
26+
@end
27+
```
28+
29+
**Main Class:**
30+
```objc
31+
@interface <ExampleName>Main : BaseViewController
32+
@end
33+
```
34+
35+
### Delegate Methods
36+
37+
Implement `AgoraRtcEngineDelegate` protocol:
38+
39+
```objc
40+
@interface <ExampleName>Main () <AgoraRtcEngineDelegate>
41+
@end
42+
```
43+
44+
### Property Declaration
45+
46+
```objc
47+
@property (nonatomic, strong) AgoraRtcEngineKit *agoraKit;
48+
@property (nonatomic, weak) IBOutlet UIView *localVideoView;
49+
```
50+
51+
## Menu Registration
52+
53+
Register example entry in `ViewController.m`.
54+
55+
## Detailed Conventions
56+
57+
(To be supplemented with complete Objective-C platform conventions)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# iOS SwiftUI Platform API Example Conventions
2+
3+
This document describes the structure conventions for examples in the `APIExample-SwiftUI/` project.
4+
5+
## Directory Structure
6+
7+
- **Basic Examples:** `APIExample-SwiftUI/APIExample-SwiftUI/Examples/Basic/<ExampleName>/`
8+
- **Advanced Examples:** `APIExample-SwiftUI/APIExample-SwiftUI/Examples/Advanced/<ExampleName>/`
9+
10+
## File Composition
11+
12+
Each example typically contains:
13+
- SwiftUI View file
14+
- ViewModel (using `@ObservableObject`)
15+
- Video rendering view wrapper (`UIViewRepresentable`)
16+
17+
## SwiftUI-Specific Conventions
18+
19+
### ViewModel Pattern
20+
21+
```swift
22+
class <ExampleName>ViewModel: ObservableObject {
23+
private var agoraKit: AgoraRtcEngineKit?
24+
@Published var isJoined = false
25+
@Published var remoteUsers: [UInt] = []
26+
27+
func initializeEngine() { /* ... */ }
28+
func joinChannel() { /* ... */ }
29+
func leaveChannel() { /* ... */ }
30+
}
31+
```
32+
33+
### View Structure
34+
35+
```swift
36+
struct <ExampleName>View: View {
37+
@StateObject private var viewModel = <ExampleName>ViewModel()
38+
39+
var body: some View {
40+
// UI implementation
41+
}
42+
}
43+
```
44+
45+
### Video Rendering Wrapper
46+
47+
Use `UIViewRepresentable` to wrap UIKit's video rendering view:
48+
49+
```swift
50+
struct VideoViewRepresentable: UIViewRepresentable {
51+
let uid: UInt
52+
let agoraKit: AgoraRtcEngineKit?
53+
54+
func makeUIView(context: Context) -> UIView { /* ... */ }
55+
func updateUIView(_ uiView: UIView, context: Context) { /* ... */ }
56+
}
57+
```
58+
59+
## Menu Registration
60+
61+
Register example entry in SwiftUI's navigation structure.
62+
63+
## Detailed Conventions
64+
65+
(To be supplemented with complete SwiftUI platform conventions)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# iOS Platform API Example Conventions
2+
3+
This document describes the structure conventions for examples in the iOS APIExample project. Please follow these conventions when adding or modifying any examples under `APIExample/APIExample/Examples/`.
4+
5+
## Directory Structure
6+
7+
- **Basic Examples:** `APIExample/APIExample/Examples/Basic/<ExampleName>/`
8+
- **Advanced Examples:** `APIExample/APIExample/Examples/Advanced/<ExampleName>/`
9+
10+
The folder name is the **example identifier** (e.g., `VideoProcess`, `JoinChannelVideo`), using PascalCase without spaces.
11+
12+
The folder typically contains:
13+
14+
- One or more Swift files (e.g., `VideoProcess.swift`, `JoinChannelVideo.swift`), defining Entry and Main view controllers.
15+
- One storyboard: `Base.lproj/<ExampleName>.storyboard` (same name as identifier).
16+
17+
## Swift: Entry and Main
18+
19+
Each example contains two view controller roles:
20+
21+
### Entry (Entry Page)
22+
23+
- **Class Name:** `<ExampleName>Entry` (e.g., `VideoProcessEntry`, `JoinChannelVideoEntry`).
24+
- **Base Class:** `UIViewController`.
25+
- **Responsibilities:**
26+
- Provide channel name input field and "Join" button (or equivalent controls).
27+
- Optional: Collect resolution, frame rate, orientation, etc. (refer to `JoinChannelVideoEntry`).
28+
- In the "Join" button callback:
29+
- Read channel name (and any additional required parameters).
30+
- Load **same-named storyboard**: `UIStoryboard(name: identifier, bundle: nil)`, where `identifier = "<ExampleName>"`.
31+
- Instantiate Main VC: `storyBoard.instantiateViewController(withIdentifier: identifier) as? BaseViewController`.
32+
- Set `newViewController.configs`, at least including `"channelName"`, plus other keys needed by Main (e.g., `"resolution"`, `"fps"`, `"orientation"`).
33+
- Push Main VC: `navigationController?.pushViewController(newViewController, animated: true)`.
34+
35+
### Main (Example Main Logic)
36+
37+
- **Class Name:** `<ExampleName>Main`, or a single class name consistent with Main's identifier in storyboard (if no Main suffix, same as identifier).
38+
- **Base Class:** `BaseViewController`.
39+
- **Responsibilities:**
40+
- Read channel name etc. from `configs` (e.g., `configs["channelName"] as? String`) and options passed from Entry.
41+
- Create and configure `AgoraRtcEngineKit` (e.g., `KeyCenter.AppId`, `GlobalSettings.shared.area`), call `Util.configPrivatization(agoraKit:)` when needed.
42+
- Implement specific Agora API calls (join channel, toggle audio/video, etc.).
43+
- Conform to `AgoraRtcEngineDelegate` and other required protocols.
44+
45+
Reference: `JoinChannelVideo.swift` (Entry + Main), `VideoProcess.swift` (Entry + Main).
46+
47+
## Storyboard
48+
49+
- **File Path:** `APIExample/Examples/<Basic|Advanced>/<ExampleName>/Base.lproj/<ExampleName>.storyboard`.
50+
- **Two Scenes:**
51+
52+
1. **Entry Scene**
53+
- **Storyboard Identifier:** `EntryViewController`.
54+
- **Custom Class:** `<ExampleName>Entry`, Module: `APIExample`.
55+
- Connect channel input field and join button to Entry class (outlets and actions).
56+
57+
2. **Main Scene**
58+
- **Storyboard Identifier:** `<ExampleName>` (consistent with folder name, e.g., `VideoProcess`, `JoinChannelVideo`).
59+
- **Custom Class:** `<ExampleName>Main` (or actual Main class name used in code), Module: `APIExample`.
60+
- Layout example main interface and connect outlets/actions to this class.
61+
62+
- When entering from menu, **Entry is shown first**; after user clicks join, Main is instantiated and pushed in code.
63+
64+
## Menu Registration
65+
66+
- **File:** `APIExample/ViewController.swift`.
67+
- **Structure:** `menus` is an array of `MenuSection`, each section has `name` (e.g., `"Basic"`, `"Anvanced"`) and `rows: [MenuItem]`.
68+
69+
When adding an example:
70+
71+
- Append a `MenuItem` to the `rows` of the corresponding section.
72+
- **Field Description:**
73+
- `name`: Display name in list (can add `.localized` if project uses internationalization).
74+
- `storyboard`: Storyboard file name (**without** extension), consistent with example identifier, e.g., `"VideoProcess"`, `"JoinChannelVideo"`.
75+
- `entry`: Usually `"EntryViewController"` (default).
76+
- `controller`: Main VC's identifier or empty string `""`; since Entry pushes Main in this project, this is often `""` or consistent with Main's storyboard identifier.
77+
78+
Example:
79+
80+
```swift
81+
MenuItem(name: "Video Process".localized, storyboard: "VideoProcess", controller: "VideoProcess")
82+
```
83+
84+
If an example's Entry class or identifier is different (e.g., KtvCopyrightMusic), set `entry` and `controller` accordingly so the main `ViewController` loads the correct initial VC from that storyboard.
85+
86+
## Common Dependencies
87+
88+
- **App ID:** `KeyCenter.AppId`.
89+
- **Region / Role / Resolution / Frame Rate / Orientation:** `GlobalSettings.shared` (e.g., `GlobalSettings.shared.area`, `getSetting(key: "resolution")`, etc.).
90+
- **Logging:** `LogUtils`, call `agoraKit.setLogFile(LogUtils.sdkLogPath())` when needed.
91+
- **Privatization:** After creating engine, call `Util.configPrivatization(agoraKit: agoraKit)`.
92+
- **Video Layout:** Use `AGEVideoLayout`, `AGEVideoContainer` / `Bundle.loadVideoView` to display local/remote views.
93+
94+
Please keep naming and structure consistent with existing examples (e.g., `JoinChannelVideo`, `VideoProcess`) to maintain unified project style.

0 commit comments

Comments
 (0)