Closed markst closed 5 months ago
I wonder if there is a better solution?
It would be much better to be able to only perform plugin .when(configuration: .debug)
I think we can wrap only the part with the call. This will save work in places where #if DEBUG
is not used.
public static var models: [PreviewModel] = {
var views: [PreviewModel] = []
#if DEBUG
{% for type in types.types where type.implements.PrefireProvider or type.based.PrefireProvider or type|annotated:"PrefireProvider" %}
views.append(contentsOf: createModel(for: {{ type.name }}.self, name: "{{ type.name | replace:"_Previews","" | replace:"_Preview","" }}"))
{% endfor %}
#endif
return views.sorted(by: { $0.name > $1.name || $0.story ?? "" > $1.story ?? "" })
}()
Not sure whether we can configure Sourcery to identify if a PrefireProvider
is within a DEBUG compiler directive.
I suppose we may not want to wrap in DEBUG since some people may wish to create a distribution build with Playbook?
We could introduce a new compiler flag such as NO_PLAYBOOK
which the consumer target could pass?
swiftSettings: [
.define("NO_PLAYBOOK", .when(configuration: .release)),
]
@markst Very cool and simple solution!
I suppose we may not want to wrap in DEBUG since some people may wish to create a distribution build with Playbook?
I think so, it is better to leave this feature configurable.
@markst Can you please add information about this flag in Readme.md?
In our case we have our
PreviewProvider
's wrapped in compiler directives. This is due toMediaMock
being also wrapped in compiler directives and so forth.