Sourcery
Sourcery copied to clipboard
[QUESTION] Is possible to get the module where the type is defined?
I was not able to find documentation for this, is it possible to get the name of the module where the type was defined? That way I could do something like this:
Original type on ModuleA:
import Whatever
struct CoolStruct {
// Stuff
}
Generated code on ModuleB:
import ModuleA
let coolStruct = CoolStruct()
// Do something with CoolStruct
yes if you use pbxproj / target integration, each type has module optional field.
Not if you just use source paths since how could Sourcery know in that case
Hum... I think I see the problem... I use trough command line because the source code is on Package and de generated code will be used on the Package too. Do you know of any way I could do that? I though about #fileID, but it is replaced only after compilation right?
If there is no target information provided Sourcery can't really know what module it's scanning, there is path
on Type
but that wouldn't really help.
We'll be adding SPM support as one of the config options in near future
There is path
on Type
? It doesn't appear on the reference. It could be enough since SPM follows a pretty rigid structure, but I guess Stencil doesn't allow for the level of string manipulation that I would required right?
Basically extracting only the content between Source/ and the next /, and transforming Module-A
into Module_A
. From what I researched Stencil does not support RegExes right?
If stencil supported the regex then it would be so cool! Btw do have have a workaround now for SPM packages? For modules integrated with pbxproj/target works fine. ❓
we'd either need to add scanning of Package.swift
or we could add support for injecting module name for a given source path
yes if you use pbxproj / target integration, each type has module optional field.
Not if you just use source paths since how could Sourcery know in that case
Is it possible to get the target within the module for the type?
@rus64 confused what you mean, module is a target isn't it?