ios Xcode 中的 Pod 错误“Id:框架未找到 Pod”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31139534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pod Error in Xcode "Id: framework not found Pods"
提问by Pami
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. These are the steps I have followed, if anyone could let me know what I am doing wrong, that would be great!
我正在尝试从 bitbucket 存储库中克隆一个项目,但Id: framework not found Pods clang: error: linker command failed with exit code 1 (use -v to see invocation)
在尝试在工作区中运行 Xcode 项目时出现错误。这些是我遵循的步骤,如果有人能让我知道我做错了什么,那就太好了!
git clone (link to bitbucket)
- changed the configuration settings in the Xcode pods project to
none
for both debug and release - performed
pod install
- opened Xcode workspace file
- 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)
git clone (link to bitbucket)
- 将 Xcode pods 项目中的配置设置更改
none
为调试和发布 - 执行
pod install
- 打开的 Xcode 工作区文件
- 尝试在 Xcode 中构建并收到错误
Id: framework not found Pods clang: error: linker command failed with exit code 1 (use -v to see invocation)
EditHere 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!
谢谢!
回答by sudo make install
This has fixed it for me:
这已经为我修复了:
- Open up the workspace.
- Click on the blue project icon (that expands into your file tree) on the left hand side of the screen
- 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)
- Click on the General tab
- Go to the "Linked Frameworks and Libraries" section (all the way at the bottom)
- Delete the Pods frameworks
- Add Alamofire and SwiftyJSON
- 打开工作区。
- 单击屏幕左侧的蓝色项目图标(扩展到您的文件树)
- 就在右边,选择“目标”(与“项目”相反——项目是蓝色的,目标就像一支铅笔、一把尺子和一支画笔形成一个三角形)
- 单击常规选项卡
- 转到“链接的框架和库”部分(一直在底部)
- 删除 Pods 框架
- 添加 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. Perhaps someone with more experience can comment.
就我而言,除非我删除 pods 框架,否则它不起作用,但我觉得这是一种解决方法。也许有更多经验的人可以发表评论。
回答by Ni?oScript
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.
有时在重命名目标或移动某些内容后,您可能会损坏 pod 安装。幸运的是,有比sudo make install
的解决方案更简单的修复方法。
- Run
pod deintegrate
to remove any trace of Cocoapods from your project. - Run
pod install
again to add it all back.
- 运行
pod deintegrate
以从您的项目中删除任何 Cocoapods 痕迹。 pod install
再次运行以将其全部添加回来。
That's it, fixed.
就是这样,固定。
回答by William Hu
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
回答by Gerd Castan
One possible cause in an explicitimport 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
是因为我typealias Image
在测试中明确使用了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.
如果像在我的示例中那样容易防止导入,请执行此操作。我只是将 Image 的定义复制到我的测试类文件中。
If you think you really need that import, go on with the answer of William Hu. A footnote to his answer:
如果您认为您真的需要导入,请继续阅读 William Hu 的答案。他的回答的脚注:
target 'MyProjectTests' do
pod 'OnlyThatFrameworkYouImportIntoYourTest'
end
You need to add only those pods to your test target, that you (need to) import explicitly.
您只需要将那些 pod 添加到您的测试目标,您(需要)显式导入。
回答by Andrew
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.
就我而言,我有几个用红色列出的框架。这些是以前 Podfile 配置遗留下来的。我只是删除了这些以红色列出的框架,问题就解决了。