RoomKit
  • Platform
  • Framework / Engine
  • iOS
  • Android
  • macOS
  • Windows
  • Linux
  • Web
  • WeChat Mini Program

Integrate the RoomKit SDK

Update Time:2021-04-25 20:24

1 Prepare the Development Environment

Please ensure your development environment meets the following requirements:

  1. Xcode 6.0 or higher.
  2. An iOS device or simulator with iOS 9.0 (or higher) and audio/video capabilities (using a real device is recommended).
  3. The iOS device is connected to the Internet.

2 Integrate the SDK

2.1 Create a Project (optional)

Skip this step if you are integrating the RoomKit SDK into an existing project.
  1. Launch Xcode, then click "Create a new Xcode project" in the Welcome to Xcode window or choose File > New > Project. In the sheet that appears, select the iOS platform and select App under the Application section.

  2. In the following sheets, fill out the forms and choose options to configure your project, and 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.

  1. Select a location to save your project and click Create.

2.2 Import the SDK

  1. Download and unzip the latest version of the RoomKit SDK. Refer to RoomKit SDK Downloads for detailed download instructions.

Please note that 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, please be reminded to use the ones in the iphoneos when you prepare your app for distribution, or 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 “ZegoRoomKitResources.bundle” into your project directory.

  3. In Xcode, select your app target under TARGETS, then select General > Frameworks,Libraries,and Embedded Content, and click the "+" button to add the .framework files you copied in the previous step.

    /Pics/RoomKit/iOS/framework_add.png

  1. In Xcode, select your app target under TARGETS, then select Build Phases > Copy Bundle Resources, and click the "+" button to add the ZegoRoomKitResources.bundle file.

    /Pics/RoomKit/iOS/copy_bundle.png

2.3 Configure the SDK

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

    Xcode11Config the SDK

  2. In Xcode, select the RoomKit screen sharing extension target under TARGETS, then select General > Framework and Libraries to configure the extension targe as demonstrated below.

copy_bundle

3 Set up App Permissions

Set up app permissions as required.

  1. In Xcode, select your app target under TARGETS, then select Info > Custom iOS Target Properties.
  2. Click the "+" 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 do not need to repeat them here.

  1. Please 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), please 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'

5 Other Settings

5.1 Capabilities

  • App Groups

To enable the data sharing between the main process and the screen sharing extension process, please add the App Groups capability to your app target.

  1. In Xcode, select your app target under TARGETS, then select Signing & Capabilities > + Capability.

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

  3. In the Signing & Capabilities pane, click the "+" 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 under TARGETS, then select Signing & Capabilities > + Capability.
  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 under TARGETS, then select Signing & Capabilities > + 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 "+" 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 under TARGETS, then General -> Deployment Info -> Device Orientation.
  2. Check the checkboxes for the 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. Please 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. Please refer to the 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” is reported.

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 under TARGETS, select the Build Settings pane, then set the option Enable Bitcode to "No".

  2. Start a Terminal window, cd into 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.” is reported.

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 under TARGETS, select the Build Settings **pane, then set the option **Validate Workspace to "Yes".