Libraries not found when using CocoaPods with iOS logic tests

前端 未结 14 1364
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 15:41

I am trying to write some iOS logic tests against classes in my project that use functionality from some of the libraries in my podspec. I am using the standard unit test bu

14条回答
  •  旧巷少年郎
    2020-11-29 16:26

    I added :exclusive => true to avoid duplicated symbol errors in the application test target.

    target 'myProjectTests', :exclusive => true do
       pod 'OCMock', :head
       pod 'XCTAsyncTestCase', :git => 'https://github.com/iheartradio/xctest-additions.git'
    end
    
    link_with 'myProject', 'myProjectTests'
    

    When I changed the application test target to the logic unit test one, the linker error occurs. After I remove :exclusive => true, everything works again.

    target 'myProjectTests', do
       pod 'OCMock', :head
       pod 'XCTAsyncTestCase', :git => 'https://github.com/iheartradio/xctest-additions.git'
    end
    
    link_with 'myProject', 'myProjectTests'
    

    :exclusive => true states that everything outside do...end should NOT be linked to myProjectTests, which is reasonable in application test targets, but it will cause linker errors in logic test targets.

提交回复
热议问题