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

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'

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


当前回答

我解决了这个问题,为我的项目设置架构和有效架构相同的所有pod。所以在我的案例中,洞的解决方案是:

更新可可荚:sudo宝石更新可可荚 更新pod:更新pod 在你的pod中,转到你的构建设置>架构,并将这里的架构和有效架构设置为与主项目相同的值。

其他回答

在所有pod中只使用_active_arch =NO解决了我的问题。为了让它持久,我在Podfile中添加了一个post_install钩子:

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
      target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
      end
  end
end

Pod安装完成。

只有将“库搜索路径”(在“MyProject”的构建设置中)添加到“Pods/ Build / debug - iphonessimulator”中才对我有效(当使用模拟器时)。

从这里开始: https://github.com/CocoaPods/CocoaPods/issues/121#issuecomment-5452473

如果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列表在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的构建阶段。

我把这里的每个答案都看了一遍,但对我来说太简单了……转到Target -> Build Phases,然后删除libPods-YourProject。A,然后用“+”再加一次。别担心图书馆是红色的,没事的。