Skip to content

Instantly share code, notes, and snippets.

View zwaldowski's full-sized avatar

Zachary Waldowski zwaldowski

View GitHub Profile
@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@zwaldowski
zwaldowski / Extra Logging for My Great App.mobileconfig
Last active January 19, 2024 00:35
Apple Configuration Profile for Logging in iOS 10 and macOS Sierra
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's
supposed to scale from the kernel, up to frameworks, and up to apps. It defaults
to a more regimented, privacy-focused approach that large apps and complex
systems need.
It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the
Console app in macOS Sierra, hope to help you graduate from caveman debugging to
@zwaldowski
zwaldowski / DoneAccessoryView.swift
Created February 11, 2019 16:01
iOS Done Accessory Bar — The two versions below are mutually exclusive
import UIKit
class DoneAccessoryView: UIInputView {
private let toolbar = UIToolbar()
init() {
super.init(frame: .zero, inputViewStyle: .default)
translatesAutoresizingMaskIntoConstraints = false
allowsSelfSizing = true
@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)")
@zwaldowski
zwaldowski / EventGenerator.swift
Created April 26, 2019 05:35
UIKit Touch Synthesis (Hacks! Hacks hacks! Hacks!)
import UIKit
import ObjectiveC.runtime
// MARK: - IOKit
@objc private protocol IOHIDEvent: NSObjectProtocol {}
private struct IOHIDDigitizerEventMask: OptionSet {
let rawValue: UInt32
init(rawValue: UInt32) { self.rawValue = rawValue }
@zwaldowski
zwaldowski / notes-specific-to-mac-os-x-10_9.md
Last active August 7, 2023 08:34
10.9 AppKit Release Notes
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) {
@zwaldowski
zwaldowski / CardPresenting.swift
Last active December 7, 2022 09:14
iOS presentation controller for bottom-focused cards using Auto Layout - https://www.icloud.com/iclouddrive/0wJzCDOwwXTRF53bM4xWLbYag#card-magic-ii
import UIKit
private class CardPresenter: UIPresentationController {
private let dimmingView = UIView()
private let roundingView = UIView()
// MARK: -
override init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?) {