217

I get these errors when I try to build an iOS application.

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:

${SRCROOT}/Pods

I didn't create this Xcode project - just pulled it from git to check it out.

26 Answers 26

660

If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file.

8
  • 2
    I also found it helpful to build the pod target, not the normal Xcode target.
    – Don Simon
    Jun 30, 2015 at 18:42
  • 2
    After I open it, I cannot run my project at all. what should I do?
    – Inuyasha
    Jan 12, 2016 at 8:39
  • I noticed that a reference to Pods is in the .xcodeproj but not in the .xcworkspace, hence why this solution works.
    – Jacksonkr
    May 23, 2016 at 13:48
  • 1
    Cd into the project folder and run "pod update". If you don't have pod, search how to install it.
    – justinkoh
    May 30, 2016 at 9:33
  • 2
    I got that error message when opening .xcworkspace (to be more specific, this worked one time on a mac and didn't on the other). In my case, found the issue related to renaming a project and later copying it to a different computer, the libs were not copied to the new location. compare: /Users/[USERNAME]/Library/Developer/Xcode/DerivedData/[OLDPROJECTNAME]-[LONGRNDCHARS]/Build/Products to: /Users/[USERNAME]/Library/Developer/Xcode/DerivedData/[NEWPROJECTNAME]-[LONGRNDCHARS]/Build/Products
    – Yatko
    Aug 28, 2016 at 19:43
102

Had this problem as well. Something was wrong with my CocoaPods installation. No pods other than KIF were installing properly. 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.

2
  • 7
    I had to make sure it was also equal between the targets of my project and the the targets of the pod... Jul 22, 2015 at 13:01
  • This happens to me once every 6 month, and I can never remember how I resolved it last time... Build Active Architecture Only . . . May we all remember
    – Eloy B.
    Feb 21, 2020 at 1:36
54

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 :

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. 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). I tested in debug and release, both of which were giving me errors, and the problem was immediately resolved.

5
  • worked like a charm, thanks. I only had this problem when updating to Swift 2.0 on El Capitan. Worked perfectly before.
    – Ovi
    Sep 22, 2015 at 12:17
  • 1
    I have $(inherited) only and at the same time I have these frustrating dupes. Where I can edit the value that is original to $(inherited) variable?
    – nickolay
    Sep 22, 2015 at 21:22
  • You saved my day man.... stuck in this issue for while ... it happened because i have remove entire pod project and re added it Oct 14, 2015 at 14:51
  • Fixed for me as well. Never would've figured this out on my own!
    – bmueller
    Oct 21, 2015 at 5:11
  • You beat! Works like a charm Nov 8, 2016 at 15:19
31

My problem had fixed by the following config:

Build Active Architecture Only: YES
3
  • This worked for me when I encountered an issue with SDWebImage.... for those who have found their way here for that Cocoapod component
    – Scott D
    May 11, 2016 at 15:16
  • 1
    This solves that issue for me, but causes another. I need to build for all architectures, not just the active one. Aug 5, 2016 at 14:00
  • In a old code I am integrating pods. I am facing the same issue. Above answer helped. Sep 21, 2018 at 9:53
31

It seems project has been using cocoapods. and that files are missing from your project.

You cant just download it from git. You need to install it from cocoapods.

for more help, you may follow Introduction to CocoaPods Tutorial

If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file

2
  • 1
    @RahulPatel How to install the particular file can you please share the command Jun 10, 2015 at 8:58
  • If you want to use the new beta version you can use: pod 'GoogleAds-IMA-iOS-SDK-For-AdMob', '3.0.beta.16' Oct 31, 2015 at 15:32
28

If you have multiple targets in your project, Cocoapods may have only integrated itself well with just one of them.

I had to manually link to libPods.a in "Link Binary With Libraries" for each additional target I had.

libPods.a in my list of frameworks

3
  • i think pod install is not integrated libPods.a file to all targets, As Rizwan isntruction I have added and it works... Thanks Rizwan Sattar
    – Wagh
    Sep 22, 2015 at 18:44
  • This worked for me although it wasn't shown in red. I ran pod install afterwards and it didn't add it, everything seems to work though.
    – Jules
    Jan 7, 2016 at 9:11
  • 2
    Actually, what I needed to do is remove an outdated (my-project-name).a library because I renamed the project before and it was just stuck there. I up-rated your answer because it provided me an idea on where the problem might be.
    – kalafun
    Nov 7, 2016 at 16:33
19

This problem-related to lPods can be fixed by following the steps below

  • Select your Project Target.
  • Go to "Build Phases" in "Link Binary With Libraries".
  • Now remove ".a" file of that library which is creating the problem.
  • Clean and Build.

This will work.

