title: CLLocationManager: didChangeAuthorization and didRangeBeacons is not getting called
body: <p>I am developing a framework which has all the logic for beacon ranging and monitoring. </p>
  
  <p>All the callbacks of <code>CLLocationManager</code> doesn't work. This only happens when I use the framework. If I transfer all the logic to the test app, it works.</p>
  
  <p>Here are parts of the code:</p>
  
  <p>This is the main class of the framework (which is called from the test app):</p>
  
  <pre><code>//Test App
  let miniK = Kanban()
  miniK.startBeaconSearch(forApiKey: "apikeytest", userID: "1")
  </code></pre>
  
  <pre><code>public class Kanban: NSObject {
  
  
      public override init() {
          super.init()
      }
  
      public func startBeaconSearch(forApiKey apikey: String, userID: String){
          let beaconController = BeaconController.init(apikey: apikey, userId: userID)
          beaconController.startScanning()
      }
  
  }
  </code></pre>
  
  <p><strong>BeaconController:</strong></p>
  
  <pre><code>import Foundation
  import CoreLocation
  import CoreBluetooth
  
  class BeaconController : NSObject, CLLocationManagerDelegate {
      var locationManager: CLLocationManager!
      var apiKey: String!
      var userID: String!
      var beaconsJson : [BeaconItem]?
  
      public override init(){
          super.init()
          locationManager = CLLocationManager()
          locationManager.delegate = self
          locationManager.requestAlwaysAuthorization()
      }
  
      public init(apikey:String, userId:String){
          super.init()
          locationManager = CLLocationManager()
          locationManager.delegate = self
          locationManager.requestAlwaysAuthorization()
          apiKey = apikey
          userID = userId
          self.loadBeacons()
      }
  
      func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
      {
          if status == .authorizedAlways
          {
              if CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self){
                  if CLLocationManager.isRangingAvailable() {
                      startScanning()
                  }
              }
          }
      }
  
  
      func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
          print("didRangeBeacons")
          if beacons.count &gt; 0 {
              self.beaconReached(uuid: beacons[0].proximityUUID, minor: beacons[0].minor, major: beacons[0].major)
          }
      }
  
      func locationManager(_ manager: CLLocationManager, rangingBeaconsDidFailFor region: CLBeaconRegion, withError error: Error) {
          print(error)
          print(error.localizedDescription)
      }
  
      public func startScanning() {
          print("StartScanning")
          sleep(5)
          //let beacon = beaconsJson![0]
  
          for beacon in beaconsJson! {
              print(beacon.BeaconUUID)
              let identifier = "iBeacon" + beacon.BeaconMajor.description + beacon.BeaconMinor.description
              let uuid = UUID(uuidString: beacon.BeaconUUID)!
              let beaconRegion = CLBeaconRegion(proximityUUID: uuid, major: CLBeaconMajorValue(beacon.BeaconMajor), minor: CLBeaconMinorValue(beacon.BeaconMinor), identifier: identifier)
              //beaconRegion.notifyOnEntry = true
              locationManager.requestState(for: beaconRegion)
              locationManager.startMonitoring(for: beaconRegion)
              locationManager.startRangingBeacons(in: beaconRegion)
          }
          print(locationManager.rangedRegions)
      }
  }
  </code></pre>
  
  <p><code>loadBeacons</code> and <code>beaconReached</code> are network functions that work correctly.
  The test app has location permission by the user and all the capabilities needed.</p>
  
  <p>When I print the ranged regions, the beacons appear correctly.</p>