1

First I make a SDK about Bluetooth

ImyBluetoothManager.swift

public protocol ImyBluetoothManager: NSObjectProtocol {

  var delegate: myBluetoothDelegate?{get set}
}

public class myBluetooth {

  public static func getManager() -> ImyBluetoothManager? {

   return myBluetoothManager.sharedInstance()
  }
}

myBluetoothManager.swift

class myBluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate, myBluetoothManager {

  static var instance: myBluetoothManager!

  var delegate: myBluetoothDelegate? {
    get {
      return delegate
    }
    set {
      delegate = newValue
    }
  }

  private override init() {}

  static func sharedInstance() ->myBluetoothManager {

    if self.instance == nil {

      self.instance = myBluetoothManager()
      self.instance.setup()
      self.instance.scanBLE()
    }     

    return self.instance
  }

Then I run it and get myBluetooth.framework,and I new a project 'ExampleApp'

ExampleApp

ViewController.swift

import myBluetooth

class ViewController: UIViewController,myBluetoothDelegate {

  override func viewDidLoad() {

    let test = SiltaBluetooth.getManager()
    test?.delegate = self

    super.viewDidLoad()
  }
}

Then I run ExampleApp,and warning me.

warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.

Cong Tran
  • 1,448
  • 14
  • 30

0 Answers0