Я написал некоторый код и попытался сделать приложение, но у меня проблема: [CoreBluetooth] XPC-соединение недействительно. Я думаю, что мое мнение правильно соотносится с кодом. Я не знаю, где проблема. Сборка выполнена успешно, поэтому с кодом не должно быть проблем. Это мой первый раз с Xcode, Swift и MacBook, так что я действительно не ладил с этим.
import UIKit
class ViewController: UIViewController, EILIndoorLocationManagerDelegate {
@IBOutlet weak var myLocationView: EILIndoorLocationView!
var locationManager = EILIndoorLocationManager()
var location: EILLocation!
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
let locationBuilder = EILLocationBuilder()
locationBuilder.setLocationName("office")
locationBuilder.setLocationBoundaryPoints([
EILPoint(x: 0.00, y: 0.00),
EILPoint(x: 0.00, y: 4.00),
EILPoint(x: 4.48, y: 4.00),
EILPoint(x: 4.48, y: 0.00)])
locationBuilder.addBeacon(withIdentifier: "395b8767bd63efc0fff23894fa05cb0b",
atBoundarySegmentIndex: 0, inDistance: 4.46, from: .leftSide)
locationBuilder.addBeacon(withIdentifier: "4bb0675d47649d4273a9bb963ea9dd13",
atBoundarySegmentIndex: 1, inDistance: 0.38, from: .rightSide)
locationBuilder.addBeacon(withIdentifier: "739cd8034732d5349f15c33c625c9f05",
atBoundarySegmentIndex: 2, inDistance: 4.46, from: .leftSide)
locationBuilder.addBeacon(withIdentifier: "a823daa6f67076543143752b57514507",
atBoundarySegmentIndex: 3, inDistance: 0.43, from: .rightSide)
locationBuilder.setLocationOrientation(270)
guard let location = locationBuilder.build()else {
print ("Error whe building location")
return
}
ESTConfig.setupAppID("<configuration-3rj>", andAppToken: "<668f7c994b82b07e902ccf4a3d7d88ba")
let addLocationRequest = EILRequestAddLocation(location: location)
addLocationRequest.sendRequest { (location, error) in
if error != nil {
NSLog("Error when saving location")
} else {
NSLog("Location saved successfully")
}
}
}
override func viewWillAppear(_ animated: Bool){
myLocationView.backgroundColor = UIColor.clear
myLocationView.showTrace = true
myLocationView.showWallLengthLabels = true
myLocationView.rotateOnPositionUpdate = false
myLocationView.locationBorderColor = UIColor.black
myLocationView.locationBorderThickness = 6
myLocationView.doorColor = UIColor.brown
myLocationView.doorThickness = 5
myLocationView.traceColor = UIColor.yellow
myLocationView.traceThickness = 2
myLocationView.wallLengthLabelsColor = UIColor.black
myLocationView.drawLocation(location)
locationManager.state(for: location)
}
override func viewWillDisappear(_ animated: Bool){
super.viewWillDisappear(animated)
locationManager.stop()
}
func indoorLocationManager(_ manager: EILIndoorLocationManager, didFailToUpdatePositionWithError error: NSError!){
NSLog("Did fail to update location")
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}