简体   繁体   English

Xcode - ld:找不到 -lPods 的库

[英]Xcode - ld: library not found for -lPods

I get these errors when I try to build an iOS application.当我尝试构建 iOS 应用程序时出现这些错误。

ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Ld /Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator/Totalbox.app/Totalbox normal x86_64
cd /Users/Markus/Development/xcode/totalbox-ios
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator -F/Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator -filelist /Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Intermediates/Totalbox.build/Debug-iphonesimulator/Totalbox.build/Objects-normal/x86_64/Totalbox.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -framework CoreGraphics -framework Foundation -framework MobileCoreServices -framework QuartzCore -framework Security -framework SystemConfiguration -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -framework CoreGraphics -framework UIKit -framework Foundation -lPods -Xlinker -dependency_info -Xlinker /Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Intermediates/Totalbox.build/Debug-iphonesimulator/Totalbox.build/Objects-normal/x86_64/Totalbox_dependency_info.dat -o /Users/Markus/Library/Developer/Xcode/DerivedData/Totalbox-clpeqwpfvwuhpleeejnzlavncnvj/Build/Products/Debug-iphonesimulator/Totalbox.app/Totalbox

PODS ROOT in the build settings:构建设置中的 PODS ROOT:

${SRCROOT}/Pods

I didn't create this Xcode project - just pulled it from git to check it out.我没有创建这个 Xcode 项目 - 只是从 git 中拉出来检查一下。

如果项目使用 CocoaPods,请注意始终打开.xcworkspace文件而不是.xcodeproj文件。

Had this problem as well.也有这个问题。 Something was wrong with my CocoaPods installation.我的 CocoaPods 安装出了点问题。 No pods other than KIF were installing properly.除了 KIF 之外,没有其他 Pod 安装正确。 I followed the comments on this thread to be of help.我按照此线程上的评论来提供帮助。

Basically, I needed to ensure that Build Active Architectures Only settings for both my project and the Pods project were equal.基本上,我需要确保我的项目和 Pods 项目的Build Active Architectures Only设置相同。

After hours of research this solution worked for me:经过数小时的研究,这个解决方案对我有用:

(disclaimer: results may vary due to circumstances) (免责声明:结果可能因情况而异)

the Library not found -lPods-(someCocoapod) error was due to multiple entries in the : Library not found -lPods-(someCocoapod)错误是由于以下内容中的多个条目造成的:

Settings(Target) > Build Settings > Linking > 'Other Linker Flags'

A lot of other posts had me look there and I would see changes to the error when I messed around with the entries, but I kept getting some variation on the same error.许多其他帖子让我在那里查看,当我弄乱条目时,我会看到错误的变化,但我一直在同一错误上得到一些变化。

Too many hours lost ...浪费了太多时间...

My Fix:我的修复:

remove the -lPods-(someCocoaPod) lines in the 'Other Linker Flags' list BUT only if $(inherited) is at the top.删除“其他链接器标志”列表中的 -lPods-(someCocoaPod) 行,仅当 $(inherited) 位于顶部时。 At first I was unsure, but the reassuring sign was that I still saw references to my cocoapods when I left the edit mode(inherited).起初我不确定,但令人放心的迹象是,当我离开编辑模式(继承)时,我仍然看到对我的 cocoapods 的引用。 I tested in debug and release, both of which were giving me errors, and the problem was immediately resolved.我在调试和发布中进行了测试,两者都给了我错误,问题立即得到解决。

It seems project has been using cocoapods .似乎项目一直在使用cocoapods and that files are missing from your project.并且您的项目中缺少该文件。

You cant just download it from git.你不能只从 git 下载它。 You need to install it from cocoapods.您需要从 cocoapods 安装它。

for more help, you may follow Introduction to CocoaPods Tutorial如需更多帮助,您可以 参考 CocoaPods 介绍教程

If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file如果项目使用CocoaPods注意始终打开.xcworkspace文件而不是.xcodeproj文件

我的问题已通过以下配置解决:

Build Active Architecture Only: YES

If you have multiple targets in your project, Cocoapods may have only integrated itself well with just one of them.如果您的项目中有多个目标,则 Cocoapods 可能只与其中之一很好地集成在一起。

I had to manually link to libPods.a in "Link Binary With Libraries" for each additional target I had.对于我拥有的每个附加目标,我必须在“Link Binary With Libraries”中手动链接到libPods.a

libPods.a 在我的框架列表中

