0

I use actual folders for my Xcode projects containing my .swift files. I dragged the folder into Xcode but it appears that my swift classes are not being built. I went to my target, went to Build Phase, went to Compile Source and added the missing folder to the references to be built.

My swift files are still not being built.

Which flag could I add to the folder (in Compile Source) for force it to compile every .swift files within it (including the ones in subfolders) ?

I couldn't find any info about it so far, any ideas ?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
vbuzze
  • 930
  • 1
  • 11
  • 25
  • 3
    Are the files added to target? Xcode doesn't compile directories, it compiles files. – Sulthan Jan 23 '19 at 12:44
  • Oh I see now that the files in questions don't have a Target Membership tab on the right, how can I add that if my files are already in my Xcode file tree ? – vbuzze Jan 23 '19 at 12:48
  • 1
    Open the right side panel, click on every file and set the membership. Or remove all file references and add them again, selecting the target membership. – Sulthan Jan 23 '19 at 12:49
  • I don't have the _Target Membership_ section for those files in the right side panel though – vbuzze Jan 23 '19 at 12:51
  • 1
    Did you create a folder reference or a group? Don't create folder references, remove them and add the directory again, creating a group. – Sulthan Jan 23 '19 at 12:53
  • I used a folder reference, thanks I'll try importing as a group – vbuzze Jan 23 '19 at 12:54
  • 1
    @Sulthan thanks it worked by adding everything as _groups_ – vbuzze Jan 23 '19 at 13:01

1 Answers1

1

TLDR Use Groups, not Folder References.

Folder References in Xcode are made mainly for resources. When you create a folder reference, Xcode won't care about the contents. They are helpful when copying resources that should keep their directory structure.

To organize source code files, you need Groups. Groups are logical project folders and most of the time they are backed up by a file system folder anyway.

See also Difference between folder and group in Xcode?

Sulthan
  • 128,090
  • 22
  • 218
  • 270