Tutorial
Mobile Development: Accelerate iOS and Android development with OpenClaw's AI assistance for Swift, Kotlin, React Native, and Flutter.
Setting Up for Mobile Development
# Initialize OpenClaw with mobile context
cd MyMobileApp
openclaw init --platform=mobile --framework=swift
# Add your mobile project
openclaw context add ./ios --label="ios-app"
openclaw context add ./android --label="android-app"iOS Development with Swift
SwiftUI Code Generation
# Generate SwiftUI views
openclaw chat "Create a SwiftUI view for a profile card with:
- Avatar image (circular)
- Name (bold, large font)
- Bio (multiline)
- Follow button
- Padding and corner radius styling"
# Combine with async/await
openclaw chat "Write a Swift async function to fetch user data from API:
URL: https://api.example.com/users/{id}
Include: error handling, decoding, and loading state"UIKit Assistance
# UITableView setup
openclaw chat "Create a UIKit ViewController with:
- UITableView delegate and dataSource
- Custom cell with title and subtitle
- Pull to refresh
- Diffable data source for performance"Core Data Helpers
# Generate Core Data stack
openclaw chat "Write Core Data code for:
- NSManagedObject model for 'Todo' entity (title, isCompleted, createdAt)
- NSPersistentContainer setup
- CRUD operations
- Fetch requests with predicates"Android Development with Kotlin
Jetpack Compose
# Compose UI generation
openclaw chat "Create a Jetpack Compose screen for:
- LazyColumn of items
- Each item: Card with image, title, description
- Click handling with navigation
- Material 3 theming"
# State management
openclaw chat "Implement a ViewModel with:
- StateFlow for UI state
- Repository pattern
- Coroutines for async operations
- Error handling"Traditional Android Views
# RecyclerView setup
openclaw chat "Create an Android app with:
- RecyclerView with ViewHolder pattern
- Adapter with DiffUtil
- ItemDecoration for spacing
- Click listener interface"React Native Development
# Component generation
openclaw chat "Create a React Native component:
- FlatList with data
- Pull to refresh
- ActivityIndicator loading state
- Navigation integration"
# Hooks
openclaw chat "Write a custom React Native hook:
- Fetch data from API
- Loading and error states
- Caching with AsyncStorage
- Auto-refresh on focus"Flutter Development
# Flutter widget generation
openclaw chat "Create a Flutter page with:
- Scaffold with AppBar
- ListView.builder for items
- Hero animations for detail navigation
- Provider for state management"
# Riverpod state management
openclaw chat "Implement Riverpod providers for:
- Data fetching from API
- Loading and error states
- AutoDispose for cleanup
- Family modifiers for parameterized providers"Cross-Platform Patterns
API Integration
# REST client setup
openclaw chat "Create a REST API client for [Swift/Kotlin/React Native/Flutter]:
- Base URL configuration
- GET/POST/PUT/DELETE methods
- Request/response interceptors
- Error handling with retry logic"Authentication
# Auth flow
openclaw chat "Implement OAuth 2.0 authentication:
- Login screen with email/password
- Token storage (Keychain/EncryptedSharedPreferences)
- Token refresh with retry
- Logout and cleanup"Offline Support
# Offline-first architecture
openclaw chat "Design an offline-first architecture:
- Local database (Core Data/Room/Realm)
- Background sync when online
- Conflict resolution strategy
- Network connectivity detection"Testing Mobile Apps
# Unit tests
openclaw chat "Write unit tests for this ViewModel:
- Test successful data loading
- Test error handling
- Test loading states
- Use MockWebServer for API mocking"
# UI tests
openclaw chat "Create UI tests for:
- Login screen input validation
- Successful login navigation
- Error message display
- Accessibility labels"Performance Optimization
# Image loading
openclaw chat "Optimize image loading in [platform]:
- Caching strategy
- Image resizing
- Progressive loading
- Memory management"
# List performance
openclaw chat "Optimize a [RecyclerView/FlatList/ListView] for:
- 1000+ items
- Smooth scrolling (60fps)
- DiffUtil/Lazy loading
- View recycling"Platform-Specific Tips
iOS Best Practices
- Use async/await for network operations
- Implement proper memory management (weak references)
- Follow Human Interface Guidelines
- Test on different device sizes
Android Best Practices
- Follow Material Design guidelines
- Handle configuration changes properly
- Use WorkManager for background tasks
- Test on different API levels