I’m trying to use this Playground on a Silver iOS based app (https://github.com/gregiOS/Playgrounds/tree/master/BLE.playground). Just copied the bluetooth parts and put the scanner on a Fire Sample iOS Tabbed App (FistViewController). There are some errors when compiling it with Fire, but the playground works flawlessly with Xcode 10.2.1.
==========================================
import Foundation
import CoreBluetooth
class BluetoothScanner: NSObject, CBCentralManagerDelegate {
public typealias DidDiscoverPeripheralClosure = (PeripheralRepresntable) -> Void
var centralManager: CBCentralManager!
private var onScannerReady: ((BluetoothScanner) -> Void)?
private var onDiscover: DidDiscoverPeripheralClosure?
public init(onScannerReady: @escaping (BluetoothScanner) -> Void) {
self.onScannerReady = onScannerReady
super.init()
centralManager = CBCentralManager(delegate: self, queue: DispatchQueue.main)
}
open func centralManagerDidUpdateState(_ central: CBCentralManager) {
switch central.state {
case .poweredOn:
onScannerReady?(self)
onScannerReady = nil
case .poweredOff:
central.stopScan()
case .unsupported: fatalError("Unsupported BLE module")
default: break
}
}
open func startScanning(_ onDiscover: @escaping DidDiscoverPeripheralClosure) {
self.onDiscover = onDiscover
centralManager.scanForPeripherals(withServices: nil, options: nil)
}
// MARK: - CBCentralManagerDelegate
public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
onDiscover?(peripheral.asPeripheral(advertisementData: advertisementData, rssi: RSSI.intValue))
}
}
============================================
RemObjects Elements (Oxygene, C#, Swift and Java) Compiler for .NET, Cocoa, Java and Island.
Version 10.0.0.2415 (develop) built on bajor, 20190621-131308. Commit a346ebd.
No overloaded constructor with these parameters for type "CBCentralManager", best matching overload is "init(# delegate: ICBCentralManagerDelegate?, # queue: dispatch_queue_t!) -> instancetype!" [/Users/mneves/Development/SimpaxCrachaSwift/App/BluetoothScanner.swift (14)]
H: parameter 2 is "DispatchQueue" should be "dispatch_queue_t!" [/Users/mneves/Development/SimpaxCrachaSwift/App/BluetoothScanner.swift (14)]
E: Parameter labels case mismatch. Parameter 1 is labeled "withServices" but should should be "withServices" in call to "func scanForPeripherals(withServices serviceUUIDs: NSArray<CBUUID!>!, # options: NSDictionary<NSString!,id!>!)" [/Users/mneves/Development/SimpaxCrachaSwift/App/BluetoothScanner.swift (31)]
E: No member "uuidString" on type "NSUUID!" [/Users/mneves/Development/SimpaxCrachaSwift/App/Peripheral.swift (46)]
Reference: /Applications/Fire.app/Contents/Resources/Toffee SDKs/iOS 12.2/CoreLocation.fx