ProjectName-Swift问题 - 找不到'CLLocationManagerDelegate'的协议声明

Nic*_*ang 12 xcode ios swift

我现在在我现有的Object-C项目中使用Swift类.在我的Swift类中,我正在使用CLLocationManagerDelegate.一切都很好.但是,当生成ProjectName-Swift.h时,ProjectName-Swift.h文件中的问题显示无法找到"CLLocationManagerDelegate"的协议声明.我试图通过在ProjectName-Swift.h中导入CoreLocation/CoreLocation.h来解决这个问题.有效.但是经过几次编译后,CoreLocation/CoreLocation.h就消失了,因为ProjectName-Swift.h是从我的swift类生成的.这个问题又来了.

项目名 - Swift.h

发布截图 这是我的快速课程(这里没有问题)

import UIKit import CoreLocation @objc class SSDLocationHelper: NSObject, CLLocationManagerDelegate { let locationManager = CLLocationManager() func findUserLocation() { ... }
Run Code Online (Sandbox Code Playgroud)

Rob*_*ern 16

解决方案是在项目桥接标头中导入框架.

项目名桥接-Header.h:

#import <CoreLocation/CoreLocation.h>
Run Code Online (Sandbox Code Playgroud)

  • 嗯,恐怕这对我不起作用。仍在报告相同的错误。 (2认同)