⌘K

LiveKit (iOS)

Nativeblocks provides hot-reloading and screen-sharing tools for developers

LiveKit is a powerful debugging and screen-sharing and hot-reloading utility for iOS applications.

Get started

Make sure that your project meets these requirements:

  • Uses Swift 5.0 or higher
  • Uses SwiftUI for UI development
  • Use iOS 15.0 or above
  • Initialized Nativeblocks Core SDK

Add LiveKit to your project by updating your Package.swift:

.package(url: "https://github.com/nativeblocks/nativeblocks-wandkit-ios-sdk.git", from: "1.0.0")

Let's get started by initializing the SDK, it can be inside of the onCreate's Activity or provide via dependency injection, but make sure liveKit calls after the Nativeblocks initialize

Add Required Permissions

Add the following keys to your Info.plist:

  • Camera Usage: NSCameraUsageDescription
  • Notifications: NSUserNotificationUsageDescription

Provide appropriate descriptions for these permissions to explain why they are required.

 import NativeblocksWandKit

 NativeblocksManager.getInstance().wandKit(LiveKit(
     screenSharing: true,
     screenShareExtention: "com.yourcompany.yourapp.LiveKitExtension",
     keepScreenOn: true
 ))

Debug builds config

Ensure LiveKit is only used in debug builds by wrapping the code with #if DEBUG:

#if DEBUG
NativeblocksManager.getInstance().wandKit(LiveKit(
    screenSharing: true,
    screenShareExtention: "com.yourcompany.yourapp.LiveKitExtension",
    keepScreenOn: true
))
#endif

Here is how to integrate LiveKit in a SwiftUI app:

import SwiftUI
import Nativeblocks
import NativeblocksWandKit

@main
struct SampleApp: App {

    init() {
        NativeblocksManager.initialize(
            ...
        )

        #if DEBUG
        let bundleId = Bundle.main.bundleIdentifier ?? ""
        NativeblocksManager.getInstance().wandKit(LiveKit(
            screenSharing: true,
            screenShareExtention: "\(bundleId).LiveKitExtension",
            keepScreenOn: true
        ))
        #endif
    }

    ...
}

Creating a Broadcast Upload Extension

To enable screen sharing, create a Broadcast Upload Extension in your Xcode project.

  1. Add a New Target

    • Go to File > New > Target.
    • Choose Broadcast Upload Extension.
    • Name it ScreenShareExtension.
  2. Update Extension Info.plist

    • NSMicrophoneUsageDescription: Required for screen sharing.
    • RPBroadcastProcessMode: Set to App.
  3. Implement SampleHandler

     import NativeblocksWandKit
     import ReplayKit
    
     class SampleHandler: LiveKitScreenSharingHandler {
    
         override func broadcastStarted(withSetupInfo setupInfo: [String: NSObject]?) {
             super.broadcastStarted(withSetupInfo: setupInfo)
         }
     }