I'm currently trying to build unit tests for an iOS Cocoa Touch Framework, which depends on Realm.framework and RealmSwift.framework to write values to a local database. These .frameworks are added to the Linked Frameworks and Libraries section in the target, as well as in the Link Binary With Libraries section under build phases. When I compile my project and run the tests, the following error occurs:
2017-08-22 11:44:04.835 xctest[58812:72591791] The bundle “AppKitTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2017-08-22 11:44:04.835 xctest[58812:72591791] (dlopen_preflight(/Users/dev/Library/Developer/Xcode/DerivedData/AppKit-hisgovyxeuiaawcmvdjpliaqtwbp/Build/Products/Debug-iphonesimulator/AppKitTests.xctest/AppKitTests): Library not loaded: @rpath/Realm.framework/Realm
Referenced from: /Users/dev/Library/Developer/Xcode/DerivedData/AppKit-hisgovyxeuiaawcmvdjpliaqtwbp/Build/Products/Debug-iphonesimulator/AppKitTests.xctest/AppKitTests
Reason: image not found)
Program ended with exit code: 82
My project does not make use of dynamic libraries, CocoaPods or any other dependency manager for now, since this is a proof of concept. I think this is arising because the Test Target does not have access to Realm or RealmSwift, but I am not sure about how to add it so that my test bundle is not missing resources. I have already attempted suggestions to clear derived data, restart Xcode and clean my builds before testing, and I'm currently using Xcode 8.3.3.