iOS SDK Documentation

📦 Version 2.4.1 📅 Last updated: Nov 2025 ⏱️ 12 min read

Overview

The ConnectHub iOS SDK provides a comprehensive, type-safe Swift interface for integrating ConnectHub's social features directly into your native applications. Build authenticated feeds, real-time messaging, content sharing, and analytics with minimal boilerplate.

💡
Pro Tip

This SDK is designed for Swift concurrency. Use async/await throughout your codebase for the best developer experience and performance.

Requirements

Component Minimum Version Recommended
iOS SDK 15.0 17.0+
Xcode 14.0 15.2+
Swift 5.5 5.9+
Architecture arm64, x86_64 (sim) arm64 only (production)

Installation

Choose your preferred dependency manager. We recommend Swift Package Manager for modern Xcode projects.

Swift Package Manager

Xcode 14+
File → Add Package Dependencies... Repository: https://github.com/connecthub/ios-sdk.git Version: 2.4.1

CocoaPods

Podfile
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '15.0' target 'YourApp' do use_frameworks! pod 'ConnectHubSDK', '~> 2.4' end

Carthage

Cartfile
github "connecthub/ios-sdk" ~> 2.4.1

Quick Start

Get up and running in under 5 minutes. Follow these three steps to initialize the SDK and make your first API call.

1. Initialize the SDK

Add this to your AppDelegate or @main App struct:

Swift
import ConnectHubSDK // Initialize in AppDelegate.swift or App.swift ConnectHub.initialize( appId: "your_app_id", environment: .sandbox, // Switch to .production for App Store debug: true // Enable verbose logging during development )

2. Authenticate a User

Swift
let auth = ConnectHub.auth // Server-side generated token recommended for production do { try await auth.login(token: "server_generated_jwt") print("✅ User logged in: \(auth.currentUser?.id)") } catch { print("❌ Auth failed: \(error.localizedDescription)") }

3. Fetch the Home Feed

Swift
let feed = ConnectHub.feed let posts = try await feed.fetch( type: .home, limit: 20, cursor: nil ) // Display posts in your UICollectionView self.posts = posts.items self.nextCursor = posts.nextCursor
⚠️
Important

Never expose your server-side API keys or client secrets in iOS code. Use secure token exchange via your backend.

Configuration

Customize SDK behavior using the ConnectHubConfig singleton. Available options:

Property Type Description Default
timeout TimeInterval Network request timeout 30.0
maxRetries Int Automatic retry attempts 3
cachePolicy CachePolicy Response caching strategy .returnCacheThenLoad
analyticsEnabled Bool Opt-in telemetry collection true
logLevel LogLevel Debug verbosity .warning
Swift
ConnectHub.config = ConnectHubConfig( timeout: 15.0, maxRetries: 2, cachePolicy: .returnCacheThenLoad, logLevel: .debug, analyticsEnabled: true )

API Reference Highlights

Explore the most commonly used modules. Full documentation is generated via SwiftDocC and available in Xcode.

Authentication

  • login(token:) - Authenticate with server JWT
  • logout() - Clear session & local cache
  • currentUser - Access current session data
  • onAuthStateChanged - Observe session transitions

Content & Feed

  • fetch(type:limit:cursor:) - Paginated feed loading
  • create(post:) - Publish media/text content
  • update(postId:modifications:) - Edit existing posts
  • like(postId:)` / `unlike(postId:) - Engagement actions

Messaging

  • openChat(userId:) - Launch 1:1 conversation
  • sendMessage(text:attachments:) - Send rich messages
  • listenToMessages(chatId:)` - Real-time stream
🚫
Breaking Change in v2.4

Callback-based APIs have been deprecated. All asynchronous operations now use async/await. Update legacy code to avoid build warnings.

Support & Community

Need help? We're here to ensure your integration is smooth.

  • 📖 Full API Reference: Available directly in Xcode via SwiftDocC
  • 💬 Developer Community: Join our Discord for real-time Q&A
  • 🐛 Report Issues: File a bug on GitHub Issues
  • 📧 Enterprise Support: support@connecthub.dev

Ready to integrate?

Get your API credentials from the ConnectHub Dashboard

Open Dashboard →