How Xcode decides which build phase to add a file into?

When you add a new file to a target, Xcode somehow decides whether to add the thing to “Compile Sources” or to “Copy Bundle Resources” build phase.


Anyone knows what this decision is based on?


Namely, anyone knows how to affect it with a new UTI?


I have added (through a separate application which exports it) a new UTI for Groovy sources; it works very well — Xcode sees the UTI all right, correctly assigns it to newly added *.groovy files, shows the proper icon etc. Nevertheless, there's one rather inconvenient problem: when a new Groovy source is added to a target, it goes to its “Copy Bundle Resources”.


I have made sure my Groovy source UTI conforms to the standard “public.source-code” UTI, in a hope Xcode would detect that and put automatically those to “Compile Sources”; alas, in vain.


What do I need to do to ensure that Xcode automatically puts sources of a given UTI to the “Compile Sources” build phase of selected target(s)?


At the moment, I am working with version 9.4.1 (9F2000).


Thanks a lot,

OC

Replies

Bumping up. Nobody knows? Still would appreciate a solution...

I believe you would have to add a rule in the Build Rules pane of the project editor, but I'm not sure it would add the file to the Compile Sources Phase, unless you tell it use one of the compilers it knows about. But you could experiment with a custom rule to see what happens.

Thanks! Alas, at least in Xcode 10.1 (10B61) which I have at the moment at hand, it does not seem to help, or I do something wrong. I have tried even a rule to compile *.groovy files by clang (would not work build-time of course, just to test), and still all groovy files are automatically added to the Copy Bundle Resource phase 😟

I'm sorry, I don't have any better ideas. A bug report or TSI would probably be the next step.