Ir al contenido

Architecture contract (ARCH9204)

Esta página aún no está disponible en tu idioma.

Key swift.architecture.contract · Severity error · Category architecture

Flags a type reference against the layer direction, a feature’s boundary or the project’s own architecture rules: code under Feature/, Features/ or Slices/ using another feature’s behaviour (a class, actor or struct with function bodies, a SwiftUI view - its model structs, enums and protocols are allowed); data, network, service or domain code using the presentation layer (Views, Scenes, Screens, UI, Presentation); the domain using the data layer in a module whose data layer already uses its domain (where the domain calls the data layer, that is the design); or any dependency a rule in Project settings > Scanning forbids. Swift files of one target see each other without imports, so a reference is a type name resolved to the file that declares it; a reference between two targets is declared in the build and is checked only against the presentation rule and the project’s rules. Read from folder names, not type names.

App/Network/Response/ProductResponse.swift
struct ProductResponse: Decodable {
let type: String
var uiType: HologramType { HologramType(rawValue: type) ?? .unknown } // HologramType lives in App/Scenes/Hologram
}
App/Network/Response/ProductResponse.swift
struct ProductResponse: Decodable {
let type: String
}
// App/Scenes/Hologram/HologramType+Response.swift - the presentation layer maps the response
extension HologramType { init(_ response: ProductResponse) { self = HologramType(rawValue: response.type) ?? .unknown } }