WandKit
WandKit is a powerful framework designed to enhance your development experience with features such as screen sharing, debugging tools, and seamless integration with Nativeblocks Studio. This document provides a comprehensive guide to installing, configuring, and utilizing WandKit and its components, including LiveKit and LiveKitScreenSharingHandler.
Get started
Requirements
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
Install WandKit
Add WandKit to your project by updating your Package.swift:
.package(url: "https://github.com/nativeblocks/nativeblocks-wandkit-ios-sdk.git", from: "1.0.0")
LiveKit
LiveKit is a component of the WandKit framework that provides functionalities such as screen sharing, keeping the screen active, and auto-connecting to the environment. It is specifically designed to work with the Nativeblocks Studio environment.
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: false,
screenShareExtention: "com.yourcompany.yourapp.LiveKitExtension",
keepScreenOn: true,
autoConnect: 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())
#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.
-
Add a New Target
- Go to File > New > Target.
- Choose Broadcast Upload Extension.
- Name it ScreenShareExtension.
-
Update Extension Info.plist
- NSMicrophoneUsageDescription: Required for screen sharing.
- RPBroadcastProcessMode: Set to App.
-
Implement SampleHandler
import NativeblocksWandKit import ReplayKit class SampleHandler: LiveKitScreenSharingHandler { override func broadcastStarted(withSetupInfo setupInfo: [String: NSObject]?) { super.broadcastStarted(withSetupInfo: setupInfo) } }