Xcode Unit Testing with Cocoapods

前端 未结 14 1091
有刺的猬
有刺的猬 2020-12-07 11:52

I\'ve been banging my head against a wall with this for the last few days but despite multiple Google/SO/Github searches I can\'t find a resolution to the issues I\'m having

相关标签:
14条回答
  • 2020-12-07 12:04

    Adding ${SRCROOT}/Pods/Firebase/CoreOnly/Sources into the unit test target's "Header search paths" fixed the problem. Steps:

    1. Select your unit tests target
    2. Go to Build Settings
    3. Search for header search path
    4. Add ${SRCROOT}/Pods/Firebase/CoreOnly/Sources

    After this the tests can run and the error will disappear.

    0 讨论(0)
  • 2020-12-07 12:05
    1. Select your Unit Test Target setting.
    2. Go to Build Settings.
    3. Look for Header Search Paths.
    4. Add this value $(SRCROOT)/Pods with recursive, then Xcode will resolve the path for you.

    Example

    0 讨论(0)
  • 2020-12-07 12:08

    A simpler method that also works:

    target 'MyApp' do
        pod 'Firebase/Auth'
        pod 'Firebase/Database'
        pod 'Firebase/Storage'
    
        target :MyAppTests
    end
    
    0 讨论(0)
  • 2020-12-07 12:13

    I had a similar problem. Phrased in terms of your question, I copied the contents of my MyApp.<configuration>.xcconfig file to my MyAppTests.<configuration>.xcconfig file. I cleaned and built the tests, and it worked.

    0 讨论(0)
  • 2020-12-07 12:15

    Missing required module Firebase NO CocoaPods solution

    For those who encounter the same problem but NOT using CocoaPods:

    If you're using Firebase, than you have some folder containing Firebase.h and module.modulemap file. For example - YOUR_PROJECT_DIR/Linking

    If your Main project target is working correct way, than you should go to ProjectSettings -> Targets. Select test target. Search for User headers and add the path to YOUR_PROJECT_DIR/Linking. Select recursive option and you should be good to go.

    See the screenshot for more details:

    0 讨论(0)
  • 2020-12-07 12:16

    Try changing the inheritance to :complete, as in:

    target 'MyAppTests' do
        inherit! :complete
    end
    

    Importantly it allows anyone else checking out your repo to just do a pod update as usual without having to copy .xcconfig files or other hackery just to build.

    0 讨论(0)
提交回复
热议问题