How To Use Live Stream SDK iOS Build App
Tags: ios, swift, sdk, programming
Published: 2022-09-30 03:48:44

More and more companies have launched their own **iOS live stream SDK**, which shows the rapid development trend of the live streaming market.

According to [eMarketer forecasts](https://www.insiderintelligence.com/content/apac-dominates-in-mobile-phone-video-viewership), 2.72 billion people will watch videos on their mobile phones in 2023. That's up from 2.16 billion in 2019. This represents a compound annual growth rate (CAGR) of 6%—higher than the 4.5% CAGR for worldwide digital video viewers.

## What features do you need for live streaming
With the continuous development of the live streaming industry, live streaming has been divided into several sub-industries.

such as game live streaming, education live streaming, live streaming with goods, and live streaming of entertainment.
Different live streaming industries require different functions.

Basic function:
- Room management
- Audio and video push-pull stream management
- Device management
- Member management
- Barrage

Special function:
- Screen sharing
- shopping cart
- Gift effects
- Host PK
- Make co-hosts

A complete live streaming application is a complex system. Most enterprises will use the **live stream SDK for iOS** to quickly build a live broadcast platform and occupy the live streaming market.

## What support is provided by the live streaming SDK
The development of live streaming SDK is also developing in a simple and convenient direction, from providing the underlying audio and video transmission capability to a complete live streaming solution, to the current componentized solution.
It can not only meet the requirements of customers for rapid construction but also meet the various personalized needs of customers.

ZEGOCLOUD's latest ios live stream SDK - [Live Streaming Kit](https://www.zegocloud.com/uikits?_source=dev&article=33). It is a componentized solution. The SDK encapsulates the live streaming function into an independent component and provides rich UI custom interfaces. Users select components according to their own needs and customize the UI.

## How to build an app with live streaming SDK
Next, I will use the **live video streaming iOS SDK** to demonstrate how to quickly build a live video streaming app.

### Add ZegoUIKitPrebuiltLiveStreaming as dependencies

Integrate ZegoUIKitPrebuiltLiveStreaming SDK through the pod as follows, add pod 'ZegoUIKitPrebuiltLiveStreaming' in Podfile file. Then execute the command `pod install` in Terminal. For detailed operation, please refer to [Quick Access Documentation](https://docs.zegocloud.com/article/14868).


```ruby
target 'ZegoCallDemo' do
  use_frameworks!
 
  # Pods for ZegoCallDemo
  pod 'ZegoUIKitPrebuiltLiveStreaming'
 
end
```
### Import ZegoUIKitSDK & ZegoUIKitPrebuiltCall to your project

In the file that needs to be called the SDK interface, import the SDK through import.

```swift
import ZegoUIKitSDK
import ZegoUIKitPrebuiltLiveStreaming
// YourViewController.swift
class MainViewController: UIViewController {
    //Other code...
}
```


### Using the ZegoUIKitPrebuiltLiveStreamingVC in your project

- Go to [ZEGOCLOUD Admin Console](https://console.zegocloud.com?_source=dev&article=33), get the `appID` and `appSign` of your project.
- Specify the `userID` and `userName` 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). 

```swift
// 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(kPresetRoleHost)
        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(kPresetRoleAudience)
      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)
}

}
```

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:

```plist
<key>NSCameraUsageDescription</key>
<string>We require camera access to connect to a call</string>
<key>NSMicrophoneUsageDescription</key>
<string>We require microphone access to connect to a call</string>
```
![video-sdk](https://resource.zegocloud.com/content_resource/2022/09/30/videosdk.jpg)


## Run the demo

{% embed https://www.youtube.com/watch?v=TXoIJXTGjEA %}

---

[Sign up](https://console.zegocloud.com/account/signup?_source=dev&article=33) with ZEGOCLOUD, and get **10,000 minutes** free every month.

## Did you know? 👏

> **Like** and **Follow** is the biggest encouragement to me
> **Follow me** to learn more technical knowledge
> Thank you for reading :)

## Learn more

This is one of the live technical articles. Welcome to other articles:
{% embed https://dev.to/zegocloud/video-sdk-for-easier-integration-1p7g %}

{% embed https://dev.to/zegocloud/how-to-choose-android-voice-chat-sdk-1ojf %}

{% embed https://dev.to/zegocloud/how-to-create-avatar-from-photo-57oa %}

{% embed https://dev.to/zegocloud/how-to-build-a-live-streaming-app-81a %}