我存档一个项目时出错了。这就是我的环境。

Mac OS Lion Xcode 4.3.1 iOS SDK 5.1

项目部署目标为:

IPHONEOS_DEPLOYMENT_TARGET 3.2

错误显示:

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

我猜Pods就是我用来管理XCode项目依赖的CocoaPods。 https://github.com/CocoaPods/CocoaPods

这是我的Podfile

platform :ios  
dependency 'libPusher', '1.1'

我不确定这个错误是什么意思?


当前回答

我尝试了这篇文章中的每一个答案,但都无济于事。最终通过匹配我的目标项目中的“Pre-Configuration Build Products Path”与Pods项目中的值来解决我的问题。原来他们在建造两个不同的输出位置。这篇文章中的其他建议都与我无关。如果XCode给出一个有用的错误描述(比如为什么它不能使用lib - File Not Found, No matching architecture Found等等),那就太好了。

其他回答

如果Xcode在链接时报错,例如Library not found for -lPods,它不会检测到隐式依赖。

Go to Product > Edit Scheme Click on Build Add the Pods static library, and make sure it's at the top of the list Clean and build again If that doesn't work, verify that the source for the spec you are trying to include has been pulled from github. Do this by looking in /Pods/. If it is empty (it should not be), verify that the ~/.cocoapods/master//.podspec has the correct git hub url in it. If still doesn't work, check your XCode build locations settings. Go to Preferences -> Locations -> Derived Data -> Advanced and set build location to “Relative to Workspace”.

http://docs.cocoapods.org/guides/getting_started.html

在这个问题中,如果你已经在你的系统中安装并更新了pod,那么你的Xcode无法找到Pods库。要解决此问题,请检查以下可能发生的原因:

您正在使用工作区。 构建Pods库。 Pods库在项目的产品组中被引用。 你的目标是在框架构建阶段的链接中包含Pods库。

我把我的pod列表在Podfile中划分为不同的目标,比如:

target :ABC do
  pod 'KissXML', '~> 5.0'
  pod 'libPhoneNumber-iOS', '~> 0.7.2'
end

target :ABCTests do
  pod 'OCMock', '~> 2.2.1', :inhibit_warnings => true
end

然后安装了吊舱

这创建了一个新的库libPods-ABC。我的二进制文件必须链接到的A。但错误是它没有删除之前的库,即libPods.a。

解决方案:删除libPods库。a来自Link Binary With Libraries的构建阶段。

没有一个解决方案适用于我,这真的是难以忍受,有一个文件libpods。a(是红色的)我把它拿走了,一切都很好!为我干杯!

我在Podfile中通过使用将app和测试目标分开

target :App do
    …
end

target :AppTests do
    …
end

这导致了两个新产品libPods-App。a和libPods-AppTests。a,他们做了之前的产品libPods。一个过时的。我必须从两个目标的构建阶段配置的Link Binary With Libraries部分中删除此产品。