XCode: 'Warning: Multiple build commands for output file' but I get error if I delete the duplicate - ios

I get the errors:
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/myapp-csoyvdzaugzkszeagjrtzrfssudr/Build/Products/Debug-iphonesimulator/myapp.app/icon-72.png
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/myapp-csoyvdzaugzkszeagjrtzrfssudr/Build/Products/Debug-iphonesimulator/myapp.app/Default-Landscape#2x~ipad.png
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/myapp-csoyvdzaugzkszeagjrtzrfssudr/Build/Products/Debug-iphonesimulator/myapp.app/Default-Landscape~ipad.png
When I try to run my app in the simulator. I understand this is because of duplicate files. But when I remove either of the duplicates I get the errors:
error: /Users/me/Documents/Cordova27/myapp/myapp/Resources/icons/icon-72.png: No such file or directory
Does anyone know how to fix this at all? Have tried cleaning and restarting XCode to no avail.

open the Copy Bundle Resources Build Phase. find the twice files in that list and Delete the duplicate reference.

Remove both,Add again.[Drag and drop at the icon field in the summary page]

I moved bunch of images to a different folders and hit the same issue. To solve, basically go to build phases >> Copy Bundle Resources and remove earlier references as shown in the picture below.
Note: Another thing to check is to see if you have multiple references of the files in the left panel (you will see 2 files with the same name)

If you set the splash/launch icon from Xcode (Targets -> Summary ...), the Xcode has an annoying feature that will copy your png file into the root folder, and after that you will get the warning for "Multiple build commands". What you need to do is, delete your png file used for splash/launch and also check the copy bundle resources in Target section and make sure your file has been removed from there. It will appear in red if the file is removed from your project and not removed from Copy bundle resources.

My problem was also in Copy Bundle Resources, but my cause was fast lane. All of my fastlane files name.txt, keywords.txt, marketing.txt, etc. were copied from each of my support languages into the bundle.
Go to your target Build Settings. In the search tool, enter the name of each fastlane file. In this case, you can delete all fastlane files. These are used for uploading your bundle to the App Store and so the files don't need to be in the bundle at all.

Add a new image(PNG) only via Copy Bundle Resources. Remove duplicates same way.

Related

Xcode error when attempting to archive project: Unexpected duplicate tasks

My project runs totally fine with no warnings on both the simulator and a real device, but when I try to archive it, I get this error:
Unexpected duplicate tasks:
1) Target 'SwiftDataTables' (project 'Pods') has copy command from '/myAppPath/Pods/SwiftDataTables/SwiftDataTables/SwiftDataTables.bundle/column-sort-descending.png' to '/Users/Marius/Library/Developer/Xcode/DerivedData/myAppName-bvaclcqghnevllgdezgzmpfvrzrz/Build/Intermediates.noindex/ArchiveIntermediates/myAppName/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/SwiftDataTables.framework/column-sort-descending.png'
2) Target 'SwiftDataTables' (project 'Pods') has copy command from '/myAppPath/Pods/SwiftDataTables/SwiftDataTables/SwiftDataTables.bundle/column-sort-descending.png' to '/Users/Marius/Library/Developer/Xcode/DerivedData/myAppName-bvaclcqghnevllgdezgzmpfvrzrz/Build/Intermediates.noindex/ArchiveIntermediates/myAppName/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/SwiftDataTables.framework/column-sort-descending.png'
I get this error 3 times, one for each of the pictures that are in the SwiftDataTables.
I have already tried cleaning the project, uninstalling and reinstalling the problematic library, and removing all the files from Derived Data. From what I have seen from other similar questions, the solution is often checking that a file isn't listed both in Copy Bundle Resources and Compile Sources in target/Build phases, but I can't find any file that is listed twice.
Thanks in advance.
I could fix it by selecting the three images in Xcode and then remove the Target Membership for SwiftDataTables and adding it again.
Try again - In the file navigator you can try searching (Cmd+F) to see
if the files are somehow in the project twice. Try removing entire
framework and any references from the file navigator and the build
settings (check under Frameworks folder, et al), and then re-add. Check the pods files listed in the build
settings. There is a place where the file paths are added for example
if you tried using Carthage previously where the duplication is
occurring.

Validation Error: The bundle contains disallowed file 'Frameworks'

I'm having the same issue as this guy, this guy, and this guy (nota bene, I'm actually not sure if they're all guys, per se).
They all ended up finding their own solutions, but none of them apply to my issue. I'm using Xcode 6.1 in my iOS 8 app with an included extension. The app and the extension both rely on an included framework. When I try to submit the app to the Store, the validation warning I get is "ERROR ITMS-9000: Invalid bundle. The bundle at 'xxxxx.appex' contains disallowed file 'Frameworks'".
I can't even find a file called Frameworks. The shared framework is supposed to be saved at /Library/Frameworks, which is Apple's recommended save location. The project also uses Cocoapods, which strikes me as the only other possible culprit, since it has references in its configuration files to $FRAMEWORK_PATH (though the build folder doesn't include a file or folder with that name).
OK for future viewers here's the fix:
When you create your own iOS framework (I'm using Xcode 6.1) when you build it the final product contains a 'Frameworks' folder in the framework bundle itself. i.e. MyFramework.framework/Frameworks. This happens even if you don't specify a copy files/embed frameworks build phase.
What you have to do is to go into you framework bundle, find the empty frameworks folder and delete it. This should not affect your app's functionality in any way. Then build your app and check that the embedded framework doesn't have a Frameworks folder as planned.
Your archive should now not contain the offending folder and the error should be gone!
I changed build settings > Packaging > Define modules set to YES in my extension and watch app target. Works fine for me.
In my case the solution was the following :
Try to create the script there 'problematic target' -> Build Phases' then click on + and select New Run Script Phase, the run script should go after all others. Insert there :
cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi
Then clean the project and try to create an archive once again. These answer was provided in the following issue :
https://github.com/CocoaPods/CocoaPods/issues/4203
I hope this help you.
Continuing to work with this, I noted that my Share Extension had an "Embed Frameworks" Build Phase, with the Destination set to the "Frameworks" directory. I changed it to "Shared Frameworks" and the error has gone away.
However, another error remains: "... contains disallowed nested bundles". I thought this was a sort of umbrella error warning as a result of the original. I'll open another question for that one.

Settings bundle - how to remove it

I've added settings bundle at the beginning of project then I've decided to have in-app settings which I've implemented. I've removed settings bundle but still settings are visible out of the app. How can it be? I've checked the Copy bundle resources and there is no trace of it.
Since the build process is optimized for speed, some file will be kept in a build folder and copied to your app when you hit run. Thus removing them from your project will not always have the effect you want.
To solve this press alt+clean (alt+shift+command+k) to clean the build folder, also notice that the name of clean command changes to Clean Build Folder.

Invalid bundle structure - The app may contain only one executable file.

This question is similar if not identical but there is no solution. I've looked inside the archive and there's only one executable, so I am at a loss as to how to proceed. Any ideas greatly appreciates.
Invalid Build Structure
The binary file 'YourApp.app/libYourLibrary.a' is not permitted.
Your app may contain only one executable file.
This error occurs when a static library file is mistakenly copied into the app bundle.
You should link the libYourLibrary.a static library via a Link Binary with Libraries build phase.
It should NOT be added to the target's Copy Bundle Resources build phase.
My app was rejected with the same error message. It turned out that I was copying a third party framework (Fiksu) in the 'Copy Bundle Resources' build phase. The framework contained an executable and was already linked to in the 'Link Binary With Libraries' build phase. I deleted the framework from the 'Copy Bundle Resources' build phase. The framework continued to work normally in a release build. I resubmitted the app and it passed validation. Similar solution was posted here:
https://devforums.apple.com/message/1020254#1020254
In hindsight the error is straightforward. An executable file was accidentally added to the project. In my case "Develop!.app/Xcode" meant that Xcode was the executable. Checking the list of files in the project I found a symlink to Xcode. (Maybe I dragged it from the dock somehow and dropped it into the project).
If you are getting this error look at the files in your project -- there is an executable there somewhere.
I had this issue for the first time on an app I'd submitted over several versions with no issues.
I found that somehow that although I'd linked to one of my own libraries, one of the source files from that same library appeared in the list of files in the "Copy Bundle Resources" list. I have no idea how it got there but removing it meant that my app build, archived and was submitted successfully. :-)
If you are getting error in following format:
"Invalid Bundle Structure - The binary file 'Abc.app/AnyFileName.o' is not permitted.
Build Phases > Copy Bundle Resources > check your file AnyFileName.swift will be added too here. (Remove it)
validate it with XCode. Error gone !!
In my case I tried to remove references but nothing worked for me. Then I uninstall particular pod, remove references as mentioned here and then install that particular pod again. It worked for me.
For those who required elaboration check below:
1)
In Podfile comment the particular pod by adding # in the beginning and save it:
On command line run: pod install // It will uninstall that framework
2) Removed references of that framework from:
Link Binary with Libraries // In Build Phase
Copy Bundle Resources // In Build Phase
Embed Frameworks
3) Now install Pod again, Remove # which you added before and save it.
On command line run: pod install // It will install that framework again
Just delete the exec file from your bundle and delete the "Executable file" key from your bundle resources.
After that archive and validate the the the build it will work.

Xcode copying unnecessary files into target

In my Xcode project, I have it set to copy all the files I need in the "Copy bundle resources" step and it doesn't link to any extra libraries, yet when I compile the project it copies a number of files that aren't even in the project's file references (a number of .dll files that have nothing to do with this version of the app).
The files may have accidentally been added to the "copy bundle resources" step at one point but were since removed. How can I find out why are these files still being copied and how can I prevent it?
Turns out the files were left over from a build before those files were removed. Trashing the app from the products folder got rid of the extra files.

Resources