I have added my own build rule to Xcode, to compile a custom type of file. Let's call it .foo.
I need to be able to specify that file A should be compiled before file B (since B depends on A). I have already written the logic to calculate these dependencies in a Run Script build phase, which runs before the Compile Sources phase. I can guarantee that there are no cycles (or if there are, it's ok for the build to fail).
How do I tell Xcode about these file dependencies for .foo files, so that it compiles them in the right order?
Things I've tried:
- outputting a "discovered dependency file" for each
.foofile, into the derived sources directory, then adding it to my.foobuild rule. I believe the syntax of the file should beB.foo: A.foo(indicating that A must be compiled before B). I've tried it with both just filenames and with full paths. Xcode is finding the file, but does not seem to act upon it. - Outputting an
xcfilelistfor each.foofile. This one I can't get to work -- in the "Input file lists" section of my.foorule, Xcode doesn't seem to want to expand any build variables that refer to the current file. For example, if I add an item$(DERIVED_SOURCES_DIR)/$(INPUT_FILE_NAME).depsto the "input file lists" section, Xcode will expand "DERIVED_SOURCES_DIR" but will not expand "INPUT_FILE_NAME". From this I conclude that you can't have a per-file input file list, you can only have one single list for the whole.foobuild rule. Is this assumption correct?
What am I missing? There must be a way of telling Xcode about file dependencies, right?
Specific questions about .d files:
In a "discovered dependency file" (i.e. a .d file), as I understand it the syntax is <target>: <dep> <dep> <dep>.
- Should the
targetbe a full path or just a filename? - Should the
targetrefer to my.foofile (the thing I'm building, inside my source folder), or my.foo.outfile (the thing it builds, inside my derived files folder)? - The deps, i.e. the things that need to be built before the target: same question regarding full path, and do they refer to the source or the built output?
I have looked in Xcode's build timeline, and all my .foo files are building in parallel, it doesn't seem to be paying attention to anything I put in the .d files. So I suspect I'm getting the syntax wrong somehow.