Swiftpack.co - getogrand/SwiftUIViewTypeInspection as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by getogrand.
getogrand/SwiftUIViewTypeInspection 0.1.0
SwiftUIViewTypeInspection provides helpers methods on SwiftUI.View to inspect its real concrete type.
⭐️ 1
🕓 3 weeks ago
iOS macOS watchOS macCatalyst
.package(url: "https://github.com/getogrand/SwiftUIViewTypeInspection.git", from: "0.1.0")

SwiftUIViewTypeInspection

SwiftUIViewTypeInspection provides helpers methods on SwiftUI.View to inspect its real concrete type.

View.inspectType() -> Self

Print its real concrete type representation to the standard output stream.

Example:

import SwiftUIViewTypeInspection

struct MyView: View {
  var body: some View {
    HStack {
      Text("Hello, ")
      Text("world!")
    }
    .inspectType() // prints "HStack<TupleView<(Text, Text)>>"
  }
}

View.inspectType<Target: TextOutputStream>(to output: inout Target) -> Self

Store its real concrete type representation to the target stream.

Tip: the String type conforms TextOutputStream.

Example:

import SwiftUIViewTypeInspection

var output: String = ""

struct MyView: View {
  var body: some View {
    HStack {
      Text("Hello, ")
      Text("world!")
    }
    .inspectType(to: &output) // stores "HStack<TupleView<(Text, Text)>>\n"
  }
}

Credits

Thinking in SwiftUI, page 10, 2020-12-15 ver.

GitHub

link
Stars: 1
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.1.0
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics