Home » Tutorials » Build an iOS Video Calling App with Swift in Simple Steps

Introduction

This tutorial provides step-by-step instructions on how to add video calls to your iOS apps with responsive UIs. You will learn how to create an Xcode project and then configure the iOS app with video call functionalities using MirrorFly SwiftUI SDKs.

Before diving right into the steps, let’s check out the requirements:

Prerequisites

1. Get the MirrorFly Video SDK License Key

Follow the below steps to get your license key:

Step 1 : Go to the MirrorFly console. Create an Account. If you already have an account with MirrorFly, go to step 3.

Step 2 : Follow the account creation instructions in the console page. Once you've created the account, validate your account using the verification link sent to your email ID.

Step 3 : Login to your account here

Step 4 : In the Overview page, under Application Info section - copy the license key

2. Create an iOS Application

Step 1 : Open Xcode

#

Step 2 : Go to File > New > Project

Step 3 : Create a New Project

Step 4 : Set up the app as belows

  • Platform: iOS
  • Template: App
  • Interface: SwiftUI
  • Life Cycle: SwiftUI App
  • Language: Swift

Now, a project to develop the iOS app is created. The next step is to set up your UI kit.

3. UI Kit Installation

Step 1 : Download the UI kit

Step 2 : Import the xcframeworks from the downloaded package

Step 3 : Next, download the MirrorFly SDKs

Step 4 : Import them into your iOS project

     
                              Goto Project ->  Target -> General -> Frameworks,libraries and Embedded Content -> 
Select Embed & Sign for all the Chat SDK's xcframeworks
#

4. Disable Bitcodes

Step 1 : Go to Project

Step 2 : Select Build Settings

Step 3 : Search ‘Bitcode’

Step 4 : Against ‘Bitcode’, choose ‘No’ from the dropdown menu

  
                                Goto Project -> Build Settings -> Filter the term `Bitcode` -> and select No from the dropdown
                           
#

5. Initialize the Pods

Step 1 : If you do not have any pods initiated before for your project, initiate one.

Step 2 : Choose the necessary pods required for the SDK.

Step 3 : Initialize them.

  
                                  pod 'Alamofire' 
                                 pod 'XMPPFramework/Swift' 
                                 pod 'Toaster' 
                                 pod 'Firebase/Auth' 
                                 pod 'Firebase/Crashlytics' 
                                 pod 'Firebase/Analytics' 
                                 pod 'Firebase/Messaging' 
                                 pod 'SDWebImage' 
                                 pod "BSImagePicker", "~> 3.1" 
                                 pod 'libPhoneNumber-iOS' 
                                 pod 'NicoProgress' 
                                 pod 'SocketRocket' 
                                 pod 'Socket.IO-Client-Swift', '~> 15.2.0' 
                                 pod 'GoogleWebRTC' # WebRTC for Calls 
                                 pod 'RealmSwift', '10.20.1' 
                            

Step 4 : At the end of the pod file, add the below pod hook file

Step 5 : Install the pods

  
                         post_install do |installer| 
                             installer.pods_project.targets.each do |target| 
                                 target.build_configurations.each do |config| 
                                 config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.1' 
                                 config.build_settings['ENABLE_BITCODE'] = 'NO' 
                                 config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No' 
                                 config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' 
                                 end 
                             end 
                             end 

                        

6. Enable Project Capabilities

Step 1 : Go to Project

Step 2 : Select Target

Step 3 : Click on Signing & Capabilities

Step 4 : Click on the + symbol at the top left corner of the page

Step 5 : Under Capabilities, find App Groups and Background Modes

I. App Group Capabilities

In App Groups, enable group.mirrorfly.quickstart

#

II. Background Modes

Next, below Background modes, you need to enable the below capabilities:

  • Audio,Airplay, and Picture in Picture
  • Background fetch
  • Voice over IP
  • Remote notifications
#

II. Microphone Privacy

In your project plist, you need to set up the Microphone Privacy as below:

#

III. Camera Privacy

Next, you need to set up the camera privacy as mentioned below:

#

IV. Ringtone and Reconnection Tone

Add the caller tone and reconnection tune in the mp3 format, to your iOS project

#

V. Photo Library Usage Description

In your info.plist, add the Photo library usage description

#

7. Initialize using License Key

Through your view controller, intialize the MirrorFlyUI instance using the func intialize () as mentioned below:

 
                     import UIKit 
                         import FlyUIKit 
                         class ViewController: UIViewController {  
                             override func viewDidLoad() {  
                                 super.viewDidLoad()  
                                 self.initialize() 
                         } 
                          
                         func initialize () { 
                                     FlyUIKitSDK.shared.initialization (userID: userId, licenseKey: licenseKey) {(isSuccess, error) in  
                                          
                                     if isSuccess {  
                                         self.getRecentChat() 
                                     }  
                                     else { 
                                         print (error) 
                                     } 
                                 } 
                             } 
                         } 
                    
 
                         func initialize () { 
                                      
                                 FlyUIKitSDK.shared.initialization(userID: userId, licenseKey: licenseKey) {(isSuccess, error) in 
                                     if isSuccess{ 
                                         self.getRecentChat() 
                                     } else { 
                                         print(error) 
                                     } 
                                 } 
                             } 
                    

