I am working on a project that was created before Xcode 9, and the folder structure doesn't match the groups structure.
There are groups that are not associated to folders, and other that are. Some files are outside folders while they are in groups.
You can create a new group, with its own folder, directly in Xcode, but it's not at all obvious. Instead of choosing 'New Group', choose 'Add Files to “<Project>”'. Then, in the file picker dialog, click the New Folder button or press Command-Shift-N and type the name of the new folder/group.
Xcode offers several ways to add existing files and folders to your project: Drag the files from the Finder into the Project navigator. Click the Add button (+) in the Project navigator's filter bar, and choose Add Files to “projectName”. Choose File > Add Files to “projectName”.
After unsuccessfully trying Synx, I ended up understanding everything I needed to do to accomplish this (manually), so here's how one should proceed:
FYI, if you a group was already linked to a folder that is now incorrect, the folder icon might become a little cross, to remove that reference. If your group appears in red, you can click that and override the link towards the new folder.
Inside that group that you have just linked to its folder, not all files will automatically find their reference and become black; some will stay red. You could right-click each of these files and link them to their file using the File inspector, but there is a quicker way: select all the files inside a group, and go in the File inspector to link them. In the Finder window that will appear, select their folder and click OK. All of the files in that folder/group will then be correctly linked.
If there are individual files that are still red after fixing your folders, you can then link them to their file in the folder using the File Inspector, until all of them are black.
IMPORTANT: if you see a "?" or "!" sign next to a file name, it's ok. You just need to "git add" this file using the terminal ("git add -A" to add all at once), and it will then appear as "Renamed" (you will see "R" sign in Xcode). Renamed is what you want for all your files, you should not have "?" or "!" left.
Tip:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With