Git Pull doesn't work correctly

Hello Y'all, a friend of mine and I are working on a project together and are using git source control to collaborate. When I commit (and push) new files or changes to pre-existing files, everything works fine and my friend can pull those without a problem. But when he adds new files and then commits and pushes them, my Xcode doesn't recognise that new files have been added after I pull them. They show up in Finder in the right place and directory, but they do not show up in Xcode. Changes he makes to pre-existing files show up fine, its only when new files are added, that those changes do not show up. I don't know if I have something incorrectly configured or if its on his end, but even deleting the project off my laptop and cloning it again from GitHub as a new project results in the exact same problem: The files are all on my drive, just not in my Xcode Project Navigator. Cleaning the build folder also does nothing. Is there a file that keeps track of all files that belong in the project that my friend is not committing? That's about the best guess I've got right now...

He is on an intel Mac and I am on an m1 Mac, if that's important.

Thanks in advance for any help!

Answered by darkpaw in 744737022

When you add a file into an Xcode project the file is tracked by the project file itself, i.e. myProject.cxodeproj (and .xcworkspace if you're using that structure).

If your friend is adding files to their local project and committing the changes, you should see those new files if your friend is also committing the changed .xcodeproj files, and you're pulling those, too.

An easy thing to do is to locate the .xcodeproj file in Finder, right-click it and choose "Show Package Contents". Drag the files into a text editor app, then search them for the names of the new files that aren't appearing within Xcode. It's likely you won't find them, so they haven't been added to the project (or they have, but you haven't go the updated project file). (You can also just drag the .xcodeproj file into BBEdit, and it'll list those files for you.)

Confirm with your friend that he's committing all the files.

Accepted Answer

When you add a file into an Xcode project the file is tracked by the project file itself, i.e. myProject.cxodeproj (and .xcworkspace if you're using that structure).

If your friend is adding files to their local project and committing the changes, you should see those new files if your friend is also committing the changed .xcodeproj files, and you're pulling those, too.

An easy thing to do is to locate the .xcodeproj file in Finder, right-click it and choose "Show Package Contents". Drag the files into a text editor app, then search them for the names of the new files that aren't appearing within Xcode. It's likely you won't find them, so they haven't been added to the project (or they have, but you haven't go the updated project file). (You can also just drag the .xcodeproj file into BBEdit, and it'll list those files for you.)

Confirm with your friend that he's committing all the files.

When you add new files to your project in Windows or Linux, commit them and pull these changes on macOS, you'll see the files in Finder but not in Xcode. This is because Xcode requires manually adding these files to the project structure. To add them:

  1. In Xcode, right-click on the target folder in the project navigator
  2. Select "Add Files to [Project Name]..."
  3. In the file picker dialog:
    • Select the new files
    • Ensure "Copy items if needed" is unchecked (files are already in project directory)
    • Check "Create groups" to maintain folder structure
    • Make sure your app target is selected under "Add to targets"
  4. Click "Add"
Git Pull doesn't work correctly
 
 
Q