Realm crash in iPhone X, permission issues


#1

Hi Realm Team,

First of all thanks for providing such a robust DB library for the mobile platform.

I want your help in debugging a crash which is happening a lot for past few days

Scenario:
It is mostly happening in iPhoneX device with {iOS 12.2.0, 12.3.1}.
It seems to be having some permission issues while accessing the primary Realm DB.
Following is the detail of the crash provided by Fabric 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/DF0CC44C-45BC-4212-B354-8266BA1BC044/Documents/realm/default.realm.lock’: open() failed: Operation not permitted.” UserInfo={Error Code=2, NSFilePath=/var/mobile/Containers/Data/Application/DF0CC44C-45BC-4212-B354-8266BA1BC044/Documents/realm/default.realm.lock, Underlying=open("/var/mobile/Containers/Data/Application/DF0CC44C-45BC-4212-B354-8266BA1BC044/Documents/realm/default.realm.lock") failed: Operation not permitted, NSLocalizedDescription=Unable to open a realm at path ‘/var/mobile/Containers/Data/Application/DF0CC44C-45BC-4212-B354-8266BA1BC044/Documents/realm/default.realm.lock’: open() failed: Operation not permitted.}: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-902.0.54/src/swift/stdlib/public/core/ErrorType.swift, line 184

Please assist me on debugging this issue as soon as you guys can do.


#2

It seems that you are using force try somewhere.
I would definitelly check those out, and if i can then change it to a try - catch block.