Как исправить ошибку ZONE_NOT_FOUND в CloudKit Dashboard? - PullRequest
0 голосов
/ 04 апреля 2020

В моем приложении я использую CloudKit для синхронизации c Базовые данные (флажки «Использовать базовые данные» и «Использовать CloudKit» были отмечены при создании проекта).

В AppDelegate.swift Я не сделал измените код ниже Базовые данные отметка. В коде я нигде не указал зону.

Во время разработки я тестировал приложение на своих устройствах, используя ту же учетную запись iCloud. Syn c работал хорошо. После тестирования я развернул мою схему разработки в производственной схеме. Позже я опубликовал приложение в App Store.

Теперь в CloudKit Dashboard, в разделе Производство> Модуль телеметрии я вижу ZONE_NOT_FOUND ошибок со счетом, равным приблизительно количеству моих пользователей.

ZONE_NOT_FOUND error in CloudKit Dashboard

Я тестировал свое приложение (теперь загруженное непосредственно из App Store) на моих друзьях устройствах - syn c работает, но одно замечание: ее устройства использовались и во время разработки (Я подключал их к моей Ma c и собирал и устанавливал приложение из Xcode несколько раз.)

Еще одно замечание: когда я go подключаю к модулю данных в разделе «Производство» в CloudKit Dashboard, в меню Zone Я вижу 2 варианта:

  1. com.apple.coredata.cloudkit.zone
  2. _defaultZone

И когда я нажимаю «Записи запросов», я вижу только свои строки данных когда com.apple.coredata.cloudkit.zone выбрано.

AppDelegate.swift:

import UIKit
import CoreData
import StoreKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Register for Remote Notifications
    application.registerForRemoteNotifications()

    // Override point for customization after application launch.

    return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentCloudKitContainer = {
    /*
     The persistent container for the application. This implementation
     creates and returns a container, having loaded the store for the
     application to it. This property is optional since there are legitimate
     error conditions that could cause the creation of the store to fail.
    */
    let container = NSPersistentCloudKitContainer(name: "AppTitle")

    guard let description = container.persistentStoreDescriptions.first else {
        fatalError("No Descriptions found")
    }
    description.setOption(true as NSObject, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)

    container.loadPersistentStores(completionHandler: { (storeDescription, error) in
        if let error = error as NSError? {
            // Replace this implementation with code to handle the error appropriately.
            // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

            /*
             Typical reasons for an error here include:
             * The parent directory does not exist, cannot be created, or disallows writing.
             * The persistent store is not accessible, due to permissions or data protection when the device is locked.
             * The device is out of space.
             * The store could not be migrated to the current model version.
             Check the error message to determine what the actual problem was.
             */
            fatalError("Unresolved error \(error), \(error.userInfo)")
        }
    })

    container.viewContext.automaticallyMergesChangesFromParent = true
    container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy

    NotificationCenter.default.addObserver(self, selector: #selector(self.processUpdate), name: .NSPersistentStoreRemoteChange, object: nil)

    return container
}()

// MARK: - Core Data Saving support

func saveContext () {
    let context = persistentContainer.viewContext
    if context.hasChanges {
        do {
            try context.save()
        } catch {
            // Replace this implementation with code to handle the error appropriately.
            // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            let nserror = error as NSError
            fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
        }
    }
}

@objc
func processUpdate(notification: NSNotification) {
    operationQueue.addOperation {
        // process notification
        let context = self.persistentContainer.newBackgroundContext()
        if context.hasChanges {
            do {
                try context.save()
            } catch {
                let nserror = error as NSError
                fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
            }
        }
    }
}

lazy var operationQueue: OperationQueue = {
    var queue = OperationQueue()
    queue.maxConcurrentOperationCount = 1
    return queue
}()

}

Эта ошибка беспокоит меня, что я могу сделать, когда приложение уже в работе, чтобы исправить его, сделать его go прочь?

1 Ответ

0 голосов
/ 08 апреля 2020

Учитывая факты:

  • CoreData + CloudKit syn c работает
  • Ошибка ZONE_NOT_FOUND возникает точно один раз для пользователя

И предположение:

  • То, что вы сами не запрашиваете зону напрямую.

Я бы не слишком беспокоился об этой ошибке.

Мои мысли:

  • Скорее всего, при первом использовании после установки интеграция CoreData + CloudKit проверяет существование обычной зоны com.apple.coredata.cloudkit.zone, используемой для синхронизации, путем запроса Это. Когда интеграция сталкивается с ошибкой ZONE_NOT_FOUND, она создаст ее.

  • Apple может быть более изящной, запросив все зоны и проверив результат. Однако, если у вас уже настроено много зон, методология проб и ошибок имеет преимущество в производительности.

То есть я твердо верю, что вы ничего не можете с этим поделать.

Я бы по-прежнему следил за этим, если бы увеличивалась ошибка на соотношение пользователей.

Однако небольшое увеличение все же можно объяснить, если пользователь выходит из iCloud и / или удаляет свою личную базу данных.

Удачи!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...