Live Streaming
  • iOS : Objective-C
  • Android
  • Web
  • Flutter
  • React Native
  • Electron
  • Unity3D
  • Windows
  • macOS
  • Linux
  • Overview
  • Live Streaming vs. Interactive Live Streaming
  • Develop your app
    • Live Streaming
      • Integrate the SDK
      • Implement a basic live streaming
      • Enhance basic livestream
      • CDN
      • Play live streams
    • Interactive Live Streaming
  • Upgrade the livestream
    • Advanced features
      • Media push
        • Mix the live streams
      • Enhance the livestream
        • Share the screen
        • Improve your appearance in the livestream
        • Beautify & Change the voice
        • Output the livestream in H.265
        • Watermark the live/Take snapshots
        • Config video codec
        • Visualize the sound level
      • Message signaling
        • Convey extra information using SEI
        • Broadcast real-time messages to a room
        • Quotas and limits
      • Ensure livestream quality
        • Test network and devices in advance
        • Check the room connection status
        • Monitor streaming quality
        • Configure bandwidth management
      • Play media files
        • Play media files
        • Play sound effects
      • Record video media data
      • Join multiple rooms
      • Publish multiple live streams
      • Low-latency live streaming
      • Use the bit mask
      • Common audio config
      • Playing streams via URL
    • Distincitve features
      • Set the voice hearing range
      • Single stream transcoding
      • Low-light enhancement
      • Customize the video and audio
  • Upgrade using Add-on
  • Resources & Reference
    • SDK
    • Sample code
    • API reference
      • Client APIs
      • Server APIs
    • Debugging
      • Error codes
    • FAQs
    • Key concepts
  • Documentation
  • Live Streaming
  • Resources & Reference
  • Sample code
Sample code
Download

Sample source code running guide

This article describes how to quickly run the sample source code and experience basic audio and video calling services.

1 Prepare the environment

Before you run the sample source code, make sure that the development environment meets the following requirements:

  • Xcode 13.0 or above.
  • iOS devices or simulators with iOS 9.0 or above that support audio and video (real devices are recommended).
  • The iOS device is connected to the Internet.

2 Prerequisites

Go to ZEGOCLOUD Admin Console to create a new project, and get the AppID and AppSign of your project.

The SDK now also supports using Token for authentication, if you want to change your authentication mode, refer to the Guide for upgrading the authentication mode from using the AppSign to Token.

3 Sample source code directory structure

The following directory structure is the file structure of the ios_objc subdirectory, and the file paths mentioned below are all relative to this directory.

.
├─ DownloadSDK.sh
├─ Libs # ZegoExpressVideo iOS SDK storage directory
├─ README.md
├─ README_zh.md
├─ VERSION.txt
├─ ZegoExpressExample
|    ...
│    ├─ Examples 
│    │    ├─ AdvancedAudioProcessing   # Advanced audio features
│    │    ├─ AdvancedStreaming         # Advanced stream publish and play
│    │    ├─ AdvancedVideoProcessing   # Advanced video features
│    │    ├─ CommonFeatures            # Common functions
│    │    ├─ Debug&Config              # Debug and configure
│    │    ├─ Others                    # Other functions
│    │    ├─ QuickStart                # Quick start
│    │    └─ Scenes                    # Best practices
|    ...
│    ├─ Info.plist
│    ├─ KeyCenter.h
│    ├─ KeyCenter.m # Fill in the AppID and AppSign of the application
│    ...
└─ ZegoExpressExample.xcodeproj  # Demo engineering documents

4 Run the sample source code

  1. Open AppStore, search for "Xcode", and download and install it.

  2. Open the ZegoExpressExample.xcodeproj file by using Xcode.

  3. Open Xcode and select File > Open... in the upper-left corner.

  4. In the decompressed sample source code folder, select the ZegoExpressExample.xcodeproj file and open it.

  5. Log in to your Apple developer account.

  6. Open Xcode and select Xcode > Preferences... in the upper-left corner.

    /Pics/iOS/ZegoExpressEngine/Common/xcode_preferences.png

  7. Click the Accounts tab, click the plus (+) icon in the lower-left corner, select Add Apple ID, and click Continue.

  8. Enter your Apple ID and password to log in.

  9. Modify the Bundle identifier and developer certificate.

  10. Open Xcode and click the "ZegoExpressExample" project on the left.

  11. Open the TARGETS option. Developers can click the General tab to modify the Bundle identifier of the project based on their needs and click the Signing & Capabilities tab to select the developer certificate.

    /Pics/iOS/ZegoExpressEngine/Common/bundle_id.png
    /Pics/iOS/ZegoExpressEngine/Common/team_signing_new.png

  12. The AppID and AppSign required for SDK initialization are missing in the sample source code, and the /ZegoExpressExample/KeyCenter.m file needs to be modified. Please use the AppID and AppSign mentioned in the Prerequisites to fill in the information correctly. Otherwise, the example source code cannot run properly.

/Pics/QuickStart/sample_code/sample_code_ios.png

  1. Connect the iOS device to the development computer, click Any iOS Device on Xcode, and select the iOS device or simulator in the pop-up window.

    /Pics/iOS/ZegoExpressEngine/Common/xcode_select_device_new.png
    /Pics/iOS/ZegoExpressEngine/Common/xcode_select_real_device_new.png

  2. Click Build in the upper-left corner of Xcode to compile and run the sample source code.

    /Pics/iOS/ZegoExpressEngine/Common/build_and_run_new.png

5 Experience audio and video calling/live streaming function

We recommend you run your project on a real device. If your app runs successfully, you should hear the sound and see the video captured locally from your device.

To test out the real-time audio and video features, visit the ZEGO Express Web Demo, and enter the same AppID, Server and RoomID to join the same room. If it runs successfully, you should be able to view the video from both the local side and the remote side, and hear the sound from both sides as well.

In audio-only scenarios, no video will be captured and displayed.

Page Directory