We’re looking for the ability to add arbitrary metadata to targets that can be ingested into other systems. My first through was to do so through tuist dump
via a new codable metadata
property on ProjectDescription.Target
. I have a draft PR up here with the the implementation (minus any tests at all) and am looking for thoughts and feedback.
We definitively need this. There was some initial work to change the Target
in XcodeGraph
too (PR) but we have a discussion still open around how generic we want the API to be.
I personally lean on having having a list of tags that are representable by strings, and some extensions over that model to have weak conventions over common needs. For example:
let target = Target(
name: "MyTarget",
tags: [
"something",
.team("infra") // Translates to "team:infra"
]
)
API design is hard .
Good to know about the other efforts. I think it might be valuable to differentiate between attaching arbitrary data (as json basically) that doesn’t strongly interact with the tuist core system and then additionally the concept of string tags that are outlined the PR that allow us to programmatically adjust behavior based on that data.
The thought here is that it would enable teams to attach any arbitrary json that would safely round trip through tuist dump
and allow them to keep the tuist graph as the source of truth even when tuist
it self doesn’t have first class support for every arbitrary system in the world.
I hacked on some things a bit more and will hopefully be able to push to the PR later this evening or tomorrow.
I’d lean on making one the subset of the other for simplicity. If we expose an API to set metadata to a target, which we can then serialize and include in the output of the graph, Tuist can add a semantic layer on top of it. Kind of like the SettingsDictionary
object. It’s a key-value data structure where you can set any build setting that you wish, and then we provide some convenient functions on top of.
I think that achieves a good balance between “use this for whatever you want” and “you can use it for some Tuist-specific features too”. Otherwise we might end up with something like this:
let target = Target(
metadata: ["foo": "bar"] // or any other serializable structure
teams: ["core"] // Isn't this also metadata?
)
Yea, im kind of thinking that Tuist can provide a type that exposes first class Tuist metadata (tags) and allow for the inclusion of an arbitrary object that would enable “untyped” (or customer typed?) objects to be included in the graph representation but tuist would be unaware of meaning other than “black box of json”.
protocol AdditionalMetadata {
var metadataDictionary: [String: MetadataValue]
}
struct MyCustomObject: AdditionalMetadata { ... }
let metadata = TargetMetadata(
tags: ["foo", "bar"]
additionalMetadata: MyCustomObject()
)
Updated the PR with a sample implementation that actually works and includes a sample usage and output.