21

Xcode run into compilation error while running the code.

Unfortunatetly I was not able to find a solution online.

These steps that I have commenced:

=> git merge branch-name => can't find the files => git checkout branch-name file-name => files were physically found => xcode can't see it

??? enter image description here

1
  • Try making sure that the targets have been set (selected) to your scheme.
    – jakenberg
    Jul 12, 2013 at 8:43

4 Answers 4

38

You have to add them to your project at File -> Add Files To "Your Project"

btw: Your project folder in Xcode does not necessarily reflect your actual folder structure you see in finder.


Edit:

if you want it to be like that (Xcode folders are the same as the existing folders in your harddrive) I found a nice tool which does that for you: https://github.com/venmo/synx

also, when creating new folders/groups in Xcode, you have to use the New Group with Folder option to also create a folder for that group on your harddrive.

4
  • 1
    Synx worked well for me, it can also delete unused files which is what I was looking for. For deleting unused files use --prune flag Dec 2, 2019 at 17:22
  • Let's try synx . I despise a tool that does not work with direct file system manipulation. May 15, 2020 at 3:49
  • wait a moment looks like synx is doing the opposite: instead of inserting the files I copied via command line (but not via "add groups" nonsense) it is deleting those files since .. well.. they were not added as groups. While I can see the usefulness of this for being sync'ed is there a tool that will not force me to drag and drop stuff like a kindergartener? May 15, 2020 at 3:52
  • Incredible. Screw you too, Apple.
    – Chris Neve
    May 4, 2021 at 20:01
4

Tested in xcode 11

You have to add them to your project by pressing right-click on the app folder Add files to "app"... select all the missing and NEEDED files, click on create groups option and press finish.

Adding missing files to xcode

1
  • 1
    Wow xcode really hates people that are keyboardists or command line driven. I can't copy stuff by terminal commands but have to go point and click and drag and drop . May 15, 2020 at 5:28
1

Maybe when you add those files to the project you did not linked them to your Target.

When you add file to your project make sure it's link to your target.

enter image description here

check the following:

  1. select the file (.m file) that causing this error.
  2. select the file inspector
  3. make sure that your Target is selected in the check box.

enter image description here

  • NOTE: you can't link .h files to the target, only .m and .swift
0

Looks like whenever I added my files to git, I never actually added MyProject.xcodeproj/project.pbxproj file. This file has all the references for new files. Make sure you add that file to your git.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.