xcode 找不到用于 -lPods-AFNetworking 的库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30601420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:13:40  来源:igfitidea点击:

library not found for -lPods-AFNetworking

iosxcoderuntime-errorafnetworkingxcode-6.2

提问by LoveMeow

I am getting the following error when using AFNetworking:

使用 AFNetworking 时出现以下错误:

''library not found for -lPods-AFNetworking''
"linker command failed with exit code 1 (use -v to see invocation)."

“未找到 -lPods-AFNetworking 的库”
“链接器命令失败,退出代码为 1(使用 -v 查看调用)。”

I checked for all missing frameworks,and they are all present .Additionally this project works for other people(we pulled it from github) and I'm the only person for whom it does not work.(its a joint project)

我检查了所有缺失的框架,它们都存在。此外,这个项目对其他人有效(我们从 github 中提取),而我是唯一一个对其不起作用的人。(它是一个联合项目)

We all use Xcode 6.2. I do not understand what could be wrong or what went missing. I tried pulling using the command line,sourceTree and even from Xcode git source control.

我们都使用 Xcode 6.2。我不明白可能出了什么问题或丢失了什么。我尝试使用命令行、sourceTree 甚至 Xcode git 源代码控制进行拉取。

I also tried different versions of Xcode. But all the other teamates are using Xcode 6.2, which I am using now.

我还尝试了不同版本的 Xcode。但是所有其他团队成员都在使用我现在正在使用的 Xcode 6.2。

It used to work before, it suddenly stopped working.

以前还能用,突然就不行了。

Any ideas are welcome,thank you!

欢迎任何想法,谢谢!

Following is the detailed errors:

以下是详细错误:

ld: warning: directory not found for option '-L/Users/ramapriyasridharan/Documents/Rama-3:06:2015-ios/Mapbox' ld: warning: directory not found for option '-L/Users/ramapriyasridharan/Documents/Rama-3:06:2015-ios/Pods/build/Debug-iphoneos' ld: library not found for -lPods-AFNetworking clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld:警告:找不到选项“-L/Users/ramapriyasridharan/Documents/Rama-3:06:2015-ios/Mapbox”的目录 ld:警告:找不到选项“-L/Users/ramapriyasridharan/Documents/”的目录Rama-3:06:2015-ios/Pods/build/Debug-iphoneos' ld: library not found for -lPods-AFNetworking clang: error: linker command failed with exit code 1 (使用 -v 查看调用)

EDIT:

编辑:

After opening the workspace file, I did not get the mach O linker error any more, but I am getting the following error:

打开工作区文件后,我没有再收到 mach O 链接器错误,但出现以下错误:

Command /Volumes/Xcode 1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/momc failed with exit code 1

I asked my team mates who said that it still works fine,so it is still a problem only on my computer!

我问过我的队友,他们说它仍然可以正常工作,所以它仍然只是在我的电脑上有问题!

回答by system

Instead of opening the XCode project, you should open up the WorkSpace file.

您应该打开 WorkSpace 文件,而不是打开 XCode 项目。

回答by Teena nath Paul

I was facing the same problem and following solution worked for me:

我遇到了同样的问题,以下解决方案对我有用:

  1. Go to project setting -> build setting -> other linker flag, and remove all flags that have -lpod or frameworks or related to pods. Don't remove the required flags (e.g. -ObjC, -licucore, -libxml2)
  2. Add a flag $(inherited)at the top.
  3. Clean the project and compile.
  1. 转到项目设置 -> 构建设置 -> 其他链接器标志,并删除所有具有 -lpod 或框架或与 pod 相关的标志。不要删除所需的标志(例如 -ObjC、-licucore、-libxml2)
  2. 在顶部添加一个标志$(inherited)
  3. 清理项目并编译。

回答by Ourang-Zeb Khan

I had the same error while migrating my project to iOS 9. I solved it by doing this:

将我的项目迁移到 iOS 9 时我遇到了同样的错误。我通过这样做解决了它:

  1. Navigate to the Build Settingstab for your project and search for "link".
  2. In the the Other Linker Flagssection, remove -l"Pods-AFNetworking"and replace it with -l"AFNetworking"
  1. 导航到项目的“构建设置”选项卡并搜索“链接”。
  2. Other Linker Flags部分,将-l"Pods-AFNetworking"其删除并替换为-l"AFNetworking"

See the screenshot linked here for more information:

有关更多信息,请参阅此处链接的屏幕截图:

http://i.stack.imgur.com/uG51T.png

http://i.stack.imgur.com/uG51T.png

回答by LoveMeow

I wanted to write an answer myself because two things together worked :

我想自己写一个答案,因为两件事一起工作:

  1. AS @Helium3 mentioned, I had to open the workspace rather than the project file in the file explorer(projectname.xcworkspace file)(I actually have 2 and only 1 seems to work!)

  2. As @Muhammad Adnan mentionedin the comments, what worked was to install pod and update pod it solved the linker problems!!(Note: This should be done in the project directory,make sure cocoapods are installed first!!), in addition it gave me odd errors at first(after a second go),later it was alright!

  1. 正如@Helium3 提到的那样,我必须在文件资源管理器(projectname.xcworkspace 文件)中打开工作区而不是项目文件(我实际上有 2 个,但似乎只有 1 个有效!)

  2. 正如@Muhammad Adnan在评论中提到的,有效的是安装 pod 和更新 pod 它解决了链接器问题!!(注意:这应该在项目目录中完成,确保首先安装 cocoapods!!),此外一开始给了我奇怪的错误(第二次之后),后来就好了!

Thank you guys!

谢谢你们!

回答by jdev

It has been a while since this question but today I ran into a similar issue and how we solved it was by going to: Edit Scheme > Build

这个问题已经有一段时间了,但今天我遇到了一个类似的问题,我们是如何解决它的:编辑方案 > 构建

and making sure the option ′Find Implicit Dependencies′ is checked.

并确保选中“查找隐式依赖项”选项。

Screenshot scheme settings

截图方案设置

I had it unchecked and after I updated CocoaPods to 1.0, I couldn′t find the dependencies in the Derived Data folder.

我没有选中它,在我将 CocoaPods 更新到 1.0 后,我在派生数据文件夹中找不到依赖项。

After that I could build it succesfully.

之后,我可以成功构建它。

回答by Priyank Jotangiya

In iWatch App using Cocoa Pods AFNetworking i got the Same issue.

在使用 Cocoa Pods AFNetworking 的 iWatch 应用程序中,我遇到了同样的问题。

I Just Solved Issue ....

我刚刚解决了问题....

Just Follow this Step.

只需按照此步骤操作即可。

[1] Open your project's podfile by typing in terminal:

[1] 通过在终端中键入来打开项目的 podfile:

open -a Xcode Podfile

Check If you are Using AFNetworking than using

检查您是否使用 AFNetworking 而不是使用

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'AFNetworking', '~> 3.0'

copy and paste this between target 'iChat' do.... end

目标 'iChat'之间复制并粘贴它....结束

Like .....

喜欢 .....

target 'iChat' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for iChat

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'AFNetworking', '~> 3.0'

end

and

[2] Then open your terminal again simply paste it.

[2] 然后再次打开您的终端,只需粘贴即可。

pod install

Now open App.xcworkspace and Clear and Run You can see Error is Gone Now...

现在打开 App.xcworkspace 并清除并运行您可以看到 Error is Gone Now ...

回答by Hugo H

React native:

反应原生:

I forgot to install a new RN module after pulling changes. So don't forget to npm ior yarnbefore building with react-native.

拉动更改后,我忘记安装新的 RN 模块。所以不要忘记npm iyarn在使用react-native.