Example Source Code Running Guide
This example source code supports iOS and macOS platforms.
Since this example source code uses SwiftUI to build the interface, the requirements for the development environment are relatively high. For the actual environmental requirements of ZegoExpress SDK, please refer to Quick Start - Integrate SDK.
Prepare Environment
Please ensure that the development environment for running the example source code meets the following requirements:
- Xcode 15.0 or above.
- iOS 14.0 or above with iOS devices or simulators that support audio and video (real devices are recommended).
- macOS 11.0 or above.
- iOS devices are already connected to the Internet.
Prerequisites
You have created a project in ZEGOCLOUD Console and applied for a valid AppID and AppSign.
The SDK also supports Token authentication. If you need to upgrade the authentication method, please refer to How to upgrade from AppSign authentication to Token authentication.
Get Example Source Code
Local Download
Example Source Code Directory Structure
The following structure is the file structure of the apple_swift subdirectory. The file paths mentioned below are all relative to this directory.
.
├─ .gitignore
├─ DownloadSDK.sh
├─ README.md
├─ README_zh.md
├─ Shared
│ ├─ Assets.xcassets
│ ├─ Deps
│ ├─ Helper
│ ├─ HomePage # Home page
│ ├─ KeyCenter.swift # Fill in the applied AppID and AppSign
│ ├─ SampleCode.xcconfig
│ ├─ SupportingViews
│ ├─ Topics # Pages corresponding to various functional modules on the interface
│ │ ├─ PlayStream
│ │ ├─ PublishStream
│ │ ├─ QuickStart
│ │ ├─ SoundLevel
│ │ └─ VideoTalk
│ └─ ZegoExpressExampleApp.swift
├─ Tests Shared
│ ├─ TestEngineModule.swift
│ └─ TestRoomModule.swift
├─ Tests iOS
│ ├─ Info.plist
│ └─ Tests_iOS.swift
├─ Tests macOS
│ ├─ Info.plist
│ └─ Tests_macOS.swift
├─ VERSION.txt
├─ ZegoExpressExample.xcodeproj # swift project file
├─ iOS
│ ├─ Info.plist
│ ├─ Libs # Directory for ZegoExpressVideo iOS SDK
│ ├─ README.md
│ └─ iOS.entitlements
└─ macOS
├─ Info.plist
├─ Libs # Directory for ZegoExpressVideo Mac SDK
├─ README.md
└─ macOS.entitlementsRun Example Source Code
-
Open App Store, search for Xcode and download to install.

-
Use Xcode to open the "ZegoExpressExample.xcodeproj" file.
a. Open Xcode and select "File > Open..." in the upper left corner.

b. Select the "ZegoExpressExample.xcodeproj" file in the unzipped example source code folder and click "Open".

-
Log in to your Apple ID account.
a. Select "Xcode > Preference" in the upper left corner of Xcode.
b. Click the "Account" tab, then click the "+" sign in the lower left corner, select to add "Apple ID" and click "Continue".

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

-
Modify the developer certificate.
a. Click the "ZegoExpressExample" project on the left side in Xcode.

b. Click the "Signing & Capabilities" tab and select your developer certificate in "Team".
NotesThis example source code adaptively obtains TeamID as the suffix of Bundle Identifier, and developers do not need to modify it manually.

-
The downloaded example source code lacks the AppID and AppSign required for SDK initialization. You need to modify the "KeyCenter.swift" file in the "Shared" directory. Please use the AppID and AppSign obtained in the Prerequisites of this article to fill in correctly, otherwise the example source code cannot run normally.
-
Connect the iOS device to the development computer, click "Generic iOS Device" in the upper left corner of Xcode, and select the iOS device (or simulator).
NotesYou can also switch to the "Target" of macOS and select "MyMac" to run the macOS example source code.


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

Experience Real-time Audio and Video Functions
Run the project on a real device. After successful operation, you can see the local video screen.
For convenience, ZEGO provides a Web platform for debugging. On this page, enter the same AppID and RoomID, enter different UserIDs, and the corresponding Token, you can join the same Room and communicate with the real device. When the audio and video call starts successfully, you can hear the remote audio and see the remote video screen.
