Implementation sample for SourceSyncCoreSDK implementation with minimal external dependencied.
Technologies used:
- Swift
- SwiftUI
- Swift Combine
- Xcode 16.0+
- iOS 17.6+
To be able to run this project:
- fetch current Git repository
- run SourceSyncIntegration target
This class is a singleton facade for interactions with SourceSyncSDK, every call to SDK must be inside it. This class is responsible for error handling and providing readable results to the screen that will be using it.
Public API:
func initialize(depth: Int = 0) async -> SourceSyncInitializationStatus- method initializesPlatformApp, logs errors and provides initialization status. Possible results are:none- SDK is not initializedsuccess- SDK is initialized successfullyinProgress- initialization in progressfailed(Error)- successfully failed with specific error
func initContent(mediaId: String) async -> SourceSyncResult<Content>- creates instance of a Content using provided mediaId Possible results are:success(Content)- Content created successfullyfailure(Error)- Content is not available, failed with specific error
func fetchActivations(content: Content, currentTimeMs: Int64, timeWindowMs: Int64) async -> SourceSyncResult<[Activation]>- get activations for specific time and time window Possible results are:success([Activation])- Activations fetched successfullyfailure(Error)- Activations are not available, failed with specific error
func close()- cleanup resources
func submitVideoData()- creates new content from provided data in Media URL field and Media IDfunc observeProgress()- start to observe video player progress to be able to check for activations in real timefunc stopObservingProgress()- unsubscribe from player progress updatesfunc createDataSubject() -> any Subject<(Int64, Content), Error>- creates subject that fetches activations and updates ui accordingly
Logger implemented using basic interface LoggerImpl, that can be changed at any time to different analytic providers.
To be able to use Firebase for example you would need to create FirebaseLoggerImpl and provide this implementation to Logger.setActiveLogger and all logging would be automatically redirected to Firebase.
SystemLogger created For demonstration purposes and provides logging to standard system output.
Every method within PreviewViewModel and SourceSyncSDKInteractor emit logs through logging system.
struct LogEvent {
let eventName: String
let message: String
let date: Date = Date()
}
protocol LoggerImpl {
func logEvent(_ event: LogEvent)
func logError(_ error: Error)
}Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-10-27.at.17.17.49.mov
- SDK package is missing Packages.swift file which would allow the SDK to be imported via Swift Package Manager.
- Cocoapods is deprecated, so instead of using cocoa pods I decided to import package directly via framework attachment to xcode project.
- After trying to initialise SDK with disabled network/internet - Unavoidable crash from client side. There’s no way to handle such an error due to standard error: Exception doesn't match @Throws-specified class list and thus isn't propagated from Kotlin to Objective-C/Swift as NSError. It is considered unexpected and unhandled instead. Program will be terminated.
- Unexpected crashes while calling fetchActivations during seeking to different parts of the video - Tame:kfun:io.sourcesync.sdk.util.StaticIntervalTree# intervalsOverlappingInterval (1:0;io.sourcesync.sdk.util.StaticIntervalTree. SearchOptions) {} kotlin.collections.List<1:0>. The file path does not exist on the file system: /Users/runner/work/kmp-sourcesync-sdk-core/kmp-sourcesync-sdk-core/coreSdk/src/commonMain/kotlin/util/StaticIntervalTree.kt
- Context creation process is not straightforward, no understanding of why you should use it and how.
- A lot of unused parameters for Content instance construction, it is better to provide different constructors for different media types - URL, MediaID etc..
- Expose all SDK methods and instance creation through SDK Facade pattern, so usage of the SDK would be intuitive. For example - create single instance of
SourceSyncCore, from which developers would call:SourceSyncCore.createMediaIdContent(...)SourceSyncCore.createUrlContent(...)SourceSyncCore.fetchActivations(...)SourceSyncCore.logEvent(...)
- Analytics available only through the single vendor with non-universal interface, it’s a good practice to expose analytics logger as interface, so client can provide his own tracking service. From the SDK side will be provided basic implementations for supported Analytic providers such as Firebase, Amplitude, OneSignal.
- After application initialization, there’s no need to pass instance of this app to other classes, it should be saved inside the sdk, since as far as I understood it is expected to have only one Application to be active.
- It is better to move initialization process and error handling inside the SDK, to make integration straightforward for developers

