ios 错误:ld:找不到带有 CocoaPods 的 -lPods 的库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23489920/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 00:04:51  来源:igfitidea点击:

Error: ld: library not found for -lPods with CocoaPods

iosobjective-ccocoapodsdtcoretext

提问by Davis

after i installed DTCoreText (https://github.com/Cocoanetics/DTCoreText) with Cocoapods i always get an error when i try to run the simulator or device!

在我使用 Cocoapods安装 DTCoreText ( https://github.com/Cocoanetics/DTCoreText) 后,当我尝试运行模拟器或设备时,总是出现错误!

ld: warning: directory not found for option '-L/Users/example/Desktop/ios/Pods/build/Release-iphoneos'
ld: warning: directory not found for option '-L/Users/example/Desktop/ios/Pods/build/Debug-iphoneos'
ld: library not found for -lPods-example
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

in my "Link Binary With Libraries" the "libPods" Part is red:

在我的“Link Binary With Libraries”中,“libPods”部分是红色的:

enter image description here

在此处输入图片说明

Here are my build Settings:

这是我的构建设置:

The Settings of my Project:

我的项目的设置:

enter image description here

在此处输入图片说明

The Settings of my Pods:

我的 Pod 的设置:

enter image description here

在此处输入图片说明

EDIT:

编辑:

I′m not exactly sure what was the Problem, but I solved it when i deleted all the DTCoreText and Cocoapods stuff and reeinstalled everything again!

我不完全确定问题是什么,但是当我删除所有 DTCoreText 和 Cocoapods 内容并重新安装所有内容时,我解决了它!

回答by gemmakbarlow

Suggest trying the following, that worked for me:

建议尝试以下对我有用的方法:

a) Search from 'Library' from the Target Settings view and double-click to inspect the value of Library Search Paths

a) 从“目标设置”视图中的“库”中搜索并双击以检查 Library Search Paths

b) There are two values listed $(inherited)and $(PROJECT_DIR)/Pods/build/Debug-iphoneos. Delete the latter.

b) 列出了两个值$(inherited)$(PROJECT_DIR)/Pods/build/Debug-iphoneos。删除后者。

c) Do a full clean, build & run

c) 彻底清理、构建和运行

d) Run pod installagain. Notice that the entry is not restored.

d)pod install再次运行。请注意,该条目未恢复。

回答by kudinovdenis

Also this may help:

这也可能有帮助:

  1. In your main project (not Pods) select the main target
  2. Go to the Build Phasestab
  3. Go to Link Binary with Libraries
  4. Remove the library that is causing the problem (it would probably be in red color)
  1. 在你的主项目(不是 Pods)中选择主目标
  2. 转到构建阶段选项卡
  3. 转到链接二进制与库
  4. 删除导致问题的库(它可能是红色的)

回答by Hsm

Make sure you are opening the .xcworkspace file, not the .xcodeproj

确保您打开的是 .xcworkspace 文件,而不是 .xcodeproj

回答by bobics

In my linked binaries I had both libPods.aand libPods-MyProj.a. I had previously updated my Podfile to have TWO separate targets (to get it compile tests in Swift with bridging), which meant I had to manually delete the old libPods.adependency.

在我链接的二进制文件中,我同时拥有libPods.alibPods-MyProj.a. 我之前已经将我的 Podfile 更新为有两个单独的目标(以使其在 Swift 中通过桥接编译测试),这意味着我必须手动删除旧的libPods.a依赖项。

回答by John Dunne

I've found that $(inherited)was missing from my Other Linker Flagsbuild setting. Applying this option fixed a missing library issue I was seeing.

我发现$(inherited)我的其他链接器标志构建设置中缺少它。应用此选项修复了我看到的缺少库的问题。

回答by StackRunner

I found that selecting "Find implicit Dependencies" (under product / edit scheme) will resolve this issue instead of having to add pods as a target.

我发现选择“查找隐式依赖项”(在产品/编辑方案下)将解决此问题,而不必添加 pod 作为目标。

回答by Kent Ke

Look for "Library Search Path" in you target's Build Settings page. change the folder name of Debug from Debug-iphoneos to Debug-iphonesimulator

在目标的构建设置页面中查找“库搜索路径”。将 Debug 的文件夹名称从 Debug-iphoneos 更改为 Debug-iphonesimulator

回答by Thomas K?hn

Make sure the missing pods library gets actually built. To do so, open the Build Scheme

确保缺失的 pods 库得到实际构建。为此,请打开构建方案

Product > Scheme > Edit Scheme... > Build

Product > Scheme > Edit Scheme... > Build

add the Pods target and put it before the target that complained about the library missing (in my case this were the UI tests – I just struggled with this for hours...)

添加 Pods 目标并将其放在抱怨库丢失的目标之前(在我的情况下,这是 UI 测试 - 我只是为此苦苦挣扎了几个小时......)

回答by FranticRock

For me the error was: that the Pods target did not contain the required architecture slice for i386. So i clicked on the Pods project --> Pods-ProjectName target, and in Build Settings, turned Build Active Architecture Only to NOfor both Debugand Release. This makes sure both the Simulator and Device slices are built. The simulator uses the i386 architecture, and the actual devices use x86-64. So you have to make sure all dependent targets for all dependent projects are building both, if you want to run on both Simulator and side loading to devices also.

对我来说,错误是:Pods 目标不包含 i386 所需的架构切片。所以,我点击了荚项目- >豆荚,项目名的目标,并在生成设置,打开构建有源体系只为NO两种调试发布。这可确保构建模拟器和设备切片。模拟器使用i386架构,实际设备使用x86-64。所以你必须确保所有依赖项目的所有依赖目标都同时构建,如果你想同时在模拟器上运行和侧面加载到设备。

回答by Tony

There are so many reason caused this problem.

造成这个问题的原因有很多。

We need to check:

我们需要检查:

  • Build setting $(inherited)
  • Detect all implicit dependencies
  • .......
  • 构建设置 $(inherited)
  • 检测所有隐式依赖
  • ......

Troubleshooting: http://guides.cocoapods.org/using/troubleshooting.html

故障排除http: //guides.cocoapods.org/using/troubleshooting.html