Xcode warning: "Multiple build commands for output file"
Asked Answered
C

26

505

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

But I have checked Xcode and I don't see any duplicates of such files at all. As this post in the Apple Mailing Lists say, there are no duplicates.

Carmelinacarmelita answered 27/4, 2010 at 1:52 Comment(0)
C
118

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 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)

Now build the project again. The warning should disappear now. (this answer is for a previous version of xcode)

Carmelinacarmelita answered 30/4, 2010 at 21:11 Comment(2)
But the files don't come up in XCode's groups and files pane any more. What's the deal with this?Ultramarine
If you continue having trouble with this, just remove all files from Xcode (don't delete them on disk). Then drag them all back in. If you still have issues after than then you actually have some resources with the same name (maybe in different folders) - find and rename/delete. Xcode output goes into a flat folder so directory structure is ignored.Afterdamp
D
818

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 is complaining that you are trying to bundle the same file with your application two times.

Doenitz answered 14/4, 2011 at 6:28 Comment(10)
How to "Go to the target you are building"Dinerman
In the Project Navigator, select your Xcode Project file. This will show you the project settings as well as the targets in the project.Doenitz
Happens to me when I deleted some assets from the build folder (using Finder). Assets replaced with those updated with the same names and dragging them within XCode flagging "add to target" options. It seems XCode goes out of synch duplicating those entries in Copy Bundle ResourcesTrauma
I wanted to add one thing to this. If you end up with a ton of duplicate references somehow (like I did), you can simply click "Validate Settings" and it will automatically delete duplicate references. Much easier than manually seeking them outLeukocyte
I had a similar issue. This answer was the closest. The <projName>.xcodeproj/project.pbxproj file had duplicate entries even though the project showed the files only once. This was a merging issue. editing with vi did the trick :) Thanks for pointing me in the right direction :)Paraffin
Worth noting that if you have a large amount of duplicated files in the Copy Bundle Resources phase, you can click 'Validate Settings' on the bottom of this page and XCode will prompt you about the duplicates and will remove all of them if you click 'Perform changes'. Hell of a lot faster than hunting for them individually.Seep
I had a similar issue with SpriteBuilder templates when I re-added the "Published-iOS" to the project. Turns out it wants it to be a "folder reference" and not a group, and had added that entire folder into the "Copy Bundle Resources". So even if the individual resource does not appear in that list, check to make sure it's not being added from a folder.Alanson
@Seep That button does not exist, atleast at the time of writing and in Xcode 10.1Armijo
in my situation, "Copy Bundle Resources" only had 1 file reference, however the file was also referenced in "[CP] Copy Pods Resources", removing one of those references worked for meSteffie
@Greg Hilston : See Menu: Editor / Validate Settings.. worked for me.Melodymeloid
E
127

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.

Eckard answered 12/3, 2011 at 20:5 Comment(2)
I fumbled about for a second, so this may help someone: app target -> build phases -> copy bundle resourcesThirtythree
I had multiple files with the same name (but in different directories) in my Xcode project. Accidently one of my had both of them in the Copy Bundle Resources step, which would result in one of them being overwritten in the resulting app bundle. Just remove one of them.Pitarys
C
118

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 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)

Now build the project again. The warning should disappear now. (this answer is for a previous version of xcode)

