Я пытаюсь использовать mongodb mobile в плагине Cordova для iOS.В mongodb mobile для подключения к базе данных используется так называемый клиент.Я хочу хранить этот клиент глобально в моем классе swift, чтобы к нему могли обращаться другие функции.Когда я делаю это, я могу выдать ошибку во время выполнения, как только я открою приложение.
Я очень новичок в Swift.
Ошибка:
Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
это мой быстрый код:
import StitchCore
import StitchLocalMongoDBService
@objc(MongoDBStorage) class MongoDBStorage : CDVPlugin {
var client: StitchAppClient?
@objc(initiate:)
func initiate(command: CDVInvokedUrlCommand){
var pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR
)
do {
client = try Stitch.initializeDefaultAppClient(
withClientAppID: "appid"
)
print("succes")
pluginResult = CDVPluginResult(
status: CDVCommandStatus_OK,
messageAs: "initiate succes"
)
} catch {
print("error")
pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR,
messageAs: "Unexpected error: \(error)."
)
}
self.commandDelegate!.send(
pluginResult,
callbackId: command.callbackId
)
}
}