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

≯℡__Kan透↙ 提交于 2019-11-27 11:47:09

This has fixed it for me:

  1. Open up the workspace.
  2. Click on the blue project icon (that expands into your file tree) on the left hand side of the screen
  3. Just to the right, select "Targets" (as opposed to "Project"--Project is blue, Target is like a pencil and a ruler and a paintbrush making a triangle)
  4. Click on the General tab
  5. Go to the "Linked Frameworks and Libraries" section (all the way at the bottom)
  6. Delete the Pods frameworks
  7. Add Alamofire and SwiftyJSON

In my case, it didn't work unless I removed the pods frameworks, but I get the feeling that this is a workaround. Perhaps someone with more experience can comment.

Sometimes after renaming a target or moving something, you can corrupt your pods installation. Luckily, there's an easier way to fix it than sudo make install's solution.

  1. Run pod deintegrate to remove any trace of Cocoapods from your project.
  2. Run pod install again to add it all back.

That's it, fixed.

My issues is when i ran test i got this error. Because i just install it in my

target 'Project' do
   pod 'xxx'
end

You should also add it into your test target:

target 'ProjectTests' do
   pod 'xxx'
end

In my case, I had several frameworks listed in red. These were left over from previous Podfile configurations. I simply removed these frameworks listed in red and the problem was fixed.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!