Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
@main
struct TravelPhotographyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
.commands {
TextEditingCommands()
@steipete
steipete / swift-testing-playbook.md
Last active July 8, 2025 04:55
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

@steipete
steipete / concat.sh
Created May 17, 2025 23:32
Squashes a whole codebase into one text file, skipping build artefacts, copies it right into the clipboard.
#!/usr/bin/env bash
#
# concat.sh [root-dir] [output-file]
#
# Squashes a whole codebase into one text file, skipping build artefacts:
# • ignores node_modules, dist, .git, .turbo, .next, out
# • omits lockfiles and *.min.* noise
# • copies the result straight to the macOS clipboard (pbcopy)
#
# Example:
@aashari
aashari / 00 - Cursor AI Prompting Rules.md
Last active July 9, 2025 06:42
Cursor AI Prompting Rules - This gist provides structured prompting rules for optimizing Cursor AI interactions. It includes three key files to streamline AI behavior for different tasks.

Cursor AI Prompting Framework — Usage Guide

A disciplined, evidence-first workflow for autonomous code agents


1 · Install the Operational Doctrine

The Cursor Operational Doctrine (file core.md) encodes the agent’s always-on principles—reconnaissance before action, empirical validation over conjecture, strict command-execution hygiene, and zero-assumption stewardship.

@RuiAAPeres
RuiAAPeres / covariance_contravariance.swift
Last active September 16, 2019 16:06
Covariance and Contravariance in Swift
import UIKit
// Based on https://www.stephanboyer.com/post/132/what-are-covariance-and-contravariance
// > Denotes "a subtype of"
// UIButton > UIView > UIResponder > NSObject
//
// e.g. `UIButton` is a subtype of `UIView`
//
// This means that any function that takes a `UIView`, can receive a `UIButton`:
//
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
@TheiOSDude
TheiOSDude / deleteSimApp.sh
Last active August 29, 2018 13:45
delete iOS app from booted simulator as a run script
xcrun simctl uninstall booted com.theiosdude.bundleid
@shaps80
shaps80 / 1. StateMachine.swift
Last active May 17, 2023 12:27
A lightweight generic state machine implementation in Swift.
import Foundation
import os.log
public protocol StateMachineDelegate: class {
associatedtype StateType: Hashable
/// Invoked before a transition is about to occur, allowing you to reject even a valid transition. Defaults to true
///
/// - Parameters:
//
// main.swift
// RoutingApproaches
//
// Created by Chris Eidhof on 01.08.18.
// Copyright © 2018 objc.io. All rights reserved.
//
import Foundation
@raulraja
raulraja / Tagless.kt
Last active January 20, 2020 15:53
Tagless in Kotlin with Arrow and manual DI
import arrow.Kind
import arrow.core.Option
import arrow.core.Try
import arrow.core.functor
import arrow.effects.IO
import arrow.effects.fix
import arrow.effects.functor
import arrow.typeclasses.Functor
/* algebras */