If anyone came here to resolve an error with react-native-fbsdk after installing it using Cocoapods , keep in mind that you have to remove all the other .a files in your Projects build phases and only keep the .a from cocoapods called libPods-WhateverAppName.a .如果有人在使用Cocoapods安装react-native-fbsdk后来到这里解决错误,请记住,您必须在项目构建阶段删除所有其他 .a 文件,并且只保留名为libPods-WhateverAppName.a cocoapods 中的libPods-WhateverAppName.a

只剩下这里了

This is usually caused from running rnpm link and the way rnpm works.这通常是由运行rnpm link和 rnpm 的工作方式引起的。

After I removed the facebook core .a file from my build phases my project was up and running once again.在我从构建阶段删除 facebook 核心 .a 文件后,我的项目再次启动并运行。

This problem-related to lPods can be fixed by following the steps below可以按照以下步骤修复与 lPods 相关的此问题

  • Select your Project Target.选择您的项目目标。
  • Go to "Build Phases" in "Link Binary With Libraries" .转到"Build Phases" "Link Binary With Libraries" "Build Phases"中的"Build Phases" "Link Binary With Libraries"
  • Now remove ".a" file of that library which is creating the problem.现在删除产生问题的那个库的".a"文件。
  • Clean and Build.清洁和建造。

This will work.这将起作用。

None of the above answers fixed it for me.以上答案都没有为我解决。

What I had done instead was run pod install with a pod command outside of the target section.我所做的是在target部分之外使用pod命令运行pod install So for example:例如:

#WRONG
pod 'SOMEPOD'

target "My Target" do
    pod 'OTHERPODS'
end

I quickly fixed it and returned the errant pod back into the target section where it belonged and ran pod install again:我很快修复了它并将错误的 pod 返回到它所属的target部分并再次运行pod install

# CORRECT
target "My Target" do
    pod 'SOMEPOD'
    pod 'OTHERPODS'
end

But what happened in the meantime was that the lib -libPods.a got added to my linked libraries, which doesn't exist anymore and shouldn't since there is already the -libPods-My Target.a in there.但与此同时发生的事情是 lib -libPods.a被添加到我的链接库中,它不再存在,也不应该存在,因为那里已经存在-libPods-My Target.a

So the solution was to go into my Target's General settings and go to Linked Frameworks and Libraries and just delete -libPods.a from the list.所以解决方案是进入我的目标的常规设置并转到链接框架和库-libPods.a从列表中删除-libPods.a

Had a same issue after upgrading Deployment target from 7.0 to 8.0 and enabling use_frameworks!Deployment target7.0升级到8.0并启用use_frameworks!后遇到了同样的问题use_frameworks!

cocoapods did not delete previously generated PodName.a files from the Frameworks section of my project. cocoapods没有从我项目的Frameworks部分删除以前生成的PodName.a文件。

So I had to delete those manually, because they caused the linker error所以我不得不手动删除它们,因为它们导致了linker error

My steps:我的步骤:

  1. Delete the pods folder and the 'Pods' file.删除 pods 文件夹和“Pods”文件。
  2. Type "pod install" into Terminal.在终端中输入“pod install”。
  3. Type "pod update" into Terminal.在终端中输入“pod update”。

In addition to making sure "Build Active Architectures" was set to YES as mentioned in previous answers, this was what had done it for me.除了像之前的答案中提到的那样确保“构建活动架构”设置为“是”之外,这就是为我所做的。

Delete all the corresponding files/folders of imported cocoapods source except podfile.删除所有导入的cocoapods源的对应文件/文件夹,除了podfile。

install cocoapod again.This should clear any redundant pull from the original source.再次install cocoapod 。这应该清除原始来源的任何冗余拉取。

This was my issue while trying to integrate Firebase to my Xcode project using cocoapods这是我尝试使用cocoapodsFirebase集成到我的 Xcode 项目时的问题

library not found for -lGoogleToolboxForMac
linker command failed with exit code 1 (use -v to see invocation)

After hours of searching and trying out various fixes listed in the stackoverflow, my issue was finally fixed doing following steps经过数小时的搜索和尝试stackoverflow中列出的各种修复程序,我的问题终于通过以下步骤得到解决

  1. Go to Build Settings , search for Other Linker Flags , remove all values expect $(inherited)转到Build Settings ,搜索Other Linker Flags ,删除所有期望$(inherited)图片

Do this for all targets.对所有目标执行此操作。

  1. Delete the pods folder.删除 pods 文件夹。 ( ios/Pods ) ( ios/Pods )
  2. Do pod updatepod update

Voila!瞧! All linker errors will be gone.所有链接器错误都将消失。

When you clone project from somewhere which uses Cocoapods you need to install them to your project.当您从使用 Cocoapods 的某个地方克隆项目时,您需要将它们安装到您的项目中。

