Browse Questions
  • OSLog is Apple's structured logging framework.
  • FlowLayout uses the Layout protocol (iOS 16+) — SwiftUI's official first-party layout system.
  • You can add observers to stored properties you define, and to inherited stored or computed properties by overriding them in a subclass.
  • The value you assign replaces the one that was just set, and the observers are not triggered again, so there is no infinite loop.

FlowLayout uses the Layout protocol (iOS 16+) — SwiftUI's official first-party layout system. You implement sizeThatFits (return required size given a proposal) and placeSubviews (position children in final bounds). It's clean, zero-boilerplate, and participates correctly in the layout system.

WrapHStack is a View, not a Layout. It measures its own width with GeometryReader and positions children manually using alignmentGuide inside a ZStack. Height is reported via a PreferenceKey two-pass trick: render → measure → resize with @State var totalHeight.

FlowLayoutWrapHStack
ApproachLayout protocolView + GeometryReader
Width sourceLayout proposalGeometryReader (actual rendered)
Height reportingReturned from sizeThatFitsMeasured via PreferenceKey
Works in ScrollView❌ Unreliable✅ Reliable
Accepts any content✅ Yes❌ Needs RandomAccessCollection
Spacing configurable✅ Both axes❌ Row spacing hardcoded
iOS versioniOS 16+Any