简体   繁体   中英

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:

带有 SDK 框架的文件系统

我添加的框架

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 .

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM