I'm trying to add new tests in Swift to an existing KIF test bundle currently written in Objective C.
Set up:
I've set up the Swift bridging header, importing KIF and the other relevant parts of my project to make these available to Swift.
I've reduced things down to a simple test case, which doesn't even use KIF at this stage:
import Foundation
class MyFirstTest : KIFTestCase {
func testOne() {
NSLog("Done")
}
}
The test bundle builds fine, but when I run I get:
2015-07-03 14:52:32.620 MyApp[1104:204793] Error loading /private/var/mobile/Containers/Data/Application/F20A664E-BD2D-4299-A93F-4C6758CBAF34/tmp/MyApp_UI_Tests.xctest/MyApp_UI_Tests: dlopen(/private/var/mobile/Containers/Data/Application/F20A664E-BD2D-4299-A93F-4C6758CBAF34/tmp/MyApp_UI_Tests.xctest/MyApp_UI_Tests, 262): Library not loaded: @rpath/libswiftXCTest.dylib
Referenced from: /private/var/mobile/Containers/Data/Application/F20A664E-BD2D-4299-A93F-4C6758CBAF34/tmp/MyApp_UI_Tests.xctest/MyApp_UI_Tests
Reason: image not found DevToolsBundleInjection: Error loading bundle '/private/var/mobile/Containers/Data/Application/F20A664E-BD2D-4299-A93F-4C6758CBAF34/tmp/MyApp_UI_Tests.xctest'
I have tried the suggestions here, including:
I've also tried:
I've also seen suggestions that this could be related to the code signing identity, but the bundle fails to load on the simulator with the dev identity as well as on a real device.
If I revert back to only using Objective C tests, everything works fine.
What have I missed?
Finally figured it out. For me, the solution was to make sure the runpath setting for the test bundle target included @loader_path/Frameworks as well as @executable_path/Frameworks.
As soon as I added that, everything loaded fine.