Mobile SDK/Library Development
SDK development differs from app development. Apps target end users; SDKs target developers integrating them into their projects. SDK public API errors cost dearly—after release, fixes mean breaking changes that break others' code.
Public API Design
First question: what's the minimum API surface that can't be removed? Everything else should be internal/private. Principle of least exposure is not optional.
Backward compatibility—the main contract. Semantic versioning: major version only for breaking changes. Adding methods to an interface is breaking for implementers. Instead of extending interfaces, add new ones or use default implementations (Swift protocol extensions, Kotlin interface defaults). Mark unstable APIs: @experimental in Kotlin, @available(*, deprecated) in Swift.
Kotlin SDK. Publish via Maven Central or GitHub Packages. build.gradle.kts with MavenPublication, sign via GPG (signing plugin), javadoc.jar mandatory for Maven Central. Artifact coordinates: com.example:sdk-name:1.0.0. For cross-platform SDKs—KMP publishing *-android, *-ios-arm64, *-ios-simulator-arm64 artifacts.
Swift/iOS SDK. Distribute via Swift Package Manager (preferred) or CocoaPods. SPM: Package.swift with explicit .supportedPlatforms, export via XCFramework if native C/Objective-C code exists. CocoaPods: .podspec with spec.vendored_frameworks or spec.source_files. Binary framework—via binaryTarget in SPM or spec.vendored_frameworks in podspec.
SDK binary size. Critical—nobody wants +5 MB added to their app. Strict dependency control: minimize transitive dependencies. If SDK needs networking—don't pull OkHttp or Alamofire, write against standard library (HttpURLConnection, URLSession). Exception: SDKs for specific ecosystems (Firebase SDK—Kotlin coroutines expected).
Key Technical Aspects
Thread safety. SDK called from foreign code—can't guarantee call order. All public API must be thread-safe or explicitly documented as "call from main thread only." Kotlin: @WorkerThread/@MainThread annotations + Lint rules. Swift: @MainActor for UI SDK components, actor for mutable state.
Lifecycle awareness. Android SDK holding Activity context = memory leak. Use WeakReference<Context> or ApplicationContext. iOS: similarly, weak references to delegates. If SDK registers system observers (NotificationCenter, BroadcastReceiver)—require explicit deinit/close() with documentation.
Configuration and initialization. Builder pattern instead of constructor with 10 parameters. Android: MySDK.Builder(context).apiKey("...").timeout(30).build(). Initialize in Application.onCreate(), not Activity. If SDK needs async init—provide callback and coroutine-compatible API (suspend fun initialize()).
Error handling. Sealed classes for results (Result<T, SDKError>), not bare exceptions. Document all possible SDKError values. Swift: enum SDKError: Error with LocalizedError. Don't connect Crashlytics or third-party crash reporters in SDK—that's the integrating app's responsibility.
Case study. Payment SDK for partner apps: Android (aar via Maven) + iOS (xcframework via SPM). Public API: PaymentSDK.present(from: UIViewController, amount: Decimal, completion: @escaping (PaymentResult) -> Void) on iOS and PaymentSDK.launch(activity, amount, callback) on Android. Inside: native UI (bottom sheet with card fields), encryption via AES-256-GCM, token sent to client backend. SDK size: 340 KB (iOS xcframework) and 280 KB (Android aar). Testing: unit tests with mock network layer, integration test project in same repo.
Documentation and Developer Experience
Auto-generate API Reference: Dokka for Kotlin, DocC for Swift. README with quickstart mandatory. Changelog in Keep a Changelog format. Sample app in repo as living integration example.
Lint rules and custom annotations for Android SDK via lint-api. Warn about incorrect usage at compile time, not runtime.
Timeline
| SDK Type | Estimated Timeline |
|---|---|
| Simple analytics SDK (events + sessions) | 4–6 weeks |
| UI SDK (custom components, screens) | 6–12 weeks |
| Payment / secure SDK | 3–5 months |
| KMP SDK (iOS + Android from single codebase) | 3–6 months |
Pricing calculated individually. When developing SDK, fix in advance: target platforms and OS versions, size requirements, versioning policy, and distribution format.