8. Set Up Audio Call Screen

Follow the below steps to implement the Screen display during an Audio call

#

II. Audio Module Components

To create and display call screen view, you need to use the MFUICallScreenModule and its components in the MFUICallScreenViewController class.

 
                        ChatManager.shared.messageEventsDelegate = self                         
                

The module consists of five components:

headerComponent

  • Back Button
  • Call Status Label
  • Name Label of Caller/Receiver
  • Image View of Caller/Receiver
  • Time Label of Connected calls

retryFooterComponent

  • Cancel button
  • Call again button

hangupFooterComponent

  • Mute Button
  • Hangup Button
  • Speaker Button

callOverlayComponent

  • Caller imageview button

muteViewComponent

  • mute imageview
  • mute description label

9. Set Up Video Call Screen

Follow the below steps to set up the screen of an ongoing video call:

#

Video Module Components

To create and display call screen view during a video chat, you need to use the MFUICallScreenModule and its components.

Step 1 : The components of the Video Call Modules include:

RemoteVideoView

  • Video mute imageview
  • Video mute description

RemoteVideoView

  • Video mute imageview
  • Video mute description

LocalVideoView

  •  Shows local video

headerComponent

  • Call status Label
  • Back Button
  • Caller/Receiver Name Label
  • Connected call Time Label

headerComponent

  • Mute button
  • Speaker button
  • Hangup button

LocalVideoView

  • Shows local video

Step 2 : In the MirrorFly UIKit's view life cycle, add the module components to the setupView() method by calling the loadView() method of the view controller.

10. Start Making Video Calls

Once you've completed the above steps,

  • Run your app on a simulator or a plugged-in device

To send a message,

  • Tap the icon in the top-rigt corner
  • Select the chat type: single or group. The app lands in the Contacts page with all the registered users.
  • Select the user you need to video chat with. A chat room gets created.
  • Make your first video call!

Congratulations! you've created a video chat app with instant messaging capability!

Conclusion

Through this tutorial, you learnt how to build an iOS video calling app with responsive UI elements, using MirrorFly Chat SDKs. You also learned how to develop a Group Chat App in Kotlin and deploy them on the MirrorFly servers.

If you’d like to add more features to your iOS app, here are a few tutorials you may find useful for your development:

Wishing you happy app development!

Integrate Our Chat SDK In Just 10 Mins!

Add chat features to your Flutter apps - in 10 minutes - with just a few lines of code.

Request Demo
  • chat api
  • video call api
  • voice call
  • sip voip
  • sdk

FAQs

1. How to implement video calls in iOS?

Here's how you can implement video calling in iOS,

Step 1: Opt for the most reliable SDK provider like MirrorFly, Agora, or Twilio.

Step 2: Install the SDK and add it to your project.

Step 3: Initialize the SDK with your app's credentials.

Step 4: Set up permissions for the camera and microphone.

Step 5: Design the user interface for carrying out a video call.

Step 6: Deploy and test.

2. Is SwiftUI only for iOS?

Nope. SwiftUI was created by Apple as a cross-platform framework that would help developers to build apps for all Apple platforms like iOS, macOS, watchOS, and tvOS using a single codebase.

3. Is SwiftUI the future of iOS development?

Absolutely yes, SwiftUI is the future of iOS development majorly for its declarative syntax framework that helps build visually impressive iOS apps. Additionally, it offers code efficiency and code reusability.

4. Is SwiftUI faster than UIKit?

Yes, SwiftUI may be faster than UIkit in certain scenarios primarily for its declarative syntax that fastens development process and streamlines building of UIs. However, in the minds of developers UIkits still remain as the better option for its optimization capabilities.

5. Can you build an app with SwiftUI?

Yes, you can build with SwiftUI. Because, SwiftUI offers declarative syntax that makes it possible for developers to build visually appealing user interfaces for all types of Apple ecosystems like iOS, macOS, watchOS, and tvOS. Additionally, there are a lot of resources available for SwiftUI covering basic and advanced topics.

6. Should I use SwiftUI or Flutter?

Choosing SwiftUI or Flutter completely depends on your project requirements. While SwiftUI is ideal for developing apps on all Apple platforms like macOS, tvOS, iOS, and more. Flutter, on the other hand is best for building cross-platform apps for both Android and iOS with a single codebase.

mirrorfly

Launch your Own iOS Chat App with Swift!

Drive 1 billion + conversations on any Android, iOS, or Web app with 500+ chat features & 100+ UI components.

  • Topic-based Chat
  • Upload Large Files
  • Multi-tenancy support
  • Lite Chat App
  • Hire Dedicated Team
Request Demo