Bridgecraft icon indicating copy to clipboard operation
Bridgecraft copied to clipboard

Find out how the generated interface is actually useful

Open lvsti opened this issue 6 years ago • 11 comments

Sudden realization: the generated interface is not valid swift because:

  • class definitions don't have method bodies
  • protocol definitions are syntactically incorrect (because of the public modifier)
  • global let constants don't have a value
  • global functions don't have a body

At least enums are fine...

lvsti avatar Jan 21 '18 17:01 lvsti

OK actually Sourcery is laid back enough to not care about this 😎 However, it is still a problem to process the generated interface together with the files of a given project target, the configuration only allows one or the other.

lvsti avatar Jan 21 '18 17:01 lvsti

In my case, I don't had the output of Bridgecraft to the project, I only use the output of Bridgecraft run Sourcery and it's working.

4brunu avatar Jan 22 '18 13:01 4brunu

Good for you, but if you have a mixed codebase then the two must be processed at the same time for Sourcery to be able to resolve crossreferenced types properly. Otherwise they just appear as placeholders without real type information.

lvsti avatar Jan 22 '18 20:01 lvsti

Hum, I see... Maybe this is not the ideal solution, but I think you can try to add multiple sources to Sourcery, like the output of Bridgecraft and the directories of your directory (if the directories are scanned recursively this would help, but I'm not sure if this is the case for Sourcery.)

4brunu avatar Jan 22 '18 22:01 4brunu

Project patching is now supported in 0.1.0, the only issue yet to be resolved is that huge generated interfaces make Sourcery eat up all the resources and stall indefinitely (see https://github.com/krzysztofzablocki/Sourcery/issues/420). A workaround could be splitting the generated file into smaller pieces but that's not a trivial task due to type interdependencies.

lvsti avatar Feb 02 '18 16:02 lvsti

Any news about this? Should we ping sourcery about the related issue?

4brunu avatar Mar 06 '18 20:03 4brunu

I have a pending PR in SourceKitten (https://github.com/jpsim/SourceKitten/pull/495) that is one step to the right direction, although it is not sufficient. I haven't had time lately to further optimize Sourcery.

lvsti avatar Mar 06 '18 21:03 lvsti

Oh, I didn't know that, thanks for sharing 👍

4brunu avatar Mar 06 '18 21:03 4brunu

Just curious, now that Sourcery 0.12.0 and SourceKitten 0.20.0 are out, with some performance improvements you made, is Bridgecraft and Sourcery working in your project? 🙂

4brunu avatar Apr 13 '18 08:04 4brunu

Yeah it would be interesting to try, let's see if I can find some time in the weekend

lvsti avatar Apr 13 '18 20:04 lvsti

Well, when parsing a generated header of 500KB, Sourcery still inflates to ~15 GB but at least it now exits within a reasonable time. So this may make it feasible in my project as well.

lvsti avatar Apr 14 '18 16:04 lvsti