问题描述:

I'm now using Swift class in my existing Object-C project.In my Swift class, I'm using CLLocationManagerDelegate. Everything works well. However, when ProjectName-Swift.h is generated, an issue in ProjectName-Swift.h file shows that Can't find protocol declaration for 'CLLocationManagerDelegate'. I tried to silence the issue by importing CoreLocation/CoreLocation.h in ProjectName-Swift.h. It worked. But after compiled a few times, CoreLocation/CoreLocation.h was gone because ProjectName-Swift.h is generated from my swift class. And the issue comes again.

ProjectName-Swift.h

Here is my swift class (No issue here)

import UIKit

import CoreLocation

@objc class SSDLocationHelper: NSObject, CLLocationManagerDelegate {

let locationManager = CLLocationManager()

func findUserLocation() { ...

}

网友答案:

The solution is to import the framework in your project bridging header.

ProjectName-Bridging-Header.h:

#import <CoreLocation/CoreLocation.h>
相关阅读:
Top