iOS崩溃: Unable to open a realm at Path

标签 ios realm

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

请帮忙。

错误:

fatal error :“尝试!”表达式意外引发错误:错误 Domain=io.realm Code=2 “无法在路径 '/var/mobile/Containers/Data/Application/03BA7C37-9852-4A01-8EF6-949E308EADCD/Documents/default.realm 处打开 Realm .lock': open() 失败: 不允许操作。"UserInfo={错误代码=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")
            }
        }

最佳答案

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

关于iOS崩溃: Unable to open a realm at Path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56346552/

相关文章:

javascript - Phonegap 事件在线/离线不工作

dictionary - Realm中的HashMap序列化(移动数据库)

swift - Realm 获取已保存记录的 ID

swift - 如何保存 Realm 关系(列表)

c# - Realm .NET 其中 Contains() 查询抛出 System.NotSupportedException

ios - 我如何接收来自 Apple 的关于 APNs 过期邮件的邮件?

ios - 在 UIScrollView 上平移对象

ios - 如何确保我的 AVCaptureSession 有足够的时间运行?

ios - 为什么Realm对象中没有我的属性?

ios - 在 iOS Metal 中重用具有不同统一参数的像素着色器