Libraries not found when using CocoaPods with iOS logic tests

前端 未结 14 1395
没有蜡笔的小新
没有蜡笔的小新 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:31

    As of CocoaPods 1.x, there's a new way to declare shared dependencies between a target and the corresponding test target. I'd been using the accepted solution by Mark Struzinski to this point, but using this method yielded a massive number of warnings when running my tests that:

    Class SomeClass is implemented in both /Path/To/Test/Target and /Path/To/App/Target. One of the two will be used. Which one is undefined.
    

    With CocoaPods 1.x we can declare our -Test target as inheriting via the parent target's search paths, like so:

    target 'MyApp' do
        pod 'aPod'
        pod 'anotherPod'
        project 'MyApp.xcodeproj'
    end
    target 'MyAppTests' do
        inherit! :search_paths
        project 'MyApp.xcodeproj'
    end
    

    This will result in the -Test target having access to the dependencies of the app target, without multiple binary copies. This has seriously sped up test build times for me.

提交回复
热议问题