Quick start
Prepare the environment
Before you attempt to integrate the SDK, make sure that the development environment meets the following requirements:
- Xcode 15.0 or higher version.
- iOS 12.0 or higher version and iOS devices that support audio and video.
- The iOS device is connected to the Internet.
Integrate the SDK
Add ZegoUIKitPrebuiltLiveStreaming as dependencies
- Open Terminal, navigate to your project's root directory, and run the following to create a
podfile
:Untitledpod init
1 - Edit the
Podfile
file to add the basic dependency:Untitledpod 'ZegoUIKitPrebuiltLiveStreaming'
1 - In Terminal, run the following to download all required dependencies and SDK with Cocoapods:
Untitled
pod install
1
Import ZegoUIKit & ZegoUIKitPrebuiltCall to your project
Untitled
import ZegoUIKit
import ZegoUIKitPrebuiltLiveStreaming
// YourViewController.swift
class MainViewController: UIViewController {
//Other code...
}
1
Using the ZegoUIKitPrebuiltLiveStreamingVC in your project
- Go to ZEGOCLOUD Admin Console, get the
appID
andappSign
of your project. - Specify the
userID
anduserName
for connecting the Live Streaming Kit service. liveID
represents the live streaming you want to start or watch (only supports single-host live streaming for now).
Note
userID
,userName
, andliveID
can only contain numbers, letters, and underlines (_).- Using the same
liveID
will enter the same live streaming.
Warning
With the same liveID
, only one user can enter the live stream as host. Other users need to enter the live stream as the audience.
Untitled
// YourViewController.swift
class MainViewController: UIViewController {
// Other code...
var userID: String = <#UserID#>
var userName: String = <#UserName#>
var liveID: String = <#liveID#>
func startLive() {
let config: ZegoUIKitPrebuiltLiveStreamingConfig = ZegoUIKitPrebuiltLiveStreamingConfig.host()
let liveVC: ZegoUIKitPrebuiltLiveStreamingVC = ZegoUIKitPrebuiltLiveStreamingVC(yourAppID, appSign: yourAppSign, userID: self.userID, userName: self.userName, liveID: self.liveID, config: config)
liveVC.modalPresentationStyle = .fullScreen
self.present(liveVC, animated: true, completion: nil)
}
func watchLive() {
let config: ZegoUIKitPrebuiltLiveStreamingConfig = ZegoUIKitPrebuiltLiveStreamingConfig.audience()
let liveVC: ZegoUIKitPrebuiltLiveStreamingVC = ZegoUIKitPrebuiltLiveStreamingVC(yourAppID, appSign: yourAppSign, userID: self.userID, userName: self.userName, liveID: self.liveID, config: config)
liveVC.modalPresentationStyle = .fullScreen
self.present(liveVC, animated: true, completion: nil)
}
}
1
Then, you can start live streaming by presenting the liveVC
.
Configure your project
Open the Info.plist
, add the following code inside the dict
part:
Untitled
<key>NSCameraUsageDescription</key>
<string>We require camera access to connect to a live</string>
<key>NSMicrophoneUsageDescription</key>
<string>We require microphone access to connect to a live</string>
1

Run & Test
Now you have finished all the steps!
You can simply click the Run in XCode to run and test your App on your device.
Resources
Sample code
Click here to get the complete sample code.