ios xcodebuild 失败 clang:error 没有这样的文件或目录:

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

xcodebuild failure clang:error no such file or directory:

iosxcodexcodebuildadhoc

提问by Todd McGuinness

Having a problem when building with xcodebuild. My project/app builds fine with the Xcode - gui. It simply isn't finding/building the libcryptopp library which is part of the build process.

使用 xcodebuild 构建时遇到问题。我的项目/应用程序使用 Xcode - gui 构建得很好。它只是没有找到/构建 libcryptopp 库,它是构建过程的一部分。

The error is:

错误是:

clang: error: no such file or directory: '/Users/builder/repo/ioskpay/xcode-cryptopp/cryptopp/build/Release-iphoneos/libcryptopp.a'  

This particular file should be derived from another project inside the main app - xcodebuild simply isn't correctly pointing at the right file folder which should be:

这个特定的文件应该来自主应用程序中的另一个项目 - xcodebuild 根本没有正确指向正确的文件夹,应该是:

~/Library/Developer/Xcode/DerivedData

Any ideas?

有任何想法吗?

回答by Ken Van Hoeylandt

To fix this, go to your project settings, go to Targetsand select your main project target. Then go to Build phases. Under Target dependenciesadd the static library project.

要解决此问题,请转到您的项目设置,转到Targets并选择您的主要项目目标。然后去Build phases。在Target dependencies添加静态库项目下。

This way, when you compile the main project, the static library subproject gets compiled before the main project and your static library will be available.

这样,当您编译主项目时,静态库子项目会在主项目之前编译,您的静态库将可用。

回答by Khaled Annajar

I had the same problem, but for a resource file .m

我有同样的问题,但对于资源文件 .m

I opened target -> build phases -> Compile sources

我打开了目标 -> 构建阶段 -> 编译源

and I found the file the compiler was tell it can't find duplicated: one with strange icon and the other with a normal icon. I simply removed the one with strange icon and it worked. ( I added the file multiple times and I had a merge conflict before that which made something wrong in the project file)

我发现编译器告诉它找不到重复的文件:一个带有奇怪的图标,另一个带有普通图标。我只是删除了带有奇怪图标的那个并且它起作用了。(我多次添加了该文件,并且在此之前发生了合并冲突,这在项目文件中出现了错误)

For your case I think you need to remove the lib from target dependencies list and add it again. This may work for you.

对于您的情况,我认为您需要从目标依赖项列表中删除 lib 并再次添加它。这可能对你有用。

回答by William Cerniuk

In Xcode Version 9.2 (9C40b) this happened when I drug a bunch of files into the project, some of which were duplicate. Rather than simply not adding the duplicates, it added them again and only the name, not the path.

在 Xcode 版本 9.2 (9C40b) 中,当我将一堆文件放入项目时会发生这种情况,其中一些文件是重复的。它不是简单地不添加重复项,而是再次添加它们,并且只添加了名称,而不是路径。

In Target> Build Phases> Compile Sourceseach of the duplicates showed with no "...in" after them. Each one caused the clang error.

Target> Build Phases> 中,Compile Sources每个重复项后面都没有“...in”。每一个都导致了叮当声错误。

enter image description here

在此处输入图片说明

After removing all of the duplicates that Xcode collected, the project compiled and ran.

删除 Xcode 收集的所有重复项后,项目编译并运行。

It makes you use the Project Navigator instead of managing your source files in the Finder. Then the Project Navigator can't replace duplicates like any decent file management system (ahem Finder).

它使您可以使用 Project Navigator 而不是在 Finder 中管理您的源文件。然后 Project Navigator 不能像任何像样的文件管理系统 (ahem Finder) 那样替换重复项。

回答by Pedro Martín

My xCode info is:

我的 xCode 信息是:

image

图片

I faced similar errors during xcode building projects (native swift, flutter, react native, native script) in which I got error messages related to clang compilar. Errors like:

