Skip to content

Instantly share code, notes, and snippets.

View zwaldowski's full-sized avatar

Zachary Waldowski zwaldowski

View GitHub Profile
zwaldowski / ContentView.swift
Created October 11, 2023 01:13
View ContentView.swift
struct ContentView: View {
@Environment(\.locale) var locale
var body: some View {
VStack {
Image(systemName: "globe")
Text("Locale: \(locale.identifier)")
Text("Measurement: \(locale.measurementSystem.identifier)")
View 1-VideoPlayerView-Unidirectional.swift
struct AVPlayerViewWrapper: UIViewControllerRepresentable {
var url: URL
var shouldStartPlayback: Bool
func makeUIViewController(context: Context) -> AVPlayerViewController {
let controller = AVPlayerViewController()
controller.player = AVPlayer(url: url)
return controller
View MuchTodo.swift
import SwiftData
import SwiftUI
struct Much_TodoApp: App {
var body: some Scene {
WindowGroup {
.modelContainer(for: TodoItem.self)
View SubviewReader.swift
// TODO docs
public typealias SubviewProxy = _VariadicView.Children
// TODO docs
public struct SubviewReader<Children, Content>: View where Children: View, Content: View {
var children: Children
var content: (SubviewProxy) -> Content
// TODO docs
public init(_ children: Children, @ViewBuilder content: @escaping (SubviewProxy) -> Content) {
View Copy.swift
/// Captures a Cocoa object as a parameter to a `@Sendable` function or closure.
public struct Copy<Wrapped>: @unchecked Sendable where Wrapped: NSCopying {
// from: <>
public let wrappedValue: Wrapped
public init(wrappedValue: Wrapped) {
self.wrappedValue = wrappedValue.copy() as! Wrapped // swiftlint:disable:this force_cast
View ArrayBuilder.swift
struct ArrayBuilder<Element> {
static func buildExpression(_ expression: Element) -> [Element] {
[ expression ]
static func buildBlock(_ elements: [Element]...) -> [Element] {
elements.flatMap { $0 }

Hello, world!

Warning Warning

Info Info

View Package-App.swift
// swift-tools-version: 5.5
// This file is automatically generated.
// Do not edit it by hand because the contents will be replaced.
import PackageDescription
import AppleProductTypes
let package = Package(

Repackaging a Fat Static Library as an xcframework

Consider this directory tree from a vendor:

zwaldowski / AssumeEqualUntilModified.swift
Created August 15, 2021 21:03
Property wrapper - Assume equal until modified; use `UIConfigurationColorTransformer` in custom structs
View AssumeEqualUntilModified.swift
/// Customizes the behavior of automatically-generated `Equatable` and `Hashable` conformances.
public struct AssumeEqualUntilModified<Wrapped> {
var modificationCount = 0
public var wrappedValue: Wrapped {
didSet {
modificationCount += 1