Great series of short articles introducing Apple's Metal framework.
- 2022-04-01: Day 1: Devices
- 2022-04-02: Day 2: Buffers
- 2022-04-03: Day 3: Commands
- 2022-04-04: Day 4: MTKView
- 2022-04-05: Day 5: Shaders
- 2022-04-06: Day 6: Pipelines
Great series of short articles introducing Apple's Metal framework.
| #!/bin/zsh | |
| # Test if the Swift compiler knows about a particular language feature. | |
| # | |
| # Usage: | |
| # | |
| # swift-has-feature [--swift SWIFT_PATH] [--language-version LANGUAGE_VERSION] FEATURE | |
| # | |
| # The feature should be an upcoming or experimental language feature, | |
| # such as `"StrictConcurrency"` or `"ExistentialAny"`. |
| // swift-tools-version: 6.0 | |
| // The swift-tools-version declares the minimum version of Swift required to build this package. | |
| import PackageDescription | |
| let package = Package( | |
| name: "MyPackage", | |
| products: [ | |
| .library(name: "MyLibrary", targets: ["MyLibrary"]), | |
| ], |
A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.
Note: I used a Swift 5.3 compiler build from a few weeks ago that I had laying around. Because of ABI stability, I don't think the swift-reflection-dump version has to match the compiler version that was used to build the binary, but I'm not 100% sure.
| # (File moved to https://github.com/ole/Storyboard-Strings-Extraction) |
| // UserDefaults KVO observation with AsyncSequence/AsyncStream | |
| // Ole Begemann, 2023-04 | |
| // Updated for Swift 6, 2024-11 | |
| // https://gist.github.com/ole/fc5c1f4c763d28d9ba70940512e81916 | |
| import Foundation | |
| // This is ugly, but UserDefaults is documented to be thread-safe, so this | |
| // should be OK. | |
| extension UserDefaults: @retroactive @unchecked Sendable {} |
| import XCTest | |
| /// An expectation that is fulfilled when a Key Value Observing (KVO) condition | |
| /// is met. It's variant of `XCTKVOExpectation` with support for native Swift | |
| /// key paths. | |
| final class KVOExpectation: XCTestExpectation { | |
| private var kvoToken: NSKeyValueObservation? | |
| /// Creates an expectation that is fulfilled when a KVO change causes the | |
| /// specified key path of the observed object to have an expected value. |
| // A heterogeneous dictionary with strong types in Swift, https://oleb.net/2022/heterogeneous-dictionary/ | |
| // Ole Begemann, April 2022 | |
| /// A key in a `HeterogeneousDictionary`. | |
| public protocol HeterogeneousDictionaryKey { | |
| /// The "namespace" the key belongs to. Every `HeterogeneousDictionary` has its associated domain, | |
| /// and only keys belonging to that domain can be stored in the dictionary. | |
| associatedtype Domain | |
| /// The type of the values that can be stored under this key in the dictionary. | |
| associatedtype Value |
| /// Runs a secondary side action concurrently with a primary action. | |
| /// The secondary action only starts after the specified delay. | |
| /// | |
| /// Usage example: showing a progress indicator UI only if the primary action | |
| /// takes a significant amount of time. | |
| /// | |
| /// The secondary action runs in a child task (structured concurrency). | |
| /// | |
| /// - Note: I'd like to provide a default argument for the clock: `clock: C = .continuous`, | |
| /// like `Task.sleep` does. But this doesn't compile in Swift 6.2. Related bug report: |
| #!/bin/bash | |
| # List Swift diagnostic groups. | |
| # | |
| # Author: Ole Begemann | |
| # | |
| # Usage: | |
| # | |
| # swift-list-diagnostic-groups [version] # default: main branch | |
| # |