XCode project missing files on other Mac - xcode

I have multiple Xcode Projects in my Dropbox so I can use them on my iMac and MacBook. But when I open the projects on another Mac most of the imported Images, Videos etc... are red (missing). the files are all in the Project Root Folder. What can I do?

This error is because when you added the files (images, documents, etc) you did not tick copy if needed option.
That means if you deag/drop items from your desktop to the project, Xcode will reference the documents from your desktop. When opening the project on another computer, the Xcode is not finding your documents in the desktop of the other computer, thus the error.
Solution:
1- Delete all the red marked items (take note of them)
2- move them again to the project and make sure to check copy items if needed checkbox.
3- re upload the project to wherever you need and it will run.
Happy coding!

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 transfer published resources from CocoStudio to Xcode?

using CocoStudio 2.0.6 and Xcode 6.1.1 on MAC inside VMware. After publishing in CocoStudio I open Xcode and "Add Files to myProject" with the "Copy items if needed" option checked. Then I have the folder myProject/res created by CocoStudio inside the myProject/Resources folder used by Xcode. Using CSLoader in HelloWorldScene.cpp works fine and I see the scene in the simulator. Runs ok also in Eclipse on Android emulator.
If I go back to CocoStudio and make changes like adding a sprite to the scene then I need to repeat the whole process of publishing, delete them Resources/res folder in Xcode and add it again. It is faster to delete the whole folder instead of adding new files into it and delete the ones not used any more.
My question is: am I doing it the right way or is it there a better way for Xcode to automatically see modifications to the resources made by CocoStudio?
Like when I use Eclipse and build the project, the resources in the myProject/proj.android/assets folder are automatically updated with the resources from the myProject/Resources folder.
Thank you.
You can make a resources folder in iOS app a symbolic link to the main Resources folder.
Remove the proj.ios_mac/Resources folder. Then go to your main app folder and execute:
ln -s ../Resources proj.ios_mac/Resources

How do you move an Xcode 4.2 project file to another folder?

Not crazy about the way Xcode 4.2 has laid out the files on disk. It creates a project file, then a single subfolder next to it that has all the code. We want the project file to be in that same folder, then the workspace file (if any) to be the folder's sibling. Makes for more portable layouts.
However, I can't STAND the lack of Save-as in Lion, and now, apparently Xcode 4.2 as well. At least with TextEdit I just grabbed the version from SL and it works. No such luck with Xcode as as you know, it's a completely different animal than Xcode 3.x.
So... how does one move/rename the project file relative to the source code?
Here is how you do it (I'm using in Xcode 4.3):
First, move your project file
1. Start out by closing the Xcode project
1. Move ProjectName.xcodeproj into the folder with all your code
1. Open the XCode project by clicking ProjectName.xcodeproj
Second, re-map your files
1. You do not need to remap the files one by one, you only need to map the groups
1. Open the "File Inspector" with ⌥⌘1 or View->Utilities->Show File Inspector
1. Click each group, then click the square icon (see screenshot below) and choose the folder your project file is in.
Icon to click:
"None" will show up when you choose the same folder your .xcodeproj file is in.
Conclusion:
I have a large project which contains ~650 files, but only 12 groups, so it takes just a few minutes to re-map everything.
Note:
Sometimes when mapping the files it doesn't recognize a folder change if the name is the same (ie. two folders with the same name). You may have to pick any other folder temporarily, then choose the actual project folder and the None indicator will appear.

want to use Xcode 4 for everything, how to add folder in project navigator?

I'd like to move my web dev editing to Xcode 4 (currently using textmate). I have a couple of simple questions that are clearly a lack of experience on my end.
In Xcode's Project Navigator, how do I add a folder to the shown directory tree? Currently, I add via terminal and do File -> Add Files
Is there any way to tell Xcode to see the file system as the file system and not as references?
a less likely thing:
Is there any way to bring up a console within the context of a folder in project navigator (would like to be able to run grep again small portion or something)?
thx
I can answer the first question. Adding a folder of files to a project is the same as adding individual files. Choose File > Add Files in Xcode. When you add a folder of files to a project, you should see something like the following screenshot:
Create groups if you need to access the files in Xcode, such as adding a folder of source code files. Create folder references if you don't need to access the files in Xcode, such as adding a folder of audio files.
You can also add folders to the project navigator by selecting a file or folder in the project navigator, right-clicking, and choosing New Group.
As far as I know, Xcode won't mirror the filesystem as an Xcode tree (anyone correct me id I'm wrong). Wanting to have an identical structure is quite some work. I use to first place the files hierarchically in the file-system, then I mimic the same structure in Xcode.
This requires some attention since Xcode 4.1 not always writes new classes to the place you told him to - they may prefer to land in the highest level of the Xcode project.
I had similar thoughts and started a thread, might be helpful for further reading
Your second question: sorry, can't help you there.

