Right now I'm in the process of migrating from Swift 1.2 to Swift 2.0.
The project I'm working on uses Realm as a database. Everything works fine in Swift 1.2 on both, device and simulator. But I get this error with Swift 2.0 when running app on device:
fatal error: 'try!' expression unexpectedly raised an error: Error
Domain=io.realm Code=1 "open() failed: Operation not permitted"
UserInfo=0x145e2bc0 {Error Code=1, NSLocalizedDescription=open() failed:
Operation not permitted}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-
700.0.57.3/src/swift/stdlib/public/core/ErrorType.swift, line 50
Realm is being initialized with this base path:
NSSearchPathForDirectoriesInDomains(.DocumentDirectory,
.UserDomainMask, true).first!
i.e. user documents directory. I can access files with NSFileManager and actually see Realm files there.
Any clues how to debug this issue? Seems that Realm just crashes on initialization.