Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

swift

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() { ... 
                           } 

like image 605
Nic Huang Avatar asked Apr 09 '15 06:04

Nic Huang


1 Answers

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

ProjectName-Bridging-Header.h:

#import <CoreLocation/CoreLocation.h>
like image 51
Rob MacEachern Avatar answered Sep 28 '22 09:09

Rob MacEachern