简体   繁体   English

Xcode中的Pod错误“Id:框架未找到Pods”

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

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 (use -v to see invocation) when trying to run an Xcode project in workspace. 我试图从bitbucket存储库克隆一个项目,并得到一个错误Id: framework not found Pods clang: error: linker command failed with exit code 1 (use -v to see invocation)尝试在工作区中运行Xcode项目时。 These are the steps I have followed, if anyone could let me know what I am doing wrong, that would be great! 这些是我遵循的步骤,如果有人能让我知道我做错了什么,那就太好了!

  1. git clone (link to bitbucket)
  2. changed the configuration settings in the Xcode pods project to none for both debug and release 对于调试和发布,将Xcode pods项目中的配置设置更改为none
  3. performed pod install 执行pod install
  4. opened Xcode workspace file 打开Xcode工作区文件
  5. tried to build in Xcode and received the error Id: framework not found Pods clang: error: linker command failed with exit code 1 (use -v to see invocation) 试图在Xcode中构建并收到错误Id: framework not found Pods clang: error: linker command failed with exit code 1 (use -v to see invocation)

Edit Here is the podfile: 编辑这是podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

target 'Oncarb' do
  pod 'Alamofire'
  pod 'SwiftyJSON', '~> 2.2.0'
end

#target 'OncarbTests' do
#  pod 'Alamofire'
#  pod 'SwiftlyJSON', '~> 2.2.0'
#end

Is there a step I am missing? 我缺少一步吗?

Thank you! 谢谢!

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 删除Pods框架
  7. Add Alamofire and SwiftyJSON 添加Alamofire和SwiftyJSON

In my case, it didn't work unless I removed the pods frameworks, but I get the feeling that this is a workaround. 就我而言,除非我删除了pods框架,否则它不起作用,但我觉得这是一种解决方法。 Perhaps someone with more experience can comment. 也许有经验的人可以发表评论。

Sometimes after renaming a target or moving something, you can corrupt your pods installation. 有时在重命名目标或移动某些内容后,您可能会损坏您的pod安装。 Luckily, there's an easier way to fix it than sudo make install 's solution. 幸运的是,有一种比sudo make install的解决方案更容易解决的问题。

  1. Run pod deintegrate to remove any trace of Cocoapods from your project. 运行pod deintegrate以从项目中删除任何Cocoapods的痕迹。
  2. Run pod install again to add it all back. 再次运行pod install以将其全部添加回来。

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. 这些是以前的Podfile配置遗留下来的。 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. 将Cocoapods框架显式导入测试类/测试目标的一个可能原因。

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 . 我首先导入了AlamofireImage因为我在AlamofireImage定义的测试中明确使用了typealias Image

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. 我刚刚将Image的定义复制到我的测试类文件中。

If you think you really need that import, go on with the answer of William Hu. 如果你认为你真的需要那个导入,请继续回答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. 您只需要将那些pod添加到测试目标,您需要(明确地)导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM