尝试在我的 Swift 项目中使用带有桥接头的 Objective-C 库失败

Failing trying to use Objective-C library in my Swift project with bridging header

我想我已经完成了所有必要的步骤,但由于某种原因失败了。 这是我得到的错误:

Showing All Messages Undefined symbol: _OBJC_CLASS_$_HCKBeaconCentralManager

我已经在构建设置中设置了文件:

这是桥接文件的内容:

#import "HCKBeaconCentralManager.h"
#import "HCKBeaconInterface.h"
#import "HCKBeaconBaseModel.h"
#import "HCKBeaconProtocol.h"

以防万一这是我用来尝试调用 SDK 的代码 类:

import UIKit
import SwiftUI
import CoreLocation
import CoreBluetooth

@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate,HCKCentralScanDelegate {

    func centralManagerScanNewDeviceModel(_ beaconModel: HCKBeaconBaseModel!, manager: HCKBeaconCentralManager!) {
        print("centralManagerScanNewDeviceModel")
    }

    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        print("scene init")
        HCKBeaconCentralManager.sharedInstance()?.scanDelegate = self
    }

    func sceneDidDisconnect(_ scene: UIScene) {
    }

    func sceneDidBecomeActive(_ scene: UIScene) {
    }

    func sceneWillResignActive(_ scene: UIScene) {
    }

    func sceneWillEnterForeground(_ scene: UIScene) {
    }

    func sceneDidEnterBackground(_ scene: UIScene) {
    }
}

将您的 Objective-C 文件添加到 Xcode->Targets->Build Phases->Compile Sources。