Xcode: ld: 找不到用于 -lAFNetworking 的库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32643858/
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
Xcode: ld: library not found for -lAFNetworking
提问by Akbapu
回答by Jagdeep Singh
Might be you are opening .xcodeproj file after installing pods. Close the project and open .xcworkspace file.
可能是您在安装 pod 后打开了 .xcodeproj 文件。关闭项目并打开 .xcworkspace 文件。
回答by myz
Have the same issue.
有同样的问题。
What I did with the help of https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1and Adlair Cerecedo-Mendez
我在https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1和 Adlair Cerecedo-Mendez的帮助下做了什么
- Delete the "Pods" project on the left panel of Xcode.
- Close Xcode and delete this file in the finder too.
- Install pods again.
- Open Xcode and clean.
- Verify that the build option "Build Active Architecture Only" is set to "NO" for your project but also for your Pods project (selection with left panel).
- Click on your project Scheme (top, near the stop button) and "Manage Scheme".
- Check, select all your pods libraries and close.
- Then, for all libs, select them (scroll the list) and build manually for the selected architecture.
- 删除 Xcode 左侧面板上的“Pods”项目。
- 关闭 Xcode 并在查找器中删除此文件。
- 再次安装 Pod。
- 打开Xcode并清理。
- 验证构建选项“Build Active Architecture Only”是否为您的项目以及您的 Pods 项目(使用左侧面板选择)设置为“NO”。
- 单击您的项目方案(顶部,靠近停止按钮)和“管理方案”。
- 检查,选择所有 pod 库并关闭。
- 然后,对于所有库,选择它们(滚动列表)并为所选架构手动构建。
Every time you change your architecture (simulator, device or for archive(Generic iOS Device)) you must do the above step: namely, manually build each libraries by selecting them in your scroll list one by one, and only than build and run your main project.
每次更改架构(模拟器、设备或存档(通用 iOS 设备))时,您都必须执行上述步骤:即,通过在滚动列表中逐个选择它们来手动构建每个库,并且仅构建和运行您的主要项目。
Seems a bit WTF, but it is the only way I resolve this issue...
似乎有点WTF,但这是我解决此问题的唯一方法......
回答by Hernan Arber
I Had this Issue several Times with PODS Libraries.
我在 PODS 库中多次遇到过这个问题。
Here is something you can Try:
以下是您可以尝试的内容:
Run
pod cache clean --all
andpod install
again.Check your Header Search Paths and Library Search Paths, Remove all entries and place $(PROJECT_DIR) in recursive mode and $(inherited) as a Second Entry
Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.
运行
pod cache clean --all
和pod install
试。检查您的标题搜索路径和库搜索路径,删除所有条目并将 $(PROJECT_DIR) 置于递归模式并将 $(inherited) 作为第二个条目
转到您的目标构建设置 -> 其他链接器标志 -> 双击 . 将 $(inherited) 添加到新行。
回答by Juan de la Torre
Make sure Build Active Architecture Only
is set to NO
in the Pods project settings.
确保Build Active Architecture Only
被设置为NO
在豆荚项目设置。
回答by Adlair Cerecedo-Mendez
I'm thinking on two possibilities:
我在想两种可能:
1) Install cocoapods-deintegrateproject:
1)安装cocoapods-deintegrate项目:
$ gem install cocoapods-deintegrate
Then run $ pod deintegrate
, after that run $ pod install
again. If it not works, then...
然后运行$ pod deintegrate
,然后$ pod install
再次运行。如果它不起作用,那么...
2) You can try open your Pods project and create new scheme for the target that you need, in this case for AFNetworking.
2)您可以尝试打开您的 Pods 项目并为您需要的目标创建新方案,在这种情况下为AFNetworking。
When the static library is created, then add it to your Frameworks references into your main project.
创建静态库后,将其添加到主项目中的框架引用中。
Hope that helps.
希望有帮助。
回答by Grzegorz R. Kulesza
I have in project->TARGETS->Build Phases ->Link Binary With Libraries one "extra" framework that remains from recent project. Delate it and all run smoothly
我在 project->TARGETS->Build Phases ->Link Binary With Libraries 中有一个“额外”的框架,该框架从最近的项目中保留下来。延迟一切,一切顺利
回答by Ken Stipek
I had this issue while using fastlane with a ReactNative project. I had added a dependency that required cocoapods.
我在 ReactNative 项目中使用 fastlane 时遇到了这个问题。我添加了一个需要 cocoapods 的依赖项。
My Fastfile looked like this:
我的 Fastfile 看起来像这样:
...
gym(
scheme: "AppName",
project: "./ios/AppName.xcodeproj"
)
....
And had to change it to the workspace like this:
并且不得不像这样将其更改为工作区:
...
gym(
scheme: "AppName",
workspace: "./ios/AppName.xcworkspace"
)
...
回答by Haris ur Rehman
I encountered this error when I downloaded some code from github. I tried to build .xcodeproj file but it failed giving the library not found error. I then opened .xcworkspace file and build that file first by clicking Product -> Build for -> Running. The workspace file built fine with no errors. Then in workspace file I changed scheme to the xcode project I was trying to build, and clicked Product -> Run. The app got built and ran with no errors.
我从github下载一些代码时遇到了这个错误。我试图构建 .xcodeproj 文件,但它失败并给出了未找到库的错误。然后我打开 .xcworkspace 文件并首先通过单击 Product -> Build for -> Running 来构建该文件。工作区文件构建良好,没有错误。然后在工作区文件中,我将方案更改为我尝试构建的 xcode 项目,然后单击产品 -> 运行。该应用程序已构建并运行,没有错误。
回答by Chris Allinson
Had a similar issue ... took a while to realize that I had updated my app's "iOS Deployment Target" to iOS 9.0, but the Pods project's "iOS Deployment Target" was still iOS 8.0!!!
有一个类似的问题......花了一段时间才意识到我已经将我的应用程序的“iOS 部署目标”更新为 iOS 9.0,但 Pods 项目的“iOS 部署目标”仍然是 iOS 8.0!!!
回答by Fokou Franklin
Use the xcworkspace to build instead of the xcproject?
使用 xcworkspace 来构建而不是 xcproject?
This usually happens when using Cocoapods and you are building from the xcproject which doesn't know about the cocoapod libraries.
这通常发生在使用 Cocoapods 并且您从不了解 cocoapod 库的 xcproject 构建时。