iOS 崩溃:无法在 Path 处打开领域

问题描述 投票:0回答:4

我在 Crashlytics 上看到许多崩溃,但无法重现应用程序启动时发生的崩溃。有谁知道如何重现以下崩溃。我已经尝试了 Github 和 stackoverflow 上的所有答案,但没有人提到如何重现这一特定崩溃。 因此,如果我确实有修复程序,则无法对其进行测试,除非将修复程序投入生产,然后假设 Crashlytics 不会显示崩溃。

请帮忙。

错误:

Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=2 "Unable to open a realm at path '/var/mobile/Containers/Data/Application/03BA7C37-9852-4A01-8EF6-949E308EADCD/Documents/default.realm.lock': open() failed: Operation not permitted." UserInfo={Error Code=2, NSFilePath=/var/mobile/Containers/Data/Application/03BA7C37-9852-4A01-8EF6-949E308EADCD/Documents/default.realm.lock,

调用代码

//passing the fileProtectionType as .none
RealmHelper.configureRealmFiles(with: .none)

示例代码

   static func configureRealmFiles(with fileProtectionType: FileProtectionType) {
            guard let folderPath = realm.configuration.fileURL?.deletingLastPathComponent().path else {
                return
            }

            do {
                try FileManager.default.setAttributes([FileAttributeKey.protectionKey: fileProtectionType],
                                                      ofItemAtPath: folderPath)
            } catch {
                logI("Realm: Couldn't change Realm file protection type")
            }
        }
ios realm
4个回答
0
投票

Realm 文档 有一些关于如何处理此错误的信息。检查他们降级文件访问属性的说明是否适合您的情况。


0
投票

在新位置添加 default.realm.lock 就可以解决问题并阻止崩溃再次出现。然而我永远无法复制崩溃的情况。这是因为它可能在后台发生。


0
投票

从项目中删除realm pod并重新安装它对我有帮助:)


0
投票

线程 1:致命错误:“尝试!”表达式意外引发错误:错误 Domain=io.realm Code=2 “无法在路径 '/Users/elvermaytahernandez/Library/Developer/CoreSimulator/Devices/B4220BA7-D542-4E69-BF58-77372A58559D/data/Containers 打开领域/Data/Application/C5D84A65-6E6F-444C-B838-275C4BA7952F/Documents/default.realm':不支持的领域文件格式版本(23)路径:异常回溯: 0 webcontrolOP_Debug 0x00000001055e798b _ZN5realm4util6detail26ExceptionWithBacktraceBaseC2Ev + 43 1 tengo este error como podria solucionarlo.

© www.soinside.com 2019 - 2024. All rights reserved.