This page contains information on how to prepare the development environment before enabling a call/live broadcast with the Agora SDK for iOS.

Prerequisites

  • Xcode 9.0+.
  • Physical iOS device 8.0+ (iPhone or iPad).
  • Ensure that your project has a validated provisioning profile certificate.
  • Before accessing Agora’s services, ensure that you have opened the ports and whitelisted the domains as specified in Firewall Requirements.

Use a physical device to run the sample. Simulators may lack the functionality or the performance needed to run the sample.

Create an Agora Account and Get an App ID

  1. Sign up for a developer account at https://dashboard.agora.io/.

  2. Click Add New Project on the Projects page of the dashboard.

    ../_images/appid_1.jpg
  3. Fill in the Project Name and click Submit. You have created your first project at Agora.

  4. Find the App ID under the created project.

    ../_images/appid_2.jpg

Add the Agora SDK to Your Project

Choose one of the following methods to add the Agora SDK libraries to your project:

Add the Libraries Automatically

  1. Install CocoaPods by running the following command in Terminal:

    brew install cocoapods
    • Skip this step if you have preconfigured CocoaPods and Homebrew on your system.
    • If Terminal says -bash: brew: command not found, install Homebrew before running the command. See Homebrew Installation Method.
  2. Create a Podfile in your project. In the root directory of your project, run the following command in Terminal. This creates a Podfile in the same directory.

    pod init
  3. Add the Agora SDK reference in the Podfile. Open the Podfile, and put in the following content. Fill “Your App” with the name of your Target.

    platform :ios, '9.0'
    use_frameworks!
    
    target 'Your App' do
      pod 'AgoraRtcEngine_iOS'
    end
  4. Update the local Cocoapods library. Run the following command in Terminal:

    pod update
  5. Install the related libraries.

    pod install

    If Terminal says Pod installation complete!, you have successfully added the libraries. Click to open the YourApp.xcworkspace file, or run the following command to open it. Fill “YourApp” with the name of your Target.

    open YourApp.xcworkspace

Add the Libraries Manually

  1. Download the Agora Video SDK for iOS and unzip the downloaded SDK package.

  2. Open your project with Xcode and select the current Target.

    ../_images/ios_video_1.jpg
  3. Navigate to the Build Phases tab.

    ../_images/ios_video_2.jpg
  4. Expand the Link Binary with Libraries section to add the following libraries. To begin adding the new libraries, click the + button.

    • AgoraRtcEngineKit.framework
    • Accelerate.framework
    • SystemConfiguration.framework
    • libc++.tbd
    • libresolv.tbd
    • CoreMedia.framework
    • VideoToolbox.framework
    • AudioToolbox.framework
    • CoreTelephony.framework
    • AVFoundation.framework

    Before:

    ../_images/ios_video_3.jpg

    After:

    ../_images/ios_video_4.jpg

    AgoraRtcEngineKit.framework is in the libs folder of the downloaded SDK. Click + > Add Other…, go to the downloaded SDK, and add AgoraRtcEngineKit.framework.

    ../_images/ios_video_5.jpg

Authorize the Use of the Agora SDK

Before enabling a video call, you need to enable camera and microphone access to the SDK on your device. Open info.plist and click + to add:

  • Privacy - Microphone Usage Description, and add a note in the Value column.
  • Privacy - Camera Usage Description, and add a note in the Value column.

Before:

../_images/ios_video_6.jpg

After:

../_images/ios_video_7.jpg

Access the Library

You can access the added library using Objective-C or Swift.

Objective-C

In the main file that uses the Agora APIs, add #import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>.

The SDK provides FAT image libraries with multi-architecture support for both 32/64-bit audio emulators and 32/64-bit audio/video real devices.

Swift

In the main file that uses the Agora APIs, add import AgoraRtcEngineKit.

../_images/ios_video_8.jpg

Additional Settings and Permissions

The Agora SDK provides the following additional settings and permissions for you to optimize your project:

  • Set the Background Modes. When the background mode is enabled, your application can still run the video call when it is switched to the background. Select the current Target, click the Capabilities tab, enable Background Modes, and check Audio, AirPlay, and Picture in Picture.

    ../_images/ios_video_9.jpg
  • Enable or disable Bitcode. Applications developed with Bitcode can be optimized once it is uploaded to the App Store. Select the current Target, click the Build Settings tab, and enable or disable Bitcode according to your needs.

    ../_images/ios_video_10.jpg

Next Steps

You have now set up the iOS environment and can start a call/live broadcast following the steps under Quickstart Guide:

  • Initialize the SDK
  • Join a Channel
  • Publish and Subscribe to Streams