You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Repository Overview
6
+
7
+
PubNub Swift Chat SDK - A Swift wrapper providing idiomatic iOS/macOS/tvOS APIs for real-time chat functionality. The SDK wraps the Kotlin Multiplatform (KMP) Chat SDK core via the `PubNubChat` dependency.
Configuration in `.swiftlint.yml` - line length 150, includes Sources/ and Tests/.
64
+
65
+
## Documentation Snippets
66
+
67
+
`Snippets/` contains compilable code examples used in PubNub documentation. These are validated during CI/CD to ensure customer-facing docs remain accurate.
68
+
69
+
**When modifying public APIs**, update corresponding snippets to prevent build failures.
70
+
71
+
## Architecture
72
+
73
+
### Dependency Chain
74
+
75
+
```
76
+
PubNubSwiftChatSDK (this repo)
77
+
└── PubNubChat (KMP compiled for Swift) - core implementation
78
+
└── PubNubSDK (Swift SDK) - low-level PubNub APIs
79
+
```
80
+
81
+
### Source Structure
82
+
83
+
-**`Sources/Chat/`** - Main entry point
84
+
-`Chat.swift` - Protocol defining all chat operations
-**`Sources/MessageDraft/`** - Message composition with mentions/references
93
+
94
+
-**`Sources/Extensions/`** - Type conversions between Swift and KMP types
95
+
96
+
-**`Sources/Models/`** - Data transfer objects (`Event`, `EventContent`, `File`, etc.)
97
+
98
+
### Key Patterns
99
+
100
+
1.**Protocol + Implementation**: Each entity has a public protocol (e.g., `Channel`) and internal implementation (e.g., `ChannelImpl`) that wraps the KMP type
101
+
102
+
2.**Dual API Surface**: All async operations have both:
3.**KMP Bridge**: `ChatImpl` creates the KMP core via `ChatImpl.createKMPChat()` and all entity implementations hold references to both the KMP object and the parent `ChatImpl`
107
+
108
+
4.**Stream Handling**: Real-time updates return `AutoCloseable` - callers must retain strong reference to continue receiving updates
109
+
110
+
### Entity Ownership
111
+
112
+
All entities hold a strong reference to `Chat`:
113
+
```swift
114
+
// ChannelImpl.swift
115
+
let chat: ChatImpl
116
+
let channel: PubNubChat.Channel_ // KMP type
117
+
```
118
+
119
+
## Test Structure
120
+
121
+
-`Tests/BaseIntegrationTestCase.swift` - Base class with `chat: ChatImpl` and helpers
122
+
-`Tests/AsyncAwait/BaseAsyncIntegrationTestCase.swift` - Async test base class
123
+
-`Tests/Common/IntegrationTestCaseConfiguration.swift` - Creates test `ChatImpl` instances
124
+
- Entity-specific tests: `ChannelIntegrationTests.swift`, `MessageIntegrationTests.swift`, etc.
125
+
126
+
## Dependencies
127
+
128
+
Defined in `Package.swift`:
129
+
-`PubNubChat` (kmp-chat) - KMP core, exact version pinned
130
+
-`PubNubSDK` (swift) - Low-level SDK, exact version pinned
0 commit comments