Skip to content

Instantly share code, notes, and snippets.

View rastersize's full-sized avatar

Aron Cedercrantz rastersize

View GitHub Profile
@steipete
steipete / swift-testing-playbook.md
Last active April 23, 2026 02:05
The Ultimate Swift Testing Playbook (feed it your agents for better tests!)

The Ultimate Swift Testing Playbook (2024 WWDC Edition, expanded with Apple docs from June 2025)

Updated with info from https://developer.apple.com/documentation/testing fetched via Firecrawl on June 7, 2025.

See also my blog: See also my blog post: https://steipete.me/posts/2025/migrating-700-tests-to-swift-testing

A hands-on, comprehensive guide for migrating from XCTest to Swift Testing and mastering the new framework. This playbook integrates the latest patterns and best practices from WWDC 2024 and official Apple documentation to make your tests more powerful, expressive, and maintainable.


1. Migration & Tooling Baseline

@janodev
janodev / waitForExpectation.swift
Last active May 16, 2025 17:13
waitForExpectation
import Foundation
import Testing
func waitForExpectation(
timeout: Duration,
description: String,
fileID: String = #fileID,
filePath: String = #filePath,
line: Int = #line,
column: Int = #column,
@Sherlouk
Sherlouk / DebugDevice.swift
Last active June 9, 2025 15:02
Debug Profiles - Securely debugging in production
//
// DebugDevice.swift
//
// Copyright 2022 • Sidetrack Tech Limited
//
import Foundation
// This must be called on the main-thread.
var isDebugProfileInstalled: Bool {
@Arutyun2312
Arutyun2312 / CustomGeometryReader.swift
Last active December 10, 2025 05:19
Custom Geometry Reader
//
// CustomGeometryReader.swift
//
//
// Created by Arutyun Enfendzhyan on 10.01.22.
//
import SwiftUI
struct CustomGeometryReader: View {
@steipete
steipete / KeyCommand.swift
Last active January 13, 2025 20:01
Add Keyboard Shortcuts to SwiftUI on iOS 13 when using `UIHostingController`. Requires using KeyboardEnabledHostingController as hosting class) See https://steipete.com/posts/fixing-keyboardshortcut-in-swiftui/
//
// KeyCommand.swift
// Adds Keyboard Shortcuts to SwiftUI on iOS 13
// See https://steipete.com/posts/fixing-keyboardshortcut-in-swiftui/
// License: MIT
//
// Usage: (wrap view in `KeyboardEnabledHostingController`)
// Button(action: {
// print("Button Tapped!!")
// }) {
@htr3n
htr3n / macos-ramdisk.md
Last active March 16, 2026 22:26
Creating RAM disk in macOS

Built-in

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://XXXXX`

where XXXXX is the size of the RAM disk in terms of memory blocks.

Notes:

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 22, 2026 23:54
set -e, -u, -o, -x pipefail explanation
@shaps80
shaps80 / Image+Color.swift
Created September 10, 2018 12:41
Swift Image from Color. Supports both UIImage and NSImage for cross-platform compatibility.
#if os(iOS)
import UIKit
public typealias PlatformImage = UIImage
public typealias PlatformColor = UIColor
#else
import AppKit
public typealias PlatformImage = NSImage
public typealias PlatformColor = NSColor
#endif
@JoeMatt
JoeMatt / Carthage.sh
Last active November 14, 2019 21:19
Improve Carthage performance with Per-target manifest caching and optional Fastlane usage
set -e
# carthage.sh : smarter carthage updating and caching by Joe Mattiello
#
# Inspired from http://shashikantjagtap.net/cache-carthage-speed-ios-continuous-integration/
#
# The purpose of this script is to reduce the amount of checkouts Carthage runs.
# I use this script in an XCode 'run script' build phase as the first phase before compiling
# If you have mutliple targets, projects, frameworks etc, you can include this script in each and it will selec
# the correct Carthage folder for each target.
@DougGregor
DougGregor / dynamic_member_lookup_environment.swift
Created May 2, 2018 16:59
Using Swift 4.2's @dynamicMemberLookup to expose environment variables
import Darwin
@dynamicMemberLookup
struct Environment {
subscript(dynamicMember name: String) -> String? {
get {
guard let value = getenv(name) else { return nil }
return String(validatingUTF8: value)
}