Deven Nazare
Deven Nazare

Reputation: 518

No such module 'AgoraRtcKit' Xcode Swift error

I am trying to integrate live video streaming into my app through a 3rd party named as Agora. I am facing some errors as No such module 'AgoraRtcKit'. I have already imported the library SDK from their website (also attached the screenshot for the same).

Code:

 //
//  RoleViewController.swift
//  OpenLive
//
//  Created by CavanSu on 2019/8/28.
//  Copyright © 2019 Agora. All rights reserved.
//

import UIKit
import AgoraRtcKit. // This is the module which is not getting imported 

protocol RoleVCDelegate: NSObjectProtocol {
    func roleVC(_ vc: RoleViewController, didSelect role: AgoraClientRole)
}

class RoleViewController: UIViewController {

    weak var delegate: RoleVCDelegate?
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
    
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        guard let segueId = segue.identifier,
            segueId.count > 0 else {
            return
        }
        
        switch segueId {
        case "roleToLive":
            guard let mainVC = navigationController?.viewControllers.first as? MainViewController,
                let liveVC = segue.destination as? LiveRoomViewController else {
                return
            }
            
            liveVC.dataSource = mainVC
        default:
            break
        }
    }
    
    func selectedRoleToLive(role: AgoraClientRole) {
        delegate?.roleVC(self, didSelect: role)
        performSegue(withIdentifier: "roleToLive", sender: nil)
    }
    
    @IBAction func doBroadcasterTap(_ sender: UITapGestureRecognizer) {
        selectedRoleToLive(role: .broadcaster)
    }
    
    @IBAction func doAudienceTap(_ sender: UITapGestureRecognizer) {
        selectedRoleToLive(role: .audience)
    }
}


Images for reference:

File system with SDK framework

Framework which I had added

Upvotes: 4

Views: 3852

Answers (5)

Krunal Nagvadia
Krunal Nagvadia

Reputation: 1162

In my case I added Agora in my project using package manager. I tried everything nothing worked for me. Maybe sometimes it's Xcode related issue. I fixed issue using simple steps

  • Then I remove the add Agora again using package manager into my project.

  • Clean Build project. (Better clean derived data as well)

  • Quit the Xcode.

  • Run the project.

Build successes. ✅

Just for your information I'm using Xcode 15.2

Upvotes: 0

Oscar Junius
Oscar Junius

Reputation: 560

I know this answer already got solved, but I have found a solution that works 100% of times on my computer. I have a Mac and all of my Xcode projects are stored in iCloud. When this error No such module AgoraRtcKit appears, I go to my Project folder (in my iCloud), navigate to the pods folder, and then right click on the "AgoraRtcEngine_iOS" folder and click download. This will force iCloud to download the pod from the cloud and merge it with your project that you have opened in Xcode. After the download is finished (takes about 10 - 15 seconds depending on your computer) you can simply run the project.

Upvotes: 0

Jainish Patel
Jainish Patel

Reputation: 11

If you are debugging or running the project in a simulator with AgoraRtcKit SDK, it returns the error like - No such module 'AgoraRtcKit' Xcode swift error. So If you want to remove this error then you need to use a real device.

Upvotes: -1

kc ochibili
kc ochibili

Reputation: 3131

For me changing to a different version of the Agora sdk solved it for me.

In my pod file, I had:

pod 'AgoraRtcEngine_iOS'

Then I changed it to:

pod 'AgoraRtcEngine_iOS', '~> 3.2.0'

after this change (and installing the new pods) the import AgoraRtcKit in my ViewController then worked.

I got the hint from this project https://github.com/AgoraIO-Community/Agora-iOS-Swift-Example/blob/main/Podfile

Upvotes: -1

clawesome
clawesome

Reputation: 1319

This is the sample project that OP is trying to get running: Basic-Video-Broadcasting/OpenLive-iOS

To get it to build and run, download the project and the Video SDK from here. Open the project and remove AgoraRtcKit.framework from the Frameworks, Libraries, and Embedded Content list. Next drag the libs folder from the downloaded SDK into the project directory. Navigate to the libs folder and drag AgoraRtcKit.framework back into the Frameworks, Libraries, and Embedded Content.

Upvotes: 5

Related Questions