ios 目录未找到 Apple Mach-O 链接器警告,但库搜索路径和框架搜索路径为空

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

directory not found Apple Mach-O linker warning but Library Search Path and Framework Search Path are empty

iosxcode

提问by Joel Derfner

I'm getting these messages:

我收到这些消息:

ld: warning: directory not found for option '-F"/Users/joel/Development/GHaikuTabbed"'
ld: warning: directory not found for option '-F"/Users/joel/Development/GHaikuTabbed/../../../Downloads"'

But when I go to Build Settings (as suggested at ‘ld: warning: directory not found for option'), Library Search Path and Framework Search Path are empty, so there's nothing to delete.

但是,当我转到构建设置(如'ld:warning: directory not found for option' 中所建议的那样)时,库搜索路径和框架搜索路径为空,因此没有什么可删除的。

Thoughts on other things I can do to get rid of this warning?

关于我可以做些什么来摆脱这个警告的想法?

回答by user2963906

Here is a description how to avoid a problem based on Apple Dev Forumposted before. It works for me so I repost description for those people who don't want to go and register at the forum.

这是基于之前发布的Apple Dev Forum的描述如何避免问题。它对我有用,所以我为那些不想去论坛注册的人重新发布描述。

The bug is due to an error in XCode 5 when it deals with the user adding new files or folders to the project.

该错误是由于 XCode 5 在处理用户向项目添加新文件或文件夹时出错所致。

Xcode is modifying the 'Library Search Paths' build setting, and making a god-awful mess of it. Instead of adding $(SRCROOT)/ it is adding fully rooted paths to all new items, and adding random amounts of /// into other elements of the string. It also seems to be duplicating source paths in some instances, probably because it's broken the existing ones, and thinks they need adding again.

Xcode 正在修改“库搜索路径”构建设置,并将其弄得一团糟。不是添加 $(SRCROOT)/ 而是向所有新项目添加完全根路径,并将随机数量的 /// 添加到字符串的其他元素中。在某些情况下,它似乎也在复制源路径,可能是因为它破坏了现有路径,并认为它们需要再次添加。

The solution:

解决方案:

  1. Copy out your Library Search Paths string into a text editor.
  2. Remove any fully rooted paths that shouldn't be there, and replace them with the usual $(SRCROOT)/MyFiles/ type paths.
  3. Remove all extraneous slashes and make sure each path has a " character at beginning and end to protect against spaces in filenames.
  4. Paste the edited string back into Build Settings.
  5. Clean, then Build. Should be back to normal.
  1. 将您的库搜索路径字符串复制到文本编辑器中。
  2. 删除任何不应该存在的完全根路径,并将它们替换为通常的 $(SRCROOT)/MyFiles/ 类型路径。
  3. 删除所有无关的斜杠,并确保每个路径的开头和结尾都有一个 " 字符,以防止文件名中出现空格。
  4. 将编辑后的字符串粘贴回构建设置。
  5. 清洁,然后构建。应该会恢复正常。

This error may well recur if you add new files to your project, so beware.

如果您向项目添加新文件,此错误很可能会再次发生,因此请注意。

回答by QED

My project.pbxproj looked like this:

我的 project.pbxproj 看起来像这样:

LIBRARY_SEARCH_PATHS = (
        "$(inherited)",
        "\\"$(SRCROOT)/AdMob-v6.4.1\\"",
        "/MyProject/AdMob-v6.5.1",
); 

I closed MyProject, deleted the line containing AdMob-v6.4.1, reopened the project, performed a "validate project settings", cleaned, and built, and now all is well.

我关闭了 MyProject,删除了包含 的行AdMob-v6.4.1,重新打开了项目,执行了“验证项目设置”,清理和构建,现在一切都很好。

回答by Wood Guardian

Yeah, Xcode is jenky sometimes.

是的,Xcode 有时很笨拙。

Did you try cleaning your build (Product > Clean Build Folder/ Shift-Cmd-K) and trying again?

您是否尝试清理您的构建(产品 > 清理构建文件夹/ Shift-Cmd-K并重试?

Another thing you can do is to search for the two entries in [project_name].xcodeproj/project.pbxproj, remove them, close XCode, re-open, Clean Build Folder and try again.

您可以做的另一件事是搜索[project_name].xcodeproj/project.pbxproj 中的两个条目,删除它们,关闭 XCode,重新打开,清理构建文件夹并重试。

Good luck!

祝你好运!

回答by Dima Deplov

To summarise what @user2963906 is suggest, I show my solution to this problem, which I think much easy.

为了总结@user2963906 的建议,我展示了我对这个问题的解决方案,我认为这很容易。

I assume that you have all your files and libraries in your project folder.

我假设您的项目文件夹中有所有文件和库。

  1. Open your project Targets
  2. Find Search Paths topic and Library Search Paths
  3. Choose and remove all paths here
  4. Then add path like this: $(SRCROOT)/"Your App Name"
  5. In the same window change drop-down list from the right from non-recursiveto recursive
  6. Shift-?-K and Run your project
  1. 打开你的项目目标
  2. 查找搜索路径主题和库搜索路径
  3. 在此处选择并删除所有路径
  4. 然后像这样添加路径: $(SRCROOT)/"Your App Name"
  5. 在同一窗口中,从右侧更改下拉列表从non-recursiverecursive
  6. Shift-?-K 并运行您的项目

回答by mservidio

I found a solution for this with my case on the iOS Developer Forums. It happened to me with Xcode 5. See Massive Linker Error Warnings (directory not found for option) yet . For me it was caused by Xcode 5 junking up the "Library Search Paths" build setting.

我在 iOS 开发者论坛上的案例中找到了解决方案。Xcode 5 发生在我身上。请参阅Massive Linker Error Warnings (directory not found for option) yet。对我来说,这是由 Xcode 5 破坏“库搜索路径”构建设置引起的。

回答by Karthick

I faced the same problem but was unable to fix it as per the steps since no library folders were getting displayed in the Project properties window.

我遇到了同样的问题,但无法按照步骤修复它,因为项目属性窗口中没有显示库文件夹。

So I solved it in another way (you need to be able to use the Terminal and the VIM editor. Also take a backup of the project just in case)

所以我用另一种方式解决了它(你需要能够使用终端和 VIM 编辑器。同时备份项目以防万一)

  1. Open a Terminal window
  2. Go to the project folder.
  3. The XCode project is a folder. use cd project name to go into that folder.
  4. use vim to open and edit the project.pbxproj file.
  5. Remove reference to the offending lines by searching using / and using the dd command on that line to delete it.
  6. Save using :wq command
  1. 打开终端窗口
  2. 转到项目文件夹。
  3. XCode 项目是一个文件夹。使用 cd 项目名称进入该文件夹。
  4. 使用 vim 打开并编辑 project.pbxproj 文件。
  5. 通过使用 / 搜索并使用该行上的 dd 命令删除它来删除对违规行的引用。
  6. 使用 :wq 命令保存

Open the project in XCode and build. Works like a charm.

在 XCode 中打开项目并构建。奇迹般有效。

回答by pratik bhiyani

Easy Solution :

简单的解决方案:

It's work for me

这对我有用

when you want to add new files or folders to the project through xcode 5 and above error display.Just follow below simple step.(Please don't forgot to get backup of your project).

当您想通过 xcode 5 及以上错误显示向项目添加新文件或文件夹时。只需按照以下简单步骤操作即可。(请不要忘记备份您的项目)。

  1. Open your Project in Old XCode (I recommend XCode 4.6.3)
  2. Add your files or folder. (it will not mess your library search path as it mess in XCode 5)
  3. Close the old xcode and open your project with XCode 5 and start to code.
  1. 在旧的 XCode 中打开你的项目(我推荐 XCode 4.6.3)
  2. 添加您的文件或文件夹。(它不会像在 XCode 5 中那样混乱你的库搜索路径)
  3. 关闭旧的 xcode 并使用 XCode 5 打开您的项目并开始编码。

回答by rharvey

I had to escape any spaces with a \

我不得不用 \ 转义任何空格

So for example:

例如:

/Users/Me/Folder\ with\ spaces\(and\ brackets\)

/Users/Me/Folder\ with\空格\(和\括号\)

in Library Search Paths

在图书馆搜索路径中

回答by Anuprabha

In project folder -> target , under 'Build Setting' search 'library search paths' and simply delete previous path in Debug & Release area.

在项目文件夹 -> 目标中,在“构建设置”下搜索“库搜索路径”,只需删除调试和发布区域中的先前路径。

Now add the line below line using + symbol

现在使用 + 符号在行下方添加行

$(PROJECT_DIR)/Library

$(PROJECT_DIR)/库

Note: After adding the above line click out from popup. its automatically display the full path.Then check this path with your Finder if any correction add after the $(PROJECT_DIR)/

注意:添加以上行后,从弹出窗口中单击。它会自动显示完整路径。如果在 $(PROJECT_DIR)/ 之后添加任何更正,请使用 Finder 检查此路径

Clean , Build and Run … Simple its cleared that error. :)

清理、构建和运行……很简单,它清除了那个错误。:)

-Anup

-阿努普

回答by Peter Lapisu

This worked for me :

这对我有用:

Create this real directories (with no content), add them to project, remove via remove reference, clean, delete for real

创建这个真实的目录(没有内容),将它们添加到项目中,通过删除引用删除,清理,删除真实