Nic Huang
Nic Huang

Reputation: 291

ProjectName-Swift issue - Can't find protocol declaration for 'CLLocationManagerDelegate'

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

issue screenshot Here is my swift class (No issue here)

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

Upvotes: 20

Views: 4793

Answers (1)

Rob MacEachern
Rob MacEachern

Reputation: 821

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

ProjectName-Bridging-Header.h:

#import <CoreLocation/CoreLocation.h>

Upvotes: 21

Related Questions