Xcode 警告:“输出文件的多个构建命令”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2718246/
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 warning: "Multiple build commands for output file"
提问by Futur
I am getting an error like this:
我收到这样的错误:
[WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/no.png
[WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/d.png
[WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/n.png
[WARN]警告:输出文件的多个构建命令/Developer/B/Be/build/Release-iphonesimulator/BB.app/no.png
[WARN]警告:输出文件的多个构建命令/Developer/B/Be/build/Release-iphonesimulator/BB.app/d.png
[WARN]警告:输出文件的多个构建命令/Developer/B/Be/build/Release-iphonesimulator/BB.app/n.png
But I have checked Xcode and I don't see any duplicates of such files at all. As this postin the Apple Mailing Lists say, there are no duplicates.
但是我已经检查了 Xcode,我根本没有看到此类文件的任何重复项。正如Apple 邮件列表中的这篇文章所说,没有重复。
采纳答案by Futur
Actually, the answer to this is quite simple.
其实,这个问题的答案很简单。
In your Xcode project search for the files which raise the warning, and just delete one of them.
在您的 Xcode 项目中搜索引发警告的文件,然后删除其中之一。
Xcode will show only one reference of that file in the search results, but don't stop there, go ahead and delete it. (it's better to make a backup of your project file before deleting it)
Xcode 将在搜索结果中只显示该文件的一个引用,但不要停在那里,继续删除它。(最好在删除之前备份您的项目文件)
Now build the project again. The warning should disappear now. (this answer is for a previous version of xcode)
现在再次构建项目。警告现在应该消失了。(此答案适用于先前版本的 xcode)
回答by Mark Suman
In the Project Navigator, select your Xcode Project file. This will show you the project settings as well as the targets in the project. Look in the "Copy Bundle Resources" Build Phase. You should find the offending files in that list twice. Delete the duplicate reference.
在项目导航器中,选择您的 Xcode 项目文件。这将显示项目设置以及项目中的目标。查看“复制捆绑资源”构建阶段。您应该在该列表中找到有问题的文件两次。删除重复的引用。
Xcode is complaining that you are trying to bundle the same file with your application two times.
Xcode 抱怨您试图将同一个文件与您的应用程序捆绑两次。
回答by slf
This is easily caused when you add git based subprojects. Xcode isn't smart enough to ignore the .git subfolder even though you can't see it from finder, so it will get very confused that there are multiple files named "master" or "exclude", (standard git repo files). With Xcode4, go to the project (root of the left tree) then click your app target and expand "Copy Bundle Resources", then remove all the references to .git, you shouldn't need them baked into your app anyway.
当您添加基于 git 的子项目时,很容易导致这种情况。Xcode 不够聪明,无法忽略 .git 子文件夹,即使您无法从 finder 中看到它,因此它会非常困惑有多个名为“master”或“exclude”的文件(标准 git repo 文件)。使用 Xcode4,转到项目(左侧树的根目录),然后单击您的应用程序目标并展开“复制捆绑资源”,然后删除对 .git 的所有引用,无论如何您都不需要将它们烘焙到您的应用程序中。
回答by aimacworx
This is not an Xcode bug, though the warning message is not helpful enough to describe the real cause.
这不是 Xcode 错误,尽管警告消息不足以描述真正的原因。
This error message occurs when you have several files in your project that have the same name. You just have to delete or rename the files with duplicate names and the problem is solved.
当您的项目中有多个具有相同名称的文件时,会出现此错误消息。您只需删除或重命名具有重复名称的文件即可解决问题。
回答by respectTheCode
This happens if you have 2 files with the same name in the project. Even though files are in groups in XCode when the project is compiled all of the files end up in the same directory. In other words if you have /group1/image.jpg and /group2/image.jpg the compiled project will only have one of the two image.jpg files.
如果项目中有 2 个同名文件,就会发生这种情况。即使在编译项目时文件在 XCode 中成组,所有文件最终都在同一目录中。换句话说,如果您有 /group1/image.jpg 和 /group2/image.jpg 编译后的项目将只有两个 image.jpg 文件之一。
回答by Stuart
As previously mentioned, this issue can be seen if you have multiple files with the same name, but in different groups (yellow folders) in the project navigator. In my case, this was intentional as I had multiple subdirectories each with a "preview.jpg" that I wanted copying to the app bundle:
如前所述,如果您在项目导航器中有多个同名但位于不同组(黄色文件夹)中的文件,则会出现此问题。就我而言,这是故意的,因为我有多个子目录,每个子目录都有一个“preview.jpg”,我想将其复制到应用程序包中:
In this situation, you need to ensure that Xcode recognises the directoryreference (blue folder icon), not just the groups.
在这种情况下,您需要确保 Xcode 识别目录引用(蓝色文件夹图标),而不仅仅是组。
Remove the offending files and choose "Remove Reference" (so we don't delete them entirely):
删除有问题的文件并选择“删除引用”(因此我们不会完全删除它们):
Re-add them to the project by dragging them back into the project navigator. In the dialog that appears, choose "Create folder references for any added folders":
通过将它们拖回到项目导航器中,将它们重新添加到项目中。在出现的对话框中,选择“为任何添加的文件夹创建文件夹引用”:
Notice that the files now have a blue folder icon in the project navigator:
请注意,文件现在在项目导航器中有一个蓝色文件夹图标:
If you now look under the "Copy Bundle Resources" section of the target's build phases, you will notice that there is a single entry for the entire folder, rather than entries for each item contained within the directory. The compiler will not complain about multiple build commands for those files.
如果您现在查看目标构建阶段的“复制捆绑资源”部分,您会注意到整个文件夹只有一个条目,而不是目录中包含的每个项目的条目。编译器不会抱怨这些文件的多个构建命令。
回答by Gunther
This is not a bug. Xcode assists can assist you. Select the target, to the left in the project Navigator. Click on "Validate settings" at the bottom of the settings. Xcode will check the settings and removes duplicates if possible.
这不是一个错误。Xcode 助手可以为您提供帮助。选择项目导航器左侧的目标。单击设置底部的“验证设置”。如果可能,Xcode 将检查设置并删除重复项。
回答by john.k.doe
another version of this situation can occur when there are duplicates in the Headersbuild phase.
当Headers构建阶段存在重复项时,可能会发生这种情况的另一个版本。
to fix this …
解决这个问题……
- go to your project target
- choose
Build Phases
- choose the
Headers
build phase - enter the name shown in the warning
- notice the two (or more) items
- find the
+|-
boxes in the lower left corner - select one of the items, and click the
-
button
- 转到您的项目目标
- 选择
Build Phases
- 选择
Headers
构建阶段 - 输入警告中显示的名称
- 注意两个(或更多)项目
- 找到
+|-
左下角的框 - 选择其中一项,然后单击
-
按钮
回答by Dmitry
In my case the issue was caused by the same name of target and folder inside a group.
在我的情况下,问题是由组内的目标和文件夹的相同名称引起的。
Just rename conflicted file or folder to resolve the issue.
只需重命名冲突的文件或文件夹即可解决问题。
回答by Mahmoud Fayez
I found a pretty easy solution for this:
我找到了一个非常简单的解决方案:
- Select the file causing the problem from the project navigator
- Uncheck the target membership from the file inspector
- Build the project
- Recheck the target membership for the file again
- 从项目导航器中选择导致问题的文件
- 从文件检查器中取消选中目标成员资格
- 构建项目
- 再次重新检查文件的目标成员资格
The warning is gone! Check this image for reference.
警告消失了!检查此图像以供参考。