Libraries not found when using CocoaPods with iOS logic tests

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

    I had issues using OpenCV under XCTest. It was giving me linker errors of Undefined symbols for architecture arm64 for classes like cv::Mat. I am installing OpenCV through CocoaPods using pod 'OpenCV', '~> 2.0' under the main target. No matter how hard I tried to put the OpenCV dependency under the test target or use inherit! :search_paths none of it worked. The solution was to create an abstract_target like so:

    # Uncomment the next line to define a global platform for your project
    platform :ios, '6.1.6'
    
    abstract_target 'Shows' do
      pod 'RMVision', path: '../..'
      pod 'RMShared', path: '../../../RMShared'
      pod 'OpenCV', '~> 2.0'
    
      target 'RMVisionSample' do
        # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
        # use_frameworks!
    
        # Pods for RMVisionSample
      end
    
      target 'RMVisionSampleTests' do
        # inherit! :search_paths
        # Pods for testing
      end
    
      target 'RMVisionBenchmarks' do
        # inherit! :search_paths
        # Pods for testing
      end
    
    end 
    
    

    Also useful are the pod deintegrate & pod clean commands which help to cleanup the project and make sure that you start fresh when testing. You can install those two using [sudo] gem install cocoapods-deintegrate cocoapods-clean.

提交回复
热议问题