RoomKit
  • iOS : Objective-C
  • Android
  • macOS
  • Windows
  • Web
  • Overview
  • SDK downloads
  • Demo app
  • Sample codes
  • Quick starts
  • Advanced features
  • RoomKit Server APIs
  • Education Cloud Service APIs
  • Error codes
  • API Documents
  • FAQ

Integrate the RoomKit SDK

Last updated:2021-09-08 20:08

1 Set up the development environment

Make sure your development environment meets the following requirements:

  1. Xcode 6.0 or later.
  2. An iOS device running iOS 9.0 or later.
  3. The iOS device is connected to the Internet.

2 Integrate the SDK

2.1 Optional: Create a project

Skip this step if you are integrating the RoomKit SDK into an existing project.
  1. Launch Xcode, and click Create a new Xcode project in the Welcome to Xcode window. Alternatively, choose File > New > Project.

  2. In the sheet that appears, select the iOS platform, then select App under Application.

  3. In the sheet that appears, fill in the text fields and choose options from the pop-up menus to configure your project, then click Next.

    You must provide a Product Name and Organization Identifier because they are used to create the Bundle Identifier that identifies your app throughout the system.

  4. Choose a location to save your project, then click Create.

2.2 Import the SDK

  1. Download and unzip the latest version of the RoomKit SDK. For detailed download instructions, see RoomKit SDK downloads.

The SDK package you download from ZEGO's website contains the following two folders:

  • iphoneos: the .framework files in this folder should be used to build your project for real iOS devices only, which you should use for preparing your app for distribution.
  • iphonos_simulator: the .framework files in this folder can be used to build your project for real iOS devices and iOS simulators. If you use the .framework files in this folder for testing on iOS simulators, you must use the ones in the iphoneos folder when you prepare your app for distribution; otherwise, your app may get rejected by Apple.

Please choose the set of .framework files that fit your development needs.

  1. Copy the .framework files from the folder iphoneos or iphonos_simulator (as explained above ) into your project directory.

  2. Copy the file ZegoRoomKitResources.bundle into your project directory.

  3. In Xcode, select your app target, click General, then under Frameworks, Libraries, and Embedded Content, click the Add button (+) below the table to add the .framework files you copied in the previous step.

    /Pics/RoomKit/iOS/framework_add.png

  1. In Xcode, select your app target, click Build Phases, then under Copy Bundle Resources, click the Add button (+) below the table to add the ZegoRoomKitResources.bundle file.

    /Pics/RoomKit/iOS/copy_bundle.png

2.3 Configure the SDK

  1. In Xcode, select your app target, click General, then under Frameworks, Libraries, and Embedded Content, set Embed to Embed & Sign for the added .framework files.

    Xcode11Config the SDK

  2. In Xcode, select the RoomKit screen sharing extension target, click General, then under Framework and Libraries, set Embed to Do Not Embed for the .framework files as demonstrated below.

    copy_bundle

3 Add app permissions

Add app permissions as required.

  1. In Xcode, select your app target.

  2. Click Info, then under Custom iOS Target Properties, click the Add button (+) to add the permissions required for accessing the camera, microphone, and photos.

    • Privacy - Camera Usage Description

    • Privacy - Microphone Usage Description

    • Privacy - Photo Library Usage Description

    /Pics/RoomKit/iOS/en/request_authorization_en.png

4 Add Cocoapods libraries

The Cocoapods libraries listed below are also required. If you already imported some of them, you don't need to repeat them here.

  1. Set all the imported third-party libraries as dynamic libraries: use_frameworks!.

  2. If your project has imported YYKit's other libraries (e.g., YYModel, YYCache), remove those libraries and only use the YYKit as shown below.

platform :ios, '9.0'
use_frameworks!

target 'ZegoRoomkitDemo' do
pod 'Masonry', '1.1.0'
pod 'YYKit', '1.0.9'
pod 'LEEAlert', '1.4.2'
pod 'MBProgressHUD', '1.2.0'
pod 'ReactiveObjC', '3.1.1'
pod 'SSZipArchive', '2.2.2'
pod 'TXIMSDK_Smart_iOS', '5.1.138'

end

5 Other settings

5.1 Configure capabilities

  • App Groups

    If you want to use the screen sharing feature, you need to add an App Group for the data sharing between the main process and the screen sharing extension.

    1. In Xcode, select your app target, click Signing & Capabilities, then click + Capability.

    2. In the Capabilities library that appears, double-click the App Groups capability.

    3. In the Signing & Capabilities pane, click the Add button (+) under the App Groups section.

    4. In the dialog that appears, enter an App Group Container ID in the text field.

      roomkit_app_group

  • Background Modes

    Background modes allow your app to continue running in the background.

    1. In Xcode, select your app target, click Signing & Capabilities, then click the + Capability button.

    2. In the Capabilities library that appears, double-click the Background Modes capability.

    3. In the Signing & Capabilities pane, check the checkbox of the item Audio, AirPlay, and Picture in Picture under the Background Modes section.

      roomkit_background_modes

  • iCloud

    Users may select files stored on their iCloud drive for sharing, so you need to add the iCloud capability to your app target.

    1. In Xcode, select your app target, click Signing & Capabilities, then click + Capability.

    2. In the Capabilities library that appears, double-click the iCloud capability.

    3. In the Signing & Capabilities pane, check the checkboxes of the Key-value storage and iCloud Documents services under the iCloud section, then click the Add button (+) to add an iCloud Container.

      roomkit_icloud

  • Device Orientation

    You will also need to set up the supported screen orientations. Not doing so may result in app crashes.

    1. In Xcode, select your app target.

    2. Click General, then under Deployment Info, check the checkboxes for Device Orientation options Portrait and Landscape Right.

      roomkit_icloud

5.2 Create the screen sharing extension

  1. In Xcode, select File > New > Target, and select to create a Broadcast Upload Extension target.

    roomkit_screen_share_creat01

    Click Next, then in the window that appears, uncheck the option Include UI Extension.

    roomkit_screen_share_creat02

  2. Add the App Groups capability to the extension target. You must use the same App Group Container ID you used for the main app target.

  3. Import the RoomKit SDK as described in Section 2 above.

  4. Refer to RoomKit sample code for how to implement the screen sharing extension.

6 Common issues

  1. When archiving the app, the error Failed to verify bitcode in xxx.framework/xxx occurs.

This is because your Xcode version is too old. Upgrade it to the latest version if you could. If you have to use an old version of Xcode, you can do the follows to fix the issue:

  1. In Xcode, select your app target, select the Build Settings pane, then set the option Enable Bitcode to No.

  2. Start a Terminal window, run cd to go to the directory where the file xxx.framework is located, and run the following command to remove the bitcode from the SDK.

xcrun bitcode_strip .framework/xxx -r -o xxx.framework/xxx
  1. When running the app, the error Building for iOS Simulator, but the linked and embedded framework xxx.framework was built for iOS + iOS Simulator. occurs.

For Xcode 12.3 or later, using Frameworks built for iOS + iOS(Simulator) is not allowed. To fix the issue, you can select your app target, select the Build Settings pane, then set the option Validate Workspace to Yes.