Xcode copying unnecessary files into target - ios

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.

Related

Copy an existing Xcode project results in files with wrong references

I have a working project that builds ok. (Xcode 6.0.1)
There were images added that were at one folder (/Downloads) and were substituted by new ones (/MyDir/MyProject).
At adding files process copy options, group and add to it's targets were selected.
After a copy and paste at Finder from the root project folder to the new project some images contain references at Targets / Build Phases / Copy Bundle Resources to old folder (Downloads) while they are ok at original project.
I've deleted the .git from initial project to make sure it's not a git problem.
Already tried
rm -rf ~/Library/Developer/Xcode/DerivedData/
Any ideas? Thank you
In the rightmost panel, which contains Identity and Type, check to see if the "Location" field is Absolute Path, Relative to Group, or Relative to Project, and set each file accordingly to what it should be. Xcode seems to create new files with creative ideas on how this should be set.
check in your project build phases if there are some missing references and delete the one you don't need

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: 'Warning: Multiple build commands for output file' but I get error if I delete the duplicate

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.

Does Xcode include miscellaneous files in the project folder when building

I keep some miscellaneous files in the folder for my project, files not actually involved in the build. I was wondering, however, wether Xcode will include these in the build. I need to make sure these files aren't taking up space and slowing down builds. Do these files have any effect?
Xcode will only include files that have been added to the projects copy bundle resources build phase.
You can see these files by selecting your project , click on the target , the select the build phases tab, and click on the Copy Bundle Resources.

.xib file not in Compile Sources build phase, but still builds correctly; how can this be?

When you start with an Xcode template that has a .xib file, that .xib file is listed in the Compile Sources build phase. This makes sense to me, because during the build process the .xib file needs to be turned into a .nib file (with ibtool), and it is.
But in renaming my .xib files and adding some new ones, I ended up in a situation where none of my .xib files are listed in the Compile Sources build phase. Instead, they are all listed in the Copy Files build phase. I was not able to fix this. (Don't get me started about that.)
But it turns out I don't have to fix it! When I build, I can look into the package of the built app and I see that it has .nib files, not .xib files. The .xib files are not being copied into the resources folder, even though they are in the Copy Files build phase; they are being compiled, even though they are not in the Compile Sources build phase.
And I can confirm this by looking at the build log:
CompileXIB "MyApp/en.lproj/ViewController~iphone.xib"
CompileXIB "MyApp/en.lproj/ViewController~ipad.xib"
How can this be?
EDIT: Now I can't reproduce my initial premise! As one respondent has said, the template doesn't put the .xib files in the Compile Sources build phase. Yet I certainly ended up in a situation where some .xib files were in the Compile Sources build phase and some where in the Copy build phase, and that's what confused me.
When I create a completely new Xcode project for OS X using the "Cocoa Application" template, the project's only .xib file is not listed under "Compile Sources", its listed under "Copy Bundle Resources". So I'm not sure how/why your .xib's are getting listed under Compile Sources in the first place.
As for how they are automatically getting compiled using the CompileXIB command, I suspect it is due to Xcode's Build Rule called "Interface Builder XIB Compiler", which runs for all Interface Builder files.

Resources