Here step-by-step what you need to do:以下是您需要做的分步说明:

  • 1) clone source code to local machine; 1) 将源代码克隆到本地机器;
  • 2) close the xcode project (if open); 2)关闭xcode项目(如果打开);
  • 3) install cocoapods application on your mac by running this command in terminal: " gem install cocoapods ", add " sudo " in the beginning if did not work; 3)通过在终端中运行以下命令在Mac上安装cocoapods应用程序:“ gem install cocoapods ”,如果不起作用,请在开头添加“ sudo ”;
  • 4) go to the root of your xcode project by using " cd " command in terminal; 4)在终端中使用“ cd ”命令转到xcode项目的根目录;
  • 5) you should have Podfile in this folder; 5)你应该在这个文件夹中有Podfile; if you want to double check it use: " cat Podfile " command, it will display the content of this file with Libraries that will have to be installed to your project;如果您想仔细检查它,请使用:“ cat Podfile ”命令,它将显示该文件的内容以及必须安装到您的项目中的库;
  • 6) then use " pod install " command to download and install the Libraries to your project; 6)然后使用“ pod install ”命令将库下载并安装到您的项目中; the Podfile.lock will be created and {Your project name}.xcworkspace file; Podfile.lock{Your project name}.xcworkspace文件将被创建;
  • 7) from now on you have to use {Your project name}.xcworkspace to open it in xcode; 7) 从现在起你必须使用{Your project name}.xcworkspace在 xcode 中打开它;

Good luck!祝你好运!

It took sometime to figure it out... I am trying to build swift framework which in turn depends on one cocoa pod library for which I was getting this error while creating build in release mode , in debug mode it was working fine!花了一些时间才弄明白...我正在尝试构建 swift 框架,该框架又依赖于一个可可豆库,我在发布模式下创建构建时遇到了这个错误,在调试模式下它工作正常!

I verified if all targets have same deployment target and found that there was mismatch pods target was having different iOS deployment target than my framework so I kept same iOS deployment target everywhere (swift framework, pod targets) and it worked like charm!我验证了所有目标是否具有相同的部署目标,并发现不匹配的 pods 目标与我的框架具有不同的 iOS 部署目标,因此我在任何地方(swift 框架、pod 目标)都保持相同的 iOS 部署目标,并且它的工作非常迷人!

在此处输入图片说明

For me, following had worked.对我来说,以下已经奏效了。

  1. Go to "Project Target -> Build Settings -> Preprocessing -> Preprocessor Macros".转到“项目目标 -> 构建设置 -> 预处理 -> 预处理器宏”。 Set "COCOAPODS=1" in all Debug, Integration, Release under "Preprocessor Macros"在“预处理器宏”下的所有调试、集成、发布中设置“COCOAPODS=1”
  2. Add the following in "Other Linker Flags" under "Project Target"在“项目目标”下的“其他链接器标志”中添加以下内容
    1. $inherited $继承
    2. -ObjC -ObjC
    3. -lc++ -lc++
    4. -all_load -all_load

Clean and run the project.清理并运行项目。 If still error receives the same then try by setting "Project Target -> Build Settings -> Build Active Architectures Only", Set "Debug" to "YES" and set "Integration and Release" to "No".如果仍然收到相同的错误,则尝试通过设置“项目目标 -> 构建设置 -> 仅构建活动架构”,将“调试”设置为“是”并将“集成和发布”设置为“否”。 Then Repeat the same setting of "Build Active Architectures Only" for all "Pods Targets"然后对所有“Pods Targets”重复相同的“Build Active Architectures Only”设置

Clean and run the project.清理并运行项目。 If you receive the following error如果您收到以下错误

 No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).

Then try Mr. Mike answer in this link然后在此链接中尝试 Mike 先生的回答

Xcode 5.1 - No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386) Xcode 5.1 - 没有要编译的架构(ONLY_ACTIVE_ARCH=YES,active arch=x86_64,VALID_ARCHS=i386)

Hope it helps!希望能帮助到你!

In a project with multiple targets I had the same issue after changing the Scheme and App name and tried to update pods.在具有多个目标的项目中,我在更改 Scheme 和 App 名称并尝试更新 pod 后遇到了同样的问题。 The issue was caused because of multiple entries in Build Phases -> Link Binary with Libraries where both the previous .a library and the current one was listed, while the previous one was not existing anymore.该问题是由于 Build Phases -> Link Binary with Libraries 中的多个条目引起的,其中列出了先前的 .a 库和当前的库,而先前的库已不存在。 Removing the library from there cleared the problem.从那里删除库解决了问题。

If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file.如果项目使用 CocoaPods,请注意始终打开 .xcworkspace 文件而不是 .xcodeproj 文件。 if you are using .xcworkspace , Please reinstall the pod file by removing the pods and again insert the pods and install it !!!如果您使用的是 .xcworkspace ,请通过删除 Pod 重新安装 Pod 文件,然后再次插入 Pod 并安装它!!! this worked for me这对我有用

My way我的方式

  1. create new project and install pod it will can run without error.创建新项目并安装 pod 它将可以正常运行。

  2. Copy text in "Other Linker Flags" in new project to old project.将新项目中“其他链接器标志”中的文本复制到旧项目。 Make old project to same new project.将旧项目转换为相同的新项目。

  3. Check "Header Search Paths" too.也检查“标题搜索路径”。

For me this is worked.对我来说这是有效的。 I have changed my app name from someApp to otherApp.我已将我的应用程序名称从 someApp 更改为 otherApp。 And I am using cocoa pods for multiple third party services integration.我正在使用可可豆荚进行多个第三方服务集成。 So Because of that 2 libPod files added(As I have changed name and target of app).因此,由于添加了 2 个 libPod 文件(因为我更改了应用程序的名称和目标)。 Finally I had to remove one libPod.最后我不得不删除一个 libPod。 And it worked.它奏效了。

target-> Build phases-> Link Binary With Libraries目标-> 构建阶段-> 将二进制文件与库链接

The below solution worked for me for the core-plot 2.3 version.以下解决方案适用于 core-plot 2.3 版本。 Do the below changes under other linker flags section.在其他链接器标志部分下进行以下更改。

1.Add $(inherited) and drag this item to top position 2.Remove "Pods-" prefix from -l"Pods-fmemopen”, l"Pods-NSAttributedStringMarkdownParser” and -l"Pods-MagicalRecord”. 1.添加 $(inherited) 并将此项拖到顶部位置 2. 从 -l"Pods-fmemopen"、l"Pods-NSAttributedStringMarkdownParser" 和 -l"Pods-MagicalRecord" 中删除 "Pods-" 前缀。

if still issue persists, Finally see if PODS_ROOT is set or not.如果问题仍然存在,最后看看是否设置了 PODS_ROOT。 You can check it under user defined section.您可以在用户定义部分下检查它。

I got the same error.我得到了同样的错误。

The issue : I created a separate Workspace and added my existing project into it.问题:我创建了一个单独的工作区并将我现有的项目添加到其中。 I got the error when I worked on that Workspace.我在该工作区工作时遇到错误。

The fix : Later I found that Workspace gets created automatically inside the existing project when dependencies are added.修复:后来我发现当添加依赖项时,工作区会在现有项目中自动创建。 And have to work on that workspace.并且必须在该工作区工作。

I had the same problem我有同样的问题

pod install and pod update on command line resolve my problem命令行上的 pod install 和 pod update 解决了我的问题

i have same issue with react-native library called linear-gradient, but i think the problem caused by adding blank space between -L -L... here the screen of error我对称为线性梯度的 react-native 库有同样的问题,但我认为问题是由在 -L -L 之间添加空格引起的...这里是错误屏幕在此处输入图片说明

im trying all solution in this page, thank you for help我正在尝试此页面中的所有解决方案,谢谢您的帮助

After spending half a day on this I discovered my problem.在花了半天的时间之后,我发现了我的问题。 I had upped the deployment target from 10 to 12.1 due to some dependencies.由于某些依赖性,我已将部署目标从 10 提高到 12.1。 I updated the project deployment target and all my pods.我更新了项目部署目标和我所有的 pod。

I just discovered that there is a deployment target at target level as wel.我刚刚发现在目标级别也有一个部署目标。 After upping this to 12.1 my project builds again.将此升级到 12.1 后,我的项目再次构建。

Deplyment target for "project" “项目”的部署目标

Podfile:播客文件:

Deployment target for "Target": “目标”的部署目标:

Check the deployment target in General and go to pod file and see检查部署目标General和go到pod文件,看看

platform:ios, '11.0'平台:ios,“11.0”

this 11.0 should be same in deployment target这个 11.0 在部署目标中应该是相同的

This error这个错误

Library not found for -lRNDateTimePicker未找到 -lRNDateTimePicker 的库

Was solve by downgrading "@react-native-community/datetimepicker" to "5.1.0", from "^6.3.2"通过将“@react-native-community/datetimepicker”从“^6.3.2”降级到“5.1.0”来解决

Hope it helps希望能帮助到你

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

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