55

I've installed cocoa pods library and some frameworks through it. Now when I compile project the build fails.

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

Here part of text:

Ld /Users/polzovatel/Library/Developer/Xcode/DerivedData/Project-bybevfqrgvqqldbzsgewqafpmylj/Build/Products/Debug-iphonesimulator/Project app/Project normal i386
    cd /Users/polzovatel/Projects/iOS-master/Project_iPhone
    export IPHONEOS_DEPLOYMENT_TARGET=6.0
    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"

What I need to do to fix this problem?

animuson
  • 53,861
  • 28
  • 137
  • 147
Eugene Biryukov
  • 1,702
  • 1
  • 13
  • 19
  • 17
    Have you run `pod install` and opened the `xyz.xcworkspace` instead of `xyz.xcproject`? – Sebastian Wramba Jun 06 '14 at 09:35
  • 1
    I know how to work with cocoa pods. I used this pods in a few projects, but this problem I see at first time. This project I downloaded from my clients. I already tried to delete xcworkspace and run pod install. Also I tried to delete Pods folder. – Eugene Biryukov Jun 06 '14 at 09:52
  • 1
    Opening the xyz.xcworkspace file worked for me. Somehow the Pod projects were not appearing in the IDE and I realized that the xcproject file was opened instead of the updated workspace. – iphone007 Nov 10 '14 at 08:00

17 Answers17

99

Fixed it by deleting the -lPods-Projectname.a in Link Binary (for newer versions, delete the -lPods-Projectname.a under the Frameworks group).

AStopher
  • 4,207
  • 11
  • 50
  • 75
Eugene Biryukov
  • 1,702
  • 1
  • 13
  • 19
47

Whenever I execute "pod install" it leads me to spend several hours fixing build errors. So, I deleted CocoaPods stuff and do not have problems any more! Now I am lucky and happy man.

Start using Swift Package Manager (SPM). If your 3rd party lib still do not support SPM I encourage you to take action on adding SPM support on your own. Here is instructions.

Or create an issue for the 3rd party lib about adding support for SPM.

Ramis
  • 13,985
  • 7
  • 81
  • 100
  • 4
    I experience a similar wish every few months, I have to admit. – theLastNightTrain Aug 27 '15 at 15:24
  • 2
    Yes me too. But... if we can't who can ;) – Femina Sep 02 '15 at 14:46
  • 5
    A mere 6 weeks later and I'm back here looking again for why one target inexplicably fails with "ld: library not found for -lPods-AFNetworking", when the other essentially-identical target succeeds fine. – theLastNightTrain Oct 09 '15 at 16:37
  • 5
    I agree with you... there are too many moving parts in CocoaPods. The cost / benefits ratio is pretty bad. Most of the time we spend more time fixing up CocoaPods problems than we would simply copy/pasting source files into our project. CocoaPods is somehow considered "state of the art" so it's hard to avoid but for private projects I might just skip it. So you have to manually update the source every now and then, but so what? On the other hand, code doesn't randomly break all the time. – n13 Mar 21 '16 at 10:12
23

The exact location that you should remove your libs is at:

  • Remove -lyourlibname.a in "Link Binary With Libraries" on "Build Phases" of your target.
mcatach
  • 1,227
  • 13
  • 23
  • 1
    This makes no sense to me, BUT IT WORKS! I guess we don't need to link the pod library in child projects because we'll also link it in the parent project as well. – Buzzrick Oct 17 '16 at 01:43
23

You can try "Build Active Architecture Only" = YES . it may be solving problem.

aybars
  • 892
  • 9
  • 9
  • 3
    The vital point is that the Build Active Architecture Only settings are the same for Pod and Project targets. Usually Yes for debug and No for release – wheeliebin Sep 12 '18 at 17:03
20

Ensure that Build Active Architectures Only settings for both of your project and the Pods project were equal for debug and release configuration! That's was a problem in my case.

skywinder
  • 21,291
  • 15
  • 93
  • 123
14

Make sure Build Active Architectures Only in your Project/Target and in your Pod/Target and Pod are the same. We often set the debug yes and set the release no.

jiexishede
  • 2,473
  • 6
  • 38
  • 54
13

I realized the xcproject file was opened instead of the updated workspace. This fixed my error. Hope this information will help others too.

JIANG
  • 1,687
  • 2
  • 19
  • 36
  • 2
    As a newbie to cocoapods I didn't even realize I was supposed to open the xcworkspace instead of the xcproject. That seems obvious now, but it's really not very obvious from the cocoapods guides I've read. – steve Jan 29 '16 at 18:48
  • 2
    this was it! prayers. – Gukki5 Jul 05 '18 at 05:50
10

If none of the other answers help you, try this:

  • Deintegrate cocoa pods using pod deintegrate. Check this link https://github.com/kylef/cocoapods-deintegrate.
  • Search on the build settings for target and project file for "pod". Anything that looks like it belonged to cocoa pods, remove.
  • Finally, run pod install once again.
HotFudgeSunday
  • 1,403
  • 2
  • 23
  • 29
6

Go to Product > Scheme > Edit Scheme... > Build > + > Add the Pods-Projectname.a and drag it to the top > Clean & Build your project.

Elad
  • 594
  • 3
  • 13
6

I had a very different experience. I tried removed the library from build settings to no avail. And honestly, I couldn't see the logic behind it.

What I did was try a new pod install. And so it gave me this error

[!] The ProjectName [Debug] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation - Use the $(inherited) flag, or - Remove the build settings from the target.

[!] The ProjectName [Release] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation - Use the $(inherited) flag, or - Remove the build settings from the target.

So I did what it told me to, I added the $(inherited) flag to build settings. And all worked well

MNassar
  • 367
  • 5
  • 11
6

In my case I found that a mis-match of deployment target of the Project (iOS 11.4) versus the Target (iOS 10.3). Updating the target to iOS 11.4 fixed the issue.

Project > Info > Deployment Target > iOS Deployment Target
Project > Target > General > Deployment Target > Target

Podfile: platform :ios, '11.4'

enter image description here enter image description here

Christopher
  • 5,806
  • 7
  • 31
  • 41
4

I had this problem when I accidentally opened project instead of workspace so Cocoapods where missing....

Renetik
  • 5,887
  • 1
  • 47
  • 66
3

Check your Project -> Targets -> Build Phases -> Link Binary With Libraries

enter image description here

Kaptain
  • 1,358
  • 12
  • 20
2

Point to your Pods project, set the BaseSDK to iOS SDK since 'pod install' process clear it. Also set Build Valid Architecture Only to NO That should work.

hungdm9999
  • 31
  • 1
  • 1
1

I experienced a similar error which affected one of my computers but not the other when compiling the same project.

I reinstalled cocoapods, all gems, rebuilt the project and none of it worked. I finally got it to compile but required me to completely remove Xcode and related data (iPhone simulator, DerivedData) then reinstall Xcode.

HDevejian
  • 111
  • 1
  • 5
1

I've had this error after adding a new build configuration.

pod install helped, because it adds separate settings for each build configuration.

dreamzor
  • 5,795
  • 4
  • 41
  • 61
0

i also had the same sort of issue. So Check your pod file's platform :ios . and check Deployment info target versions. and please make sure version of both files are same. if both are not same the issue will be executed. i also had the issue after library updating my react native project

(Target info = select your project, then select target, In general section Deployment info is available.)

enter image description here

enter image description here