我在 xcode 构建项目(原生 swift、flutter、react native、原生脚本)期间遇到了类似的错误,其中我收到了与 clang 编译器相关的错误消息。错误如:

  • clang-4.0: error: no such file or directory: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
  • clang-4.0: error: cannot specify -o when generating multiple output files
  • others
  • clang-4.0:错误:没有这样的文件或目录:'/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
  • clang-4.0:错误:生成多个输出文件时无法指定 -o
  • 其他

Despite of errors related with DerivedData for native apps can be fixed by deleting the directory and, eventually, restart xCode and even restart the machine... in this case, you will see that after deleting the directory and start building process again, the error comes back.

尽管与原生应用程序的 DerivedData 相关的错误可以通过删除目录来修复,最终,重新启动 xCode 甚至重新启动机器......在这种情况下,您将看到在删除目录并再次开始构建过程后,错误回来。

Then, is the moment of checking the clang installation by running clang --version. The normal output will be something like:

然后,是通过运行检查 clang 安装的时刻clang --version。正常输出将类似于:

image

图片

as you can see the InstalledDiris incorrect for xCode. In my case, some days ago I needed to install Anaconda app (R, Python, etc) and, now, I remember that I had to install some dependencies and one of them was clang and its installation was altered. To fix this problem (in my case that I will not need anaconda any more): (edited)

如您所见InstalledDir,xCode 不正确。就我而言,几天前我需要安装 Anaconda 应用程序(R、Python 等),现在,我记得我必须安装一些依赖项,其中之一是 clang,其安装已更改。要解决此问题(在我的情况下,我不再需要 anaconda):(已编辑)

1.- Delete anaconda and all its dependencies (I recommend to use App Cleaner). 2.- Re-install xCode

1.- 删除 anaconda 及其所有依赖项(我建议使用 App Cleaner)。2.- 重新安装 xCode

After reinstalling xCode, if you type again clang --version, you'll get this:

重新安装 xCode 后,如果再次键入clang --version,您将得到:

image

图片

More info at: https://github.com/flutter/flutter/issues/32457#issuecomment-496161092

更多信息请访问:https: //github.com/flutter/flutter/issues/32457#issuecomment-496161092

Hopefully, this info helps some else.

希望这些信息可以帮助其他人。

Best

最好的事物

回答by AMIT

Run this command :

运行此命令:

$ conda deactivate

回答by bigpotato

For me it was because I had removed a package or pod. I ran pod installand it fixed it

对我来说,这是因为我删除了一个包或 pod。我跑了pod install,它修好了

回答by Todd McGuinness

Ok so by simply adding the correct -target -configuration and -scheme parameters I got this to run correctly. However due to my running this in Jenkins for autobuild purposes it still doesn't work as I'd like - getting stuck in exactly the same place. It's odd because I have the exact same code being built in another job that isn't having this problem. There is no rhyme or reason for it at this point. I will keep shooting rubber bands at it and update when I have an answer...

好的,只需添加正确的 -target -configuration 和 -scheme 参数,我就可以正确运行。但是,由于我在 Jenkins 中出于自动构建目的运行它,它仍然无法像我希望的那样工作 - 卡在完全相同的地方。这很奇怪,因为我在另一个没有这个问题的工作中构建了完全相同的代码。在这一点上没有押韵或理由。我会继续用橡皮筋射击它并在我有答案时更新......

回答by ErAcube

Sometimes Xcode performs weird. You have to find that static library project e.g.. "filename.a" under 'Link Binary With Libraries' in Build Phase and then remove it and add it again.

有时 Xcode 的表现很奇怪。你必须找到那个静态库项目,例如。“文件名.a”在构建阶段的“链接二进制与库”下,然后将其删除并再次添加。

I had the same problem while I was archiving my target. I removed the library and the build succeeded.

我在归档目标时遇到了同样的问题。我删除了库并且构建成功。

回答by sudhakkar k

Look for the missing file in the Xcode project i.e the files may be deleted or miss placed.

在 Xcode 项目中查找丢失的文件,即文件可能被删除或丢失。

enter image description here

在此处输入图片说明

add the missing files to the xcode, then everything will work fine.

将丢失的文件添加到 xcode,然后一切正常。