Reputation: 11
I installed RealmSwift using CocoaPods, and am importing RealmSwift without any problems. However, I'm getting a weird error when I'm trying to use it. When I do:
let realm = try! RealmSwift.Realm()
I get this error:
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=0 "Schema validation failed due to the following errors:
- Target type 'RealmSwiftObject' doesn't exist for property 'articles'.
- Target type 'RealmSwiftObject' doesn't exist for property 'favorites'." UserInfo={NSLocalizedDescription=Schema validation failed due to the following errors:
- Target type 'RealmSwiftObject' doesn't exist for property 'articles'.
- Target type 'RealmSwiftObject' doesn't exist for property 'favorites'.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.1.101.15/src/swift/stdlib/public/core/ErrorType.swift, line 50
Upvotes: 1
Views: 400
Reputation: 129
After import RealmSwift
in your class.
You can use like this:
class FooClass {
let realm = try! Realm()
func bar()
{
try! realm.write {
// do stuff
}
}
}
Upvotes: 1