Moving Files into a Real Folder in Xcode

When I started my project I was happy to use Groups in Xcode rather than literal folders: Since I'm using the browser in Xcode to access everything, stuff was nicely organized and I was happy.
However, now that the project is about to be shared for version control, the project folder itself is a horror show for those trying to scan it via a terminal, about 300 files, over half of which are graphics.
I'm trying to now reorganize things, creating real folders and importing them into Xcode. Unfortunately Xcode doesn't let me work with them the way it does with groups. For example, if I right-click on an actual added folder (blue, not yellow) and choose to add existing files, it doesn't actually put them in that folder, it puts them in its root.
Similarly, I can't move a file from a faux-folder (a group) into a real folder: Xcode doesn't consider the real folders to be valid places to move stuff to.
What am I missing? How can I convince Xcode to let me use the folders the way I use groups? There's an answer here to a somewhat similar question, but it doesn't actually solve my problem since I'm working with existing files.
A modern (and dead simple!) approach for 2017 (Xcode 6, 7, 8, and sometimes 9, since it does it automagically some of the time):
If you're moving a bunch of files into a new folder and are keeping the child hierarchy, it's actually a lot easier than moving each file individually:
Create new groups in the Xcode folder tree and organize your files into them however you like.
Create a matching physical folder tree in Finder and organize your physical files into them to match what you did in step 1.
All the references in Xcode should now be red (that's OK!).
From the Identity and Type manager, select the Group in Xcode that you want to relocate, then click the folder icon from the info pane:
In the Finder selection dialog, locate the equivalent new folder you created for this group in step 2. All the files inside that group will now be automagically rediscovered!
Isn't that nice? At most you'll have to repeat these 5 steps once for each new group you've created (which beats relocating each file individually!)
Bonus Points!
Say you accidentally screwed up the move and now a bunch of your files are red and can't be found: select multiple files that are broken, and using the same folder icon in the screenshot from step 4, find the correct folder that contains these files and they'll automatically resolve the missing paths.
FURTHER EDITED JUNE 2017: Xcode 9 does this automatically, no special effort required. This answer and Brandon's only apply to Xcode 8 and earlier.
EDITED DECEMBER 2016: Brandon's answer below is a better solution now. Back when this answer was created in 2010 this was the only option I could find. I now suggest Brandon's answer, below.
It turns out that moving files into real folders is certainly possible, though not as simple as it should be.
I got the basic information from a question here, Xcode organising files and folders (core data model objects - iPhone), but learned important things along the way.
##The Process
Moving the files is a two-step process with multiple sub-steps:
Tell Xcode where you want the files to be:
Right/Control-click on the file or file group that you'd like to move and choose Get Info from the contextual menu that appears. The Group Info or File Info window appears.
Click the Choose button on the far right side of the window in the Path area. A dialog box appears.
Navigate to the folder you want the files to be moved to. Create a New Folder if needed. Click the Choose button in the bottom-right corner of the dialog box, then close the Group Info/File Info window.
The names of the file/files in the group will turn red to indicate that Xcode can't find them in the place you specified.
Move the actual files
In the Finder (or Git) move the files you selected in step 1 into the actual folders you want them in.
Switch back to Xcode. The files/groups should all have turned black again. If any are still red then you've missed moving something to the right folder.
##Tips
I learned a couple of important things while adjusting the ~300 files in this project:
Some files refuse to move this way; that is, when you navigate to the new destination the Choose button is disabled, as is the New Folder button. The solution, though I don't know why it makes a difference, is to first use Xcode to put those files in a Group (right/control-click the files and choose Group, and give the group a name) and then move the group to the new location. After you're actually moved the files in the Finder you can remove them from the group (by dragging them into the new parent group/folder and deleting the group).
Stop and build every few minutes, after completing step 2 for a number of files. The build will tell you if you've screwed anything up so far, making it easier to go back and fix it before you've done too much damage.
If the files won't move to where you want them to — I had a devil of a time moving some files that had been created early-on in the Classes folder — you can simply drag them out of their old place in the finder to someplace handy like the desktop, delete references to them in Xcode, and then re-import them via the right/control-click Add Existing Files option.
If in the past you've used Xcode to delete references to files without also moving them to the trash in this project, you'll find files that don't have to be moved but at just sitting there. Be careful that you don't do what I did, confusing the names of a current group of files I was moving and the older, no-longer-linked files, insisting that Xcode import them because you thought it was being dense.
In Xcode 5 or Xcode 6:
Create the folders that map to your Groups in Finder
Move the files into those folders in Finder
Select each file that is red in the Xcode sidebar on the left
Click the button "Show/Hide Utilities" to reveal the right sidebar (see figure)
In "Identity and Type", click the tiny button and select the file location (see figure)
Cheers.
I've found the most reliable way to work around XCode's appalling design here is to organize ALL your files in Finder, for two reasons:
Finder doesn't make "mistakes", unlike XCode's GUI
Once things are organized in Finder, you can drag/drop entire Finder folders into XCode, and ... it does exactly what you wanted, with no effort
Even when moving existing XCode files around, it is quicker to do this:
Select the files in Finder
Create a folder in Finder for them
Drag/drop them to the folder (automatically Moves them)
Drag/drop the Finder folder into Xcode (automatically: creates the Xcode folder, adds every file in the Finder folder)
cmd-select every "red" file you now see in Xcode (because you moved them) and hit the delete key
NB: I never use the "create dragged folders with sub-groups" option, because in XCode 3 that was often hopelessly buggy and could corrupt projects. Apple clearly (IMHO) does NOT use this feature internally, otherwise it would never have been allowed to be so buggy; if Apple doesn't use a thing, it's generally not safe to use it either - they aren't good at testing :)
There is a simple to setup and use Command Line Tool - "synx"
available in github that do exactly what is needed here.
It reorganizes Xcode project folder in finder to match Xcode groups in project.
You can find it here:
https://github.com/venmo/synx
UPDATE:
XCode 9 supports this feature by default. So, no need to use other tools anymore!
Xcode 9
It seems Xcode 9 now supports it by default. When you move files from a group to another, the file will also be moved from the old folder to the new folder. This was announced in WWDC 2017.
I used the following tool to achieve it.Organize Folders in Groups Xcode
--no-default-exclusions
I'm usually move files to the directory directly in the Finder, then fix the files with red-color names in XCode in their "Get Info" dialog: click the "Choose..." button and select file's new locatoin. That's the first response when I want to move files in XCode, and it works.
As of Xcode 4.5 when you drag in a folder structure it is automatically turned into nested groups in the Project Navigator. Then, if you look on disk (e.g. right click and choose Show in Finder), the folder structure has been retained.
I found trying to fix things from an older project was just a pain. It turned out much easier to just delete these files and drag them in again.
To move a folder in xcode 4.5 I just...
Delete the files/groups from xcode and select "Remove Reference".
Go into finder and move the folder/files as needed.
Once done I go back into Xcode and choose File->Add Files to {ProjectName}.
Make sure "Copy Items into Destination Group's folder (If needed)" is checked
Make sure "Create Group for any added folder" is checked
Make sure "Add to Target" is checked for your project
Easiest technique for XCode 8....
Assuming you have files A,B,C in a logical group, but want them moved into a folder on your hard drive.
Create a destination folder via Finder
Add the folder in XCode (File -> Add Files ) using the Options pane to select a Folder Reference (not a group)
Drag files A,B,C from the (old) group to the (new) folder reference in the project navigator. XCode will move the files into the folder, both in the the project, and on disk.
Done.
On XCode 11 (I just validated this on XCode 11.6), you can select the files you would like to move under the project navigator, right click on the selected files, and click "New Group From Selection". This will create a folder on disk and move the files appropriately.

Resources