Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions examples/chatapp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Changelog

All notable changes to the AG-UI-4K Chat App example will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- **Complete iOS implementation** of the chat app with feature parity to Android and Desktop versions
- iOS app structure with SwiftUI wrapper for Compose Multiplatform UI
- iOS-specific platform implementations:
- `IosPlatform.kt` with NSUserDefaults-based settings storage
- `MainViewController.kt` as the iOS app entry point using ComposeUIViewController
- iOS source set configuration with proper dependency hierarchy
- iOS-specific tests:
- `IosSettingsTest.kt` for NSUserDefaults persistence testing
- `IosUserIdManagerTest.kt` for iOS-specific UserIdManager functionality
- iOS app project (`iosApp/`) with:
- Xcode project configuration
- SwiftUI ContentView wrapping Kotlin Multiplatform UI
- iOS 15.0+ deployment target
- Framework integration with shared Kotlin code

### Changed
- **Replaced JVM-specific threading constructs** with Kotlin Multiplatform alternatives:
- Replaced `@Volatile` and `synchronized` with `kotlinx.atomicfu.atomic` for thread-safe singletons
- Updated `UserIdManager` and `AgentRepository` to use atomic operations
- **Fixed multiplatform compatibility issues**:
- Replaced `String.format()` with multiplatform-compatible string formatting in file size utility
- Removed `@TestOnly` annotation not available on iOS platforms
- **Enhanced ID generation** in `AgentConfig.generateId()` with random component to prevent duplicate IDs
- **Updated iOS deployment target** from 14.1 to 15.0 to match framework requirements
- **Improved string formatting** in `Extensions.kt` for cross-platform compatibility
- **Upgraded dependencies**:
- Gradle wrapper upgraded to 8.14
- Kotlin plugin upgraded to 2.2.0
- **Enhanced build configuration**:
- Added `org.gradle.console=plain` to reduce console formatting errors
- Fixed Gradle wrapper missing files
- Configured iOS source set hierarchy with proper target dependencies

### Fixed
- **Xcode build script path issues** - corrected gradlew path resolution in iOS build phases
- **Java runtime detection** - resolved JDK path issues in Xcode build environment
- **Threading compatibility** - eliminated JVM-specific concurrency constructs
- **Source set conflicts** - resolved duplicate platform implementations
- **Framework linking** - fixed Swift code integration with Kotlin framework
- **Build tool integration** - ensured proper Java/Gradle integration in Xcode environment

### Technical Details
- **Kotlin Multiplatform**: All three platforms (Android, Desktop, iOS) now share common business logic
- **Compose Multiplatform**: Unified UI framework across all platforms
- **Platform-specific storage**:
- Android: SharedPreferences
- Desktop: Java Preferences
- iOS: NSUserDefaults
- **Authentication**: Cross-platform auth provider system with API Key, Bearer Token, and Basic Auth support
- **Testing**: Comprehensive test suite covering all platforms with platform-specific test implementations

### Platform Support
- ✅ Android (API 26+)
- ✅ Desktop/JVM (Java 21+)
- ✅ iOS (15.0+) - **NEW**

### Developer Experience
- Complete iOS development workflow documentation
- Xcode project ready for iOS development
- Cross-platform testing suite
- Unified build system supporting all platforms
20 changes: 10 additions & 10 deletions examples/chatapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ The client follows a clean architecture pattern:

### Prerequisites

- JDK 11 or higher (JDK 21 recommended)
- JDK 21 or higher (required for building)
- Android Studio or IntelliJ IDEA with Compose Multiplatform plugin
- Xcode 14+ (for iOS development)
- Kotlin 2.1.21 or higher
- Kotlin 2.2.0 or higher

### Running the Client

#### Android
```bash
cd client
./gradlew :androidApp:installDebug
```

#### Desktop (JVM)
```bash
cd client
./gradlew :desktopApp:run
```

#### iOS
1. Open `chatApp/iosApp` in Xcode
2. Select your target device
3. Build and run
1. Open `chatapp/iosApp/iosApp.xcodeproj` in Xcode
2. Select your target device or simulator
3. Build and run (⌘+R)

**Note**: The iOS app requires the Kotlin framework to be built first. This happens automatically when building through Xcode.

## Usage

Expand Down Expand Up @@ -135,18 +135,18 @@ Agent configurations are stored using platform-specific preferences:

### Android
```bash
cd client
./gradlew :androidApp:assembleRelease
```

### Desktop
```bash
cd client
./gradlew :desktopApp:packageDistributionForCurrentOS
```

### iOS
Build through Xcode with your provisioning profiles.
1. Set up your development team in Xcode project settings
2. Configure code signing and provisioning profiles
3. Archive and distribute through Xcode (Product → Archive)

## Troubleshooting

Expand Down
9 changes: 9 additions & 0 deletions examples/chatapp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
plugins {
id("org.jetbrains.kotlinx.kover") version "0.7.6"

// Centralize plugin declarations with 'apply false'
kotlin("multiplatform") apply false
kotlin("android") apply false
kotlin("plugin.serialization") apply false
kotlin("plugin.compose") apply false
id("org.jetbrains.compose") apply false
id("com.android.application") apply false
id("com.android.library") apply false
}

allprojects {
Expand Down
8 changes: 5 additions & 3 deletions examples/chatapp/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.console=plain

# Kotlin
kotlin.code.style=official
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.enableCInteropCommonization=true
Expand All @@ -24,9 +26,9 @@ android.nonTransitiveRClass=true
xcodeproj=./iosApp

# K2 Compiler Settings
kotlin.compiler.version=2.1.21
kotlin.compiler.languageVersion=2.1
kotlin.compiler.apiVersion=2.1
kotlin.compiler.version=2.2.0
kotlin.compiler.languageVersion=2.2
kotlin.compiler.apiVersion=2.2
kotlin.compiler.k2=true

# Disable Kotlin Native bundling service
Expand Down
2 changes: 1 addition & 1 deletion examples/chatapp/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ core = "1.6.1"
core-ktx = "1.16.0"
junit = "4.13.2"
junit-version = "1.2.1"
kotlin = "2.1.21"
kotlin = "2.2.0"
#Downgrading to avoid an R8 error
ktor = "3.1.3"
kotlinx-serialization = "1.8.1"
Expand Down
4 changes: 2 additions & 2 deletions examples/chatapp/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Loading
Loading