Skip to content

Instantly share code, notes, and snippets.

View zwaldowski's full-sized avatar

Zachary Waldowski zwaldowski

View GitHub Profile
@zwaldowski
zwaldowski / ContentView.swift
Created October 11, 2023 01:13
`Locale.MeasurementSystem`
struct ContentView: View {
@Environment(\.locale) var locale
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Locale: \(locale.identifier)")
Text("Measurement: \(locale.measurementSystem.identifier)")
struct AVPlayerViewWrapper: UIViewControllerRepresentable {
var url: URL
var shouldStartPlayback: Bool
func makeUIViewController(context: Context) -> AVPlayerViewController {
let controller = AVPlayerViewController()
controller.player = AVPlayer(url: url)
return controller
}
import SwiftData
import SwiftUI
@main
struct Much_TodoApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(for: TodoItem.self)
// 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) {
/// Captures a Cocoa object as a parameter to a `@Sendable` function or closure.
@propertyWrapper
public struct Copy<Wrapped>: @unchecked Sendable where Wrapped: NSCopying {
// from: <https://github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md?plain=1#L568>
public let wrappedValue: Wrapped
public init(wrappedValue: Wrapped) {
self.wrappedValue = wrappedValue.copy() as! Wrapped // swiftlint:disable:this force_cast
}
}
@resultBuilder
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

// swift-tools-version: 5.5
// WARNING:
// 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:

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