找不到 xcode 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11358591/
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-09 04:28:02  来源:igfitidea点击:

xcode library not found

xcode

提问by SBel

I'm getting the following error:

我收到以下错误:

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

ld:找不到 -lGoogleAnalytics clang 的库:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

I've spent some time googling but can't find how to fix this problem. I'm new to xcode and this is an existing project that I need to work on.

我花了一些时间谷歌搜索,但找不到如何解决这个问题。我是 xcode 的新手,这是我需要处理的现有项目。

回答by trojanfoe

You need to set the "linker search paths" of the project (for both Debug and Release builds). If this library was in, say, a sibling directory to the project then you can set it like this:

您需要设置项目的“链接器搜索路径”(对于 Debug 和 Release 版本)。如果这个库在项目的同级目录中,那么你可以像这样设置它:

$(PROJECT_DIR)/../GoogleAnalytics/lib

$(PROJECT_DIR)/../GoogleAnalytics/lib

(you want to avoid using an absolute path, instead keep the library directory relative to the project).

(您希望避免使用绝对路径,而是保持库目录相对于项目)。

回答by Gon

All in all, the Xcode cannot find the position of library/header/framework, then you tell Xcode where they are.

总而言之,Xcode 找不到 library/header/framework 的位置,然后你告诉 Xcode 它们在哪里。

set the path that Xcode use to find library/header/framework in Build Settings--> Library/Header/Framework Search Paths.

Build Settings--> Library/Header/Framework Search Paths 中设置Xcode 用于查找 library/header/framework 的路径

Say, now it cannot find -lGoogleAnalytics, so you add the directory where -lGoogleAnalyticsis to the Library Search Paths.

说,现在它找不到-lGoogleAnalytics,所以你添加目录 where -lGoogleAnalyticsis 到Library Search Paths

回答by Scott Jungwirth

In my case I had a project with lots of entries in "Build Settings > Other Linker Flags"

就我而言,我有一个项目,在“构建设置 > 其他链接器标志”中有很多条目

I needed to reduce it down to just

我需要把它减少到只是

  $(inherited)
  -ObjC

Old settings:

旧设置:

old settings

旧设置

Updated settings:

更新设置:

enter image description here

在此处输入图片说明

回答by Aniruddha Shevle

In my case, the project uses CocoaPods. And some files are missing from my project.

就我而言,该项目使用 CocoaPods。我的项目中缺少一些文件。

So I install it from CocoaPods: https://cocoapods.org/.

所以我从 CocoaPods 安装它:https://cocoapods.org/ 。

And if the project uses CocoaPodswe've to be aware to always open the .xcworkspace folder instead of the .xcodeprojfolder in the Xcode.

如果项目使用 CocoaPods,我们必须注意始终打开 .xcworkspace 文件夹而不是Xcode中的 .xcodeproj文件夹。

回答by Rinni

If you have pods installed, make sure to open the workspace folder(white Xcode icon) not the project folder. This resolved the library not found for ...error. Very simple issue but I was stuck on this for a long time.

如果您安装了 Pod,请确保打开工作区文件夹(白色 Xcode 图标)而不是项目文件夹。这解决了library not found for ...错误。非常简单的问题,但我被困在这个问题上很长时间。

回答by vr_driver

For me, I open the projectname.xcworkspace file and it all works.

对我来说,我打开 projectname.xcworkspace 文件,一切正常。

回答by James Martin

If you are using Pods to include the GoogleAnalytics iOS SDK into your project, it's worth noting that since the 3.0 release your Other Linker Flagsneeds to include -lGoogleAnalyticsServicesnot the old -lGoogleAnalytics

如果您使用 Pods 将 GoogleAnalytics iOS SDK 包含到您的项目中,值得注意的是,自 3.0 版本以来,您Other Linker Flags需要包含-lGoogleAnalyticsServices而不是旧的-lGoogleAnalytics

回答by David

If your library file is called libGoogleAnalytics.a you need to put -lGoogleAnalytics so make sure the .a file is named as you'd expect

如果您的库文件名为 libGoogleAnalytics.a,则您需要添加 -lGoogleAnalytics,因此请确保 .a 文件的名称符合您的预期

回答by Rikesh Subedi

In XCode 10.1, I had to set "Library Search Paths" to something like $(PROJECT_DIR)/.../path/to/your/library

在 XCode 10.1 中,我必须将“库搜索路径”设置为 $(PROJECT_DIR)/.../path/to/your/library

回答by Loegic

You can also try to lintwith the --use-libraryoption, as cocoapods lint libraries as framework by default since v0.36

您也可以尝试lint使用该--use-library选项,因为自 v0.36 以来默认情况下 cocoapods lint 库作为框架