Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Using Twilio Voice side by side with WebRTC - iOS


Twilio's Programmable Voice SDK for iOS is based upon a fork of the Chromium WebRTC project (webrtc.org(link takes you to an external page)). This heritage usually presents an interesting challenge of class conflicts when using other WebRTC dependencies alongside Twilio in your iOS application. We have designed Voice SDK 3.x and above to work alongside other libraries that also inherit from webrtc. However, in the case you run into conflict issues, follow this guide for ways how to resolve conflicts.


How do conflicts occur?

how-do-conflicts-occur page anchor

Objective-C does not support the concept of namespaces. Instead, developers typically use a 3-4 letter prefix to uniquely identify their classes. WebRTC classes are prefixed with RTC, while Twilio Voice classes are prefixed with TVO.

Consider the following Podfile which consumes both Twilio Voice and WebRTC:


_10
source 'https://github.com/CocoaPods/Specs'
_10
_10
target 'TARGET_NAME' do
_10
platform :ios, '10.0'
_10
pod 'TwilioVoice', '4.0.0'
_10
pod 'GoogleWebRTC'
_10
end

Some classes with the RTC prefix are present both in WebRTC (publicly) and in Twilio Voice (privately). When classes are loaded by the Objective-C runtime, any conflicts which occur are raised in your console logs:

Console log showing that several libraries are implemented twice.

You can see that classes like RTCAudioSession are provided by both libraries. When classes conflict at runtime, the version which is loaded is undefined. This could result in unexpected behavior or crashes in your application.


How do I resolve class conflicts?

how-do-i-resolve-class-conflicts page anchor

One technique used to resolve class conflicts is to rename (prefix) the impacted classes. As of version 4.0.0, Twilio Voice now prefixes RTC classes with TVO. For example, RTCAudioSession now becomes TVORTCAudioSession.

If you wish to use Twilio Voice side by side with other WebRTC dependencies we recommend that you update to 4.x to eliminate class conflicts.


Rate this page: