How to trash app file with pathname too long after failed app build - Xcode 12 new build system with MacOS 11.5.2 - macos-big-sur

I have files in trash that I can't delete with an error that the pathname is too long. How can I get rid of those?
Where these files came from: I was getting Xcode 12 build failures after switching over to new build system with a plist too long error; stackoverflow helped with that -- the problem was that somehow the Product target (the app) was marked as included in the target, thereby recursively creating a giant path for the app. So unchecking the box allowed the build to complete. Thanks everybody!!
However, in the fray, I frequently cleaned the Build folder or trashed the Derived Data folder. Now I have a bunch of zero-length files for the app in the trash; emptying the trash fails with an error that it can't delete the app file because the pathname is too long. Nothing else got deleted from Trash either.
Any suggestions of how to get these cleaned up?

I managed to clean up the bad app files, but I have no idea why it worked. Note that the app icons were greyed out with a "stop" icon throughout. I decided I would clean up as much as possible, so I dragged all of the current contents of Trash (the many Derived Data & Build folders) into another desktop folder, and moved everything that wasn't a bad app file back into Trash, and emptied Trash. I left each app file in its immediate enclosing folders. Then I tried to consolidate the remaining bad app files into as few folders as possible, and along the way I discovered that I could force a replacement of one bad app file with another (just dragging it into the other's folder). So I got down to only one bad file. Then I tried moving it Trash, and bang - I could empty Trash now! Maybe my manipulations caused it to get a legal size path? Most bizarre thing I have seen on MacOS, and I started with the original 512K Mac! Any explanation?

Related

How to clean junk files in Xcode from iOS support

I have tried cleaning the simulator but it again occupies 6gb disk space on my Mac.
Can anyone suggest manual cleaning?
If the objective is to free up disk space occupied by Xcode-related and simulator-related caches and data, and not just iOS support files, there are other folders you can look into to consider removing files, besides ~/Library/Developer/Xcode/iOS DeviceSupport/ and ~/Library/Developer/Xcode/DerivedData that have been mentioned in the other 2 answers so far.
~/Library/Developer/Xcode/Archives/ contains data from your builds that can be helpful in the process of symbolicating/debugging deployed apps, but could otherwise be removed. Thankfully, it is organized by date, so you can choose to keep specific folders inside it, and delete the rest
~/Library/Developer/CoreSimulator/ contains simulator related data. It includes a Caches folder and a Devices folder. If you no longer need to run your apps on certain devices, you may consider removing those devices' corresponding folders in the Devices folder. The Caches folder may grow over time as well, and you can remove contents from there, and they should be regenerated as needed.
If you've been using this machine for some years, it may be worth looking for ~/Library/Application Support/iPhone Simulator. The simulator related files used to be there until around Xcode 6. So you may have files still there that you might want to delete (I did, on some older Macs some years back)
There's an Xcode specific cache (not about simulators), ~/Library/Caches/com.apple.dt.Xcode, which should be regenerated as needed, but may be less useful to clean up.
You could also consider running DevCleaner from time to time to remove unnecessary Xcode-related files.
Delete the contents of "~/Library/Developer/Xcode/iOS DeviceSupport/".
Remove all "paired devices" in iOS settings > Developer.
Connect iPhone to the Mac and pick "Don't trust".
Since the above is not okay for iTunes syncing etc, try the following:
Delete the contents of the folder "~/Library/Developer/Xcode/iOS DeviceSupport/" and then right click > get info > lock the folder.
Locking the folder will stop Xcode from copying the simulator files from the iPhone to that folder next time you connect them.
https://apple.stackexchange.com/questions/380024/how-to-stop-xcode-downloading-ios-support-package-of-my-iphone
It is possible that Xcode starts downloading it via nsurlsessiod so you can block it either
by using a firewall
https://apple.stackexchange.com/questions/393689/how-to-stop-catalina-from-contacting-apple-servers-when-executing-programs/393698#393698
Or by renaming the binary as explained at the link below. (I haven't tried it)
Xcode simulator constantly download something
Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData manually. Remove all its contents because there's a bug where Xcode will run an old version of your project that's in there somewhere
By following this steps you can do....
For user who are not able to find library/developer path.
open Xcode( i am using Xcode 13) -> file -> workspace setting -> there will be a path at center of modal -> click on arrow button next to path -> on clicking it will open up the folder.

How to move saved location of xcode files without messing up references

Since this is my first app I naively have all my xcode files (swift code, assets, and storyboard) all saved to my desktop. Is there someway I can move it (or duplicated backups) to another location like github or google drive without messing up all the references?
There is nothing wrong with saving stuff to the desktop. But what should be on the desktop should be a project folder, with an organization like this:
Desktop
MyProject (this is the project folder)
MyProject.xcodeproj (this is the project)
MyProject (this is a group folder)
[everything else]
That is the situation that Xcode will create for you by default. And if that is indeed the situation, then all is well. You can just drag the project folder elsewhere and nothing will break. You can put it under git control and upload it to github and nothing will break. You can clone from github to another computer and nothing will break. This is how people operate every day, all the time.
(Don't put it on google drive, that's the kiss of death.)
If that is not the situation, then the situation is so bad that you would be better off starting all over again. It is possible to move stuff into the project folder, but then you have to alert the project to what you've done, and that can be an error-prone task for a beginner.

Non-default storyboard not being copied after compile in XCode5

I have a project that uses several storyboards. In starting to internationalize/localize it, I've begun differentiating the storyboards. However, I've found that non-default (i.e. not MainStoryboard.storyboard) files are compiled but not copied into the bundle. For instance, the following files are present:
./DerivedData/.../fr-CA.lproj/MainStoryboard.storyboardc
./Library/Application Support/iPhone Simulator/.../fr-CA.lproj/MainStoryboard.storyboardc
./DerivedData/.../fr-CA.lproj/Foo.storyboardc
BUT, this one is not:
./Library/Application Support/iPhone Simulator/.../fr-CA.lproj/Foo.storyboardc
Suggestions/ideas are welcome. I'm at the point where I'm considering writing a script to just copy over these resources manually, assuming that will even work.
I found a solution, though "work around" is probably a better description:
Remove the storyboard (or XIB) from any Target Membership;
Do a clean build (and clean the build folder as well);
Close XCode;
Delete the app from the device/simulator;
Delete the contents of XCode's DerivedData directory (see Preferences);
Rebuild and launch the app, navigating to the area where the storyboard/XIB is expected (this should cause a crash);
Re-add the storyboard/XIB under Target Membership;
Rebuild and launch.
Step #6 is the most important. If the app doesn't crash it means that you have a cached copy of the file somewhere, which is no good. I have no idea exactly why this fixes things, though I wish I did.
After this, things work swimmingly (using Base Internationalization or not).

Multiple errors ocurred while copying files - but, can I see what they are?

There were around 200 files I had to delete in my Xcode project (and yeah, they were deleted properly), and now I have to copy 200+ files are supposedly replace the ones I just deleted.
I keep getting "Multiple errors occurred while copying files". The Xcode window doesn't show the newly-added files, but if I explore the project folder using the Finder, I can see that the files were indeed added - well, there most likely was a certain file that could not be copied and thus caused the error. Problem is, I have no idea which one nor why.
Now then, is it possible to get Xcode to tell me what the problem is rather than telling me there is one?
Edit: Okay, I did discover that some of the new files shared the same name as some files that were not listed in Xcode, which explains the error. However, I am still interested in knowing whether there is a way to know that the "Multiple errors" actually are whenever Xcode says t his.
When Xcode finds a duplicate file, it generates this error, and then it fails to add references for the files that it did manage to copy.
Rather than deleting files from the finder and starting over, you can do this:
Open the Finder for your project, where your source files are located
Command-click the ones for which your references are missing (and if you click others, it won't really matter)
Drag them into Xcode. When the confirmation dialog comes up, unset the "Copy items into destination group's folder (if needed)" checkbox. This will tell Xcode to make references only.
I deleted the files from finder and then added again the files via Xcode, that worked for me.
This error sometimes occurs when the code is not merged properly. The missing files will not be available in Xcode but once you open the finder containing this project, you will be able to spot the missing file.
The simplest way to add these missing files back to the project is:
1) In your Xcode, navigate to Build Phases Tab.
2) Under Compile Sources, tap on '+' to add back the missing file.
Sometimes the missing files will be greyed out in the build phases, just tap on '-' and add them back.
For me this is worked. I tried to add files which are already in my bundle. So make sure you are not adding files which are already added. I hope it helps someone.

How do I remove the default localizations from a Phonegap/Cordova project?

I've just had a Phonegap/Cordova iPhone app approved for the app store but noticed it claims to be available in a bunch of other languages including Northern Sami. I've found the list of languages in xcode under localizations and tried deleting them but if I restart xcode they re-appear.
I've also tried deleting lproj folders in the resources folders but that doesn't help either.
I'm at a loss to what to do next so any help would be much appreciated.
Here is a step by step guide of how I do it. (Order matters)
First go to the Resources folder in the Phonegap project. Within this folder there are several folders ending in *.lproj. Delete all of them except for en.lproj (Assuming your language is english).
Even though you deleted those files from your hard drive they're still linked in Xcode. Open up your *.xcodeproj and delete all of the folders from the side bar once again.
Normally this should suffice, but if you're still having problems go to the app's project tab (rather than target) and under info you can find and remove all the current localisations.
Oh and btw if this still isn't enough you can look at the details of your app's binary in iTunesConnect to verify if it worked before releasing the app.

Resources