objective-c - 未能尝试在我的 Swift 项目中使用带有桥接头的 Objective-C 库
问题描述
我想我已经完成了所有必要的步骤,但由于某种原因它失败了。这是我得到的错误:
显示所有消息未定义符号:_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。
推荐阅读
- excel - Excel VBA ~ 数据表未写入工作表
- python - (变分)自编码器中异常阈值的实际确定
- javascript - 在 React 中将数组存储到本地存储中
- c - 在进行分配操作时,将其类型转换为比实际更长的数据类型时,c 中的类型转换如何表现
- ruby-on-rails - 获取对象数组的关联记录
- file - 如何从 trust.p12 证书文件中获取 SSL 证书主题、颁发者、开始日期和到期日期
- git - 如何将 .git/ 文件更改推送到远程(服务器)存储库
- haskell - 将 forkIO 推广到 MonadIO
- spring - DEF_CONTENT_CHARSET 错误
- typescript - Angular 6 库:在 CI 管道中构建库以创建 lib 版本