Pod Error in Xcode “Id: framework not found Pods”

后端 未结 5 445
余生分开走
余生分开走 2020-12-04 19:22

I am trying to clone a project from a bitbucket repository and am getting an error Id: framework not found Pods clang: error: linker command failed with exit code 1 (u

5条回答
  •  执笔经年
    2020-12-04 19:49

    One possible cause in an explicit import of a Cocoapods framework into a test class / into the test target.

    Example:

    import XCTest
    //import AlamofireImage
    @testable import MyProject
    
    // instead of importing AlamofireImage:
    #if os(iOS) || os(tvOS) || os(watchOS)
        import UIKit
        public typealias Image = UIImage
    #elseif os(macOS)
        import Cocoa
        public typealias Image = NSImage
    #endif
    

    I first imported AlamofireImage because I explicitly used typealias Image in my test as defined in AlamofireImage.

    If it is as easy to prevent an import as in my example, do it. I just copied the definition of Image into my test class file.

    If you think you really need that import, go on with the answer of William Hu. A footnote to his answer:

    target 'MyProjectTests' do
       pod 'OnlyThatFrameworkYouImportIntoYourTest' 
    end
    

    You need to add only those pods to your test target, that you (need to) import explicitly.

提交回复
热议问题