"Class X is implemented in both" when performing unit tests in a project using Cocoapods

I added the unit test target to an existing project that uses Cocoapods.

When I started the tests, it ran an iOS simulator, and I had a bunch of warnings on the Xcode console:

The PodsDummy_Pods class is implemented as in / Users / me / Library / Developer / CoreSimulator / Devices / 604372F1-E934-445C-B8F6-3D8C86AA8E41 / data / Containers / Bundle / Application / 2A1BCAE6-5127-4288-B0E7-15588A1C09D1 / Myapp. as well as / Users / me / Library / Developer / Xcode / DerivedData / MyApp -fzjqljiyaapspvaylhszcbkhtijd / Build / Products / Debug-iphonesimulator / MyAppTests.xctest / MyAppTests. One of the two will be used. Which one is undefined.

This error message appears for every class contained in the module used by my project.

At the end, the project throws EXC_BAD_ACCESS

When I typed bt in the Xcode console, this happens as an endless loop of this error:

frame # 130498: 0x000000012626e897 MyAppTests` ___ lldb_unnamed_function42 $$ MyAppTests + 135

Any suggestion?

+5
source share
1 answer

Finally found a solution to this problem! For my part, I had this problem with my express modules. My subfile looked like this:

 def import_gtm send :pod, 'GoogleTagManager', '~> 5.0.8' end target 'MyFramework' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for MyFramework import_gtm end target 'MyFrameworkTests' do use_frameworks! # Pods for testing end 

Despite the fact that my tests performed correctly, I had a lot of logs, like the OP. After reading this Github issue, I changed my subfile to the following:

 def import_gtm send :pod, 'GoogleTagManager', '~> 5.0.8' end target 'MyFramework' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for MyFramework import_gtm target 'MyFrameworkTests' do inherit! :search_paths end end 

I finally got rid of all these warnings! Try to clear before rebuilding (cmd + alt + shift + K) or delete the contents of the DerivedData folder:

 rm -rf ~/Library/Developer/Xcode/DerivedData/* 

Hope this helps!

+1
source

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


All Articles