Testing iOS modules: the class is implemented as in

I am building an application for iOS 9 with Swift 2 and Xcode 7.

My application works fine when deploying it to my phone, but when I run some unit test, I get the following error message for many classes:

Class _TtC5<AppName>19<ClassName> is implemented in both/Users/<Username>/Library/Developer/CoreSimulator/Devices/<UUID>/data/Containers/Bundle/Application/<UUID</<AppName>.app/<AppName> and/Users/<Username>/<Path/To/Workspace>/DerivedData/<AppName>/Build/Products/Debug-iphonesimulator/<AppName>.xctest/<AppName>. One of the two will be used. Which one is undefined.

Any ideas?

+5
source share
3 answers

Add only a test class to your target and none of the iPhone application classes. Then simply import your application name as a module on top of your test class to gain access to all application classes.

 import MyAppName 
+4
source

The answer to @Mundi is correct for some cases.

However, I experienced the same error, and the reason for this is because the libPods.a file for Cocoa Pods was linked in the target application and the test target.

0
source

Duplicate class implementations when running a test suite: in my case, since the target of the test is the host application , you do not need to bundle third-party frameworks. I had to clear the โ€œOther linker flagsโ€ ( OTHER_LDFLAGS ) from the build settings because it linked to all CocoaPods in the workspace.

0
source

Source: https://habr.com/ru/post/1234104/


All Articles