Reachu Swift SDK
A modular Swift SDK for iOS(iPhone & iPad) to manage shopping carts, checkouts, discounts, markets, channels and paymentsusing GraphQL. Built with modern SwiftUI components and designed for scalability and performance.
Why Choose Swift + SwiftUI?
- Native iOS Performance: Compiled to native code optimized specifically for iPhone and iPad
- Modular Architecture: Import only the components you need for smaller app sizes
- Modern SwiftUI: Beautiful, declarative UI components with built-in iOS accessibility
- Type Safety: Leverage Swift's strong type system for reliable ecommerce operations
- Full iOS Support: Works seamlessly on iPhone and iPad with adaptive layouts
- Automatic Payments: Stripe and Klarna configured automatically - zero setup required!
Modular Architecture
The Swift SDK is designed with a modular approach that allows you to import only what you need:
Core Modules - ReachuCore (Required) → Essential ecommerce functionality, models, and business logic
- ReachuNetwork (Internal) → Shared networking layer with Apollo GraphQL client
UI Modules - ReachuUI (Optional) → SwiftUI components for ecommerce interfaces
- ReachuDesignSystem (Internal) → Design tokens, colors, typography, and base components
Live Shopping Modules - ReachuLiveShow (Optional) → Real-time livestream shopping features
- ReachuLiveUI (Optional) → SwiftUI components for livestream interfaces
Development Modules - ReachuTesting (Internal) → Mock data providers and testing utilities
Quick Installation
Add the Reachu Swift SDK to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/ReachuDevteam/ReachuSwiftSDK.git", from: "1.0.0")
]
Choose Your Modules
Import only what you need to keep your app size minimal:
targets: [
.target(
name: "YourApp",
dependencies: [
// Core functionality only
.product(name: "ReachuCore", package: "ReachuSwiftSDK"),
// Core + UI Components
.product(name: "ReachuUI", package: "ReachuSwiftSDK"),
// Core + LiveShow
.product(name: "ReachuLiveShow", package: "ReachuSwiftSDK"),
// Everything included
.product(name: "ReachuComplete", package: "ReachuSwiftSDK"),
]
),
]
Basic Usage
import SwiftUI
import ReachuCore
import ReachuUI
struct ContentView: View {
@StateObject private var cartManager = CartManager()
var body: some View {
NavigationView {
ScrollView {
// Display products with built-in UI components
LazyVGrid(columns: [
GridItem(.flexible()),
GridItem(.flexible())
]) {
ForEach(products) { product in
RProductCard(
product: product,
variant: .grid,
onAddToCart: {
cartManager.addToCart(product)
}
)
}
}
}
.navigationTitle("Products")
}
}
}
SwiftUI Components
The Swift SDK includes beautiful, ready-to-use SwiftUI components:
Product Components - RProductCard → Flexible product cards with 4 layout variants (grid, list, hero, minimal)
RProductSlider→ Horizontal scrolling product galleries with 6 layout optionsRProductImageView→ Advanced image loading with placeholders and error states
Cart & Checkout Components - CartManager → Global cart state management with reactive updates
RCheckoutOverlay→ Complete checkout flow as modal overlayRProductDetailOverlay→ Full-screen product detail modal with galleryRFloatingCartIndicator→ Persistent cart indicator across all screensRToastNotification→ Elegant notification system with auto-dismiss
Enhanced UX Features - Automatic Animations → Button feedback, product highlighting, spring transitions
- Haptic Feedback → Tactile confirmation on iOS devices (light, medium, heavy)
- Auto-Notifications → Smart toasts for cart operations with product names
- Visual Feedback → Loading states, success indicators, error handling
Design System - RButton → Consistent buttons with multiple styles and sizes
ReachuColors→ Unified color palette for brand consistencyReachuTypography→ Typography scale for proper text hierarchyReachuSpacing→ Consistent spacing tokens for layouts
Documentation Structure
Module Examples
Core Module Usage
import ReachuCore
class CartManager: ObservableObject {
private let sdk = ReachuSDK.shared
@Published var cart: Cart?
func createCart() async {
do {
self.cart = try await sdk.cart.create(
customerSessionId: "session-123",
currency: "USD"
)
} catch {
print("Failed to create cart: \(error)")
}
}
}
UI Components Usage
import SwiftUI
import ReachuUI
struct ProductView: View {
let product: Product
var body: some View {
VStack(spacing: ReachuSpacing.lg) {
// Different layout variants
RProductCard(product: product, variant: .hero, showDescription: true)
RProductCard(product: product, variant: .grid)
RProductCard(product: product, variant: .list)
RProductCard(product: product, variant: .minimal)
}
.padding(ReachuSpacing.lg)
}
}
Design System Usage
import SwiftUI
import ReachuDesignSystem
struct CustomView: View {
var body: some View {
VStack(spacing: ReachuSpacing.md) {
Text("Welcome to Reachu")
.font(ReachuTypography.largeTitle)
.foregroundColor(ReachuColors.primary)
RButton(
title: "Add to Cart",
style: .primary,
size: .large
) {
// Handle action
}
}
.padding(ReachuSpacing.lg)
.background(ReachuColors.surface)
.cornerRadius(ReachuBorderRadius.large)
}
}
Recommended Setup
For production apps, initialize the SDK in your main App struct:
import SwiftUI
import ReachuCore
import ReachuUI
@main
struct MyApp: App {
@StateObject private var cartManager = CartManager()
@StateObject private var checkoutDraft = CheckoutDraft()
init() {
// Load configuration from reachu-config.json
// Automatically initializes Stripe payments
ConfigurationLoader.loadConfiguration()
}
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(cartManager)
.environmentObject(checkoutDraft)
}
}
}
What this does: - Loads theme, colors, and settings from reachu-config.json
- Initializes Stripe payments automatically
- Sets up CartManager for global cart state
- Configures CheckoutDraft for address normalization
- Makes managers available to all views via @EnvironmentObject
**That's all the setup you need!**The SDK handles the rest.
Platform Support
| Platform | Version | Status |
|---|---|---|
| iOS | 15.0+ | Fully Supported |
| iPhone | All models | Optimized |
| iPad | All models | Adaptive layouts |
We're currently focused on delivering the best iOS experience. Support for macOS, tvOS, and watchOS may be added in future releases based on community demand.
Useful Links
- GitHub Repository - Source code and issues
- Getting Started Guide - Step-by-step setup
- UI Components - SwiftUI component library
- API Reference - Complete method documentation
- Support - Technical support
License
This project is licensed under the MIT License - see the LICENSE file for details.