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

时间:2015-04-09 06:10:46

标签: ios xcode 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

issue screenshot 这是我的快速课程(这里没有问题)

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

1 个答案:

答案 0 :(得分:15)

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

项目名-桥接-Header.h:

#import <CoreLocation/CoreLocation.h>