Carmelinacarmelita answered 30/4, 2010 at 21:11 Comment(2)
But the files don't come up in XCode's groups and files pane any more. What's the deal with this?Ultramarine
If you continue having trouble with this, just remove all files from Xcode (don't delete them on disk). Then drag them all back in. If you still have issues after than then you actually have some resources with the same name (maybe in different folders) - find and rename/delete. Xcode output goes into a flat folder so directory structure is ignored.Afterdamp
P
53

This is not an Xcode bug, though the warning message is not helpful enough to describe the real cause.

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.

Pester answered 21/12, 2010 at 6:22 Comment(4)
Yes, this is the correct answer. And the situation can easily arrive when you have resource files, e.g. pngs with the same name but in separate dirs on your file system - during the build process they all get copied to 1 dir, namely the app bundle.Gard
@Gard is there a work around to allowing images with the same name? or to prevent the images from getting bundled together?Paraclete
Actually I figured out that you can create Folder References to avoid the bundling.Paraclete
Here is a way to find files with duplicate name, regardless of directory find . | grep -v \.git | rev | cut -d/ -f1 | rev | sort | uniq -c | sort however, this did not solve my problemVariant
S
26

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.

Shaunta answered 10/11, 2010 at 11:9 Comment(0)
S
20

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:

group references

In this situation, you need to ensure that Xcode recognises the directory reference (blue folder icon), not just the groups.

Remove the offending files and choose "Remove Reference" (so we don't delete them entirely):

remove group references


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":

add as folder references


Notice that the files now have a blue folder icon in the project navigator:

folder references


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.

Sundog answered 25/9, 2013 at 10:32 Comment(1)
Best answer! It works for me on the Xcode 12.2Miranda
E
15

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.

Expiry answered 22/2, 2012 at 0:56 Comment(0)
V
15

another version of this situation can occur when there are duplicates in the Headers build phase.

to fix this …

  1. go to your project target
  2. choose Build Phases
  3. choose the Headers build phase
  4. enter the name shown in the warning
  5. notice the two (or more) items
  6. find the +|- boxes in the lower left corner
  7. select one of the items, and click the - button
Viradis answered 11/10, 2014 at 18:3 Comment(0)
M
8

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.

Myelitis answered 21/8, 2011 at 16:28 Comment(1)
This is similar to what I had. I had 2 separate targets with the same module name.Klatt
E
6

I found a pretty easy solution for this:

  1. Select the file causing the problem from the project navigator
  2. Uncheck the target membership from the file inspector
  3. Build the project
  4. Recheck the target membership for the file again

The warning is gone! Check this image for reference.

enter image description here

Engrain answered 28/8, 2012 at 2:5 Comment(0)
H
5

I'm pretty sure this can be caused by an XCode 4 bug, at least in the cases that I've encountered it in.

It happens if you add multiple language dependent files to the project at the same time. I found this out by looking through the git differences. I did nothing in the commit but add some new localized nib files. But looking back at the difference of the project.pbxproj file it showed a bunch of new duplicate references added for files that were already in the project before. The files it did this too seemed random to me.

I reproduced this same exact behavior multiple times.

Deleting these files from the project does not fix the problem because it only deletes the original reference and leaves the duplicates. The only way to fix it is to go back a commit and start over, or hand edit the project file, which is a really good way to screw it up even more since it's hard to tell which duplicates to remove and you have to do it in a ton of different places.

Xcode 4 is just a huge disappointment for me.

Higdon answered 20/5, 2011 at 20:46 Comment(3)
Looks like this is fixed in XCode 4.2. In earlier versions you can avoid this bug by first placing the file you're about to add localizations for into it's own "Group" (virtual folder in the project). Once you're done adding localizations you can put it back where it was and delete the temp Group you created.Higdon
This is not a bug. It is due to having more than one file with the same name in your project.Givens
When you localize a file you're supposed to have the same file name for each localization, except in different directories. This was indeed a bug.Higdon
S
4

This happends because ur "no.png" "d.png" and "n.png" are duplicated in resources . Just look for delete dublicated files and delete.

Screening answered 23/9, 2011 at 10:36 Comment(0)
A
3

The error seem to appear when u have more than one reference of the same file. I had 2 files of the same name and got this error. When I delete one of them the error disappear..

Accrete answered 20/2, 2011 at 14:27 Comment(0)
R
2

Yet another variation on this issue. I had the same message come up none of the previously suggested solutions solved the problem (I definitely only had one copy of the offending file for instance).

My solution was to edit the project.pbxproj file in a text editor (after quitting XCode and backing up the file of course) and remove all references to the offending file. Then, after starting XCode again, I manually added the file back into the project and everything was ok.

(My suspicion is that this problem happened to me because of a manual, ie: non-XCode, merge of the project file.)

Remonstrant answered 9/6, 2011 at 13:25 Comment(0)
E
1

Open the Frameworks folder in your project and make sure there are only frameworks inside. I added by mistake the whole Developer folder!

Eirena answered 18/6, 2012 at 18:8 Comment(0)
C
1

I had the same problem minutes ago. I've mentioned changing the 'deployment target' fixed my problem.

Cotter answered 13/3, 2013 at 17:17 Comment(0)
F
1

For me the Target > Build Settings > Packaging > Product Name was set to the same thing as another value referenced in a .plist file which was custom to my app. Eventually due to our build process this creates duplicate files.

Frey answered 9/7, 2014 at 16:15 Comment(0)
D
1

Commenting use_frameworks! in PodFile worked for me.

#use_frameworks!

Note: Did this on XCode 10.1, pod version 1.8.4

Directorial answered 7/2, 2020 at 5:52 Comment(0)
S
0

Swift 3: (but also the older versions) it happen when I have assets with duplicates. Just rename the files with this issue and all go well.

It could happen also when you have made a Assets.xcassets and you have renamed the duplicates with new names so after time you forgot it and remove it to add the folder references but this one return to the duplicate files problem..

Selfdetermination answered 7/10, 2016 at 10:27 Comment(0)
M
0

One of simple way is,

  • Go to App target
  • Go to Build Phases
  • Output files
  • Delete path of out put files, then build project. It will run successfully.
Mangrove answered 21/12, 2018 at 9:56 Comment(0)
S
0

The key was to do pod deintegrate and rm *.workspace file ! What a waste of time !

Staid answered 10/6, 2019 at 4:55 Comment(0)
A
0

React-Native users. goto file -> workspace settings -> build system -> change it to legacy build system. and it should build fine now. React-Native isn't compatible with the new file system yet.

Absorbed answered 30/12, 2019 at 19:42 Comment(0)
P
0

This might also happen in cases where you have multiple xcode project which reference the same library in your workspace, the worksapce tries to copy the same library to the the BUILD dir even if you build a target that is dependent on a single framework.

To solve this I have used: Select yout target and click: -> Edit Sheme enter image description here -> Under build - UNCHECK Find implicit dependencies enter image description here In some cases I also had to unckeck Parallelize Build

Precedence answered 20/5, 2021 at 21:52 Comment(0)
F
0

"Product Name" in Build Settings was empty in my case. So the output becomes .app with empty name which leads multiple products. Set a product name and you are good to go.

Farrington answered 26/6, 2021 at 16:0 Comment(0)
R
0

For me this was because i changed project folder name.

and i solve it by changing the project folder name from Targer app > Build Settings > info.plist file change folder name here.

enter image description here

Replication answered 24/9, 2023 at 13:42 Comment(0)
S
-1

While I'm sure there is a better way, nuking only took me less than 60 seconds, and was the only thing I could find that worked.

  1. Drag repo to the trash.
  2. re-clone your repo.
  3. set up your repo with correct remote tracking. git remote add <url.git>, or git remote set-url <url.git>
Stephanotis answered 8/10, 2018 at 23:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.