3
  • In my case removing libstdc++.6.dylib solved the problem! Feb 27, 2020 at 4:15
  • How and where you removed the "libstdc++.6.dylib", as I need to remove the "-lstdc++.6". I am getting the "library not found for -lstdc++.6" Mar 6, 2020 at 9:53
  • removing "*.a" file worked for me. Thanks
    – Nabeel
    Jul 24, 2022 at 13:58
17

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.

Only that remains here

This is usually caused from running rnpm link and the way rnpm works.

After I removed the facebook core .a file from my build phases my project was up and running once again.

0
12

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. 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:

# 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.

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.

2
  • I installed cocoapods properly for my project, but had the same error as the OP. Deleting -libPods.a solved it for me. Thank you kindly, sir.
    – NKorotkov
    Jan 15, 2016 at 14:26
  • I was updating an old project, and scrapped the old Podfile and ran pod init to set up a new one, and discovered the old file was like your # WRONG way, and the new file is like # CORRECT. Thank you!
    – BJ Miller
    Feb 5, 2017 at 13:54
11

My steps:

  1. Delete the pods folder and the 'Pods' file.
  2. Type "pod install" into Terminal.
  3. Type "pod update" into Terminal.

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.

2
  • +1 In my case, if it's -lHelpshift or specific name of pod. Then I remove only specific folder thus it is Pods/Helpshift. Then do pod install again. No need to update. It works now.
    – haxpor
    Jan 22, 2017 at 11:40
  • 1
    Deleting all pods and then reinstalling helped. May 29, 2017 at 12:17
11

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!

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!

enter image description here

1
  • 1
    You're my hero! I was getting an error about lBVLinearGradient but this solved it!
    – J. Adam
    Dec 11, 2021 at 9:52
8

Had a same issue after upgrading Deployment target from 7.0 to 8.0 and enabling use_frameworks!

cocoapods did not delete previously generated PodName.a files from the Frameworks section of my project.

So I had to delete those manually, because they caused the linker error

5

If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file. if you are using .xcworkspace , Please reinstall the pod file by removing the pods and again insert the pods and install it !!! this worked for me

4

Delete all the corresponding files/folders of imported cocoapods source except podfile.

install cocoapod again.This should clear any redundant pull from the original source.

4

This was my issue while trying to integrate Firebase to my Xcode project using cocoapods

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

  1. Go to Build Settings, search for Other Linker Flags, remove all values expect $(inherited) Image

Do this for all targets.

  1. Delete the pods folder. (ios/Pods)
  2. Do pod update

Voila! All linker errors will be gone.

1
  • This needed to happen for me as well. However, also in my case it was a react-native app added Firebase Analytics. As of July 2018, all apps must be built with iOS 11 per Apple: developer.apple.com/ios/submit/ Once I went to my General tab and scrolled down to Deployment Info / Deployment Target and changed it from 10.x which is what I was targeting, to 11.x - the app built/archived and I was able to submit.
    – bo_
    Jul 31, 2018 at 1:27
3

When you clone project from somewhere which uses Cocoapods you need to install them to your project.

Here step-by-step what you need to do:

  • 1) clone source code to local machine;
  • 2) close the xcode project (if open);
  • 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;
  • 4) go to the root of your xcode project by using "cd" command in terminal;
  • 5) you should have Podfile in this folder; 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;
  • 6) then use "pod install" command to download and install the Libraries to your project; the Podfile.lock will be created and {Your project name}.xcworkspace file;
  • 7) from now on you have to use {Your project name}.xcworkspace to open it in xcode;

Good luck!

3

I had the same problem

pod install and pod update on command line resolve my problem

2

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"
  2. Add the following in "Other Linker Flags" under "Project Target"
    1. $inherited
    2. -ObjC
    3. -lc++
    4. -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"

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

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

Hope it helps!

2

In a project with multiple targets I had the same issue after changing the Scheme and App name and tried to update pods. 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. Removing the library from there cleared the problem.

2

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. I updated the project deployment target and all my pods.

I just discovered that there is a deployment target at target level as wel. After upping this to 12.1 my project builds again.

Deplyment target for "project"

Podfile:

Deployment target for "Target":

1

My way

  1. create new project and install pod it will can run without error.

  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.

1

For me this is worked. I have changed my app name from someApp to 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). Finally I had to remove one libPod. And it worked.

target-> Build phases-> Link Binary With Libraries

1

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.

1
  • This answer doesn't clearly state how to fix the question that has been asked
    – Mark
    Jun 4, 2016 at 3:43
1

The below solution worked for me for the core-plot 2.3 version. 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”.

if still issue persists, Finally see if PODS_ROOT is set or not. You can check it under user defined section.

0

Check the deployment target in General and go to pod file and see

platform :ios, '11.0'

this 11.0 should be same in deployment target

0

This error

Library not found for -lRNDateTimePicker

Was solve by downgrading "@react-native-community/datetimepicker" to "5.1.0", from "^6.3.2"

Hope it helps

Not the answer you're looking for? Browse other questions tagged or ask your own question.