I wrote a simple XCTest which try to access a property of a Realm object, declared as a List[anotherRealmObject].
Build and execute tests
Build correctly but testing fails.
Execute the following test on a similar model.
This is my model definition:
public class First: Object {
var items = List<Second>()
}
public class Second: Object, Comparable {
@objc dynamic var id: String = ""
}
This is the test:
func test() {
let first = First()
let second = Second()
first.items.append(second) // This wrapped inside write transaction. It stores correctly.
for i in First.items {
.... /// CRASH WHEN ACCESS First.items
}
Here the error produced when test run:
Undefined symbols for architecture arm64:
"__T010RealmSwift4ListCMa", referenced from:
__T010RealmSwift4ListCy64ItemCGMa in myclass.o
"__T010RealmSwift4ListC12makeIteratorAA11RLMIteratorVyxGyF", referenced from:
__T011myclassAAC31testGetCatalogWithParameterTypeyyFySbcfU_ in myclass.o
"__T010RealmSwift11RLMIteratorVMa", referenced from:
__T010RealmSwift11RLMIteratorVy64ItemCGMa in myclass.o
"__T010RealmSwift6ObjectCAA0A15CollectionValueAAWP", referenced from:
__T010RealmSwift4ListCy64ItemCGMa in myclass.o
__T010RealmSwift11RLMIteratorVy64ItemCGMa in myclass.o
"__T010RealmSwift11RLMIteratorV4nextxSgyF", referenced from:
__T011myclassAAC31testGetCatalogWithParameterTypeyyFySbcfU_ in myclass.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Realm framework version: 3.0.2
Realm Object Server version: not used
Xcode version: 9.1 (9B55)
iOS/OSX version: 10.13.1
Dependency manager + version: cocoapod 1.3.1
@matteodanelli Try to add "import RealmSwift" to the test file
Apparently, it seems solved adding pod RealmSwift to test target inside _Podfile_
Glad to hear that adding the dependency to the test target worked! Apologies for not getting to your issue earlier. If you run into any more problems feel free to file more issues and we'll do our best to help you.
Most helpful comment
Apparently, it seems solved adding
pod RealmSwiftto test target inside _Podfile_