This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| public extension View { | |
| func alert<Message: View, Actions: View>( | |
| _ title: LocalizedStringResource, | |
| presenting error: Binding<Error?>, | |
| @ViewBuilder message: @escaping (Error) -> Message, | |
| @ViewBuilder actions: @escaping () -> Actions | |
| ) -> some View { | |
| modifier( |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// This code defines an init method for the Binding type. This method accepts three parameters: | |
| /// | |
| /// An object of any type T | |
| /// A key path to a property of type Value on that object | |
| /// An optional UndoManager object | |
| /// | |
| /// The init method sets the Binding value to the value of the property specified by the key path. It also sets the set value of the Binding to a closure that updates the value of the property at the key path and registers an undo operation with the provided UndoManager, if one is given. | |
| /// | |
| /// This allows the Binding object to be used to access and update the value of the specified property on the provided object, and to register undo operations for those updates with the UndoManager. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import AVFoundation | |
| import CoreMedia | |
| class Converter { | |
| static func configureSampleBuffer(pcmBuffer: AVAudioPCMBuffer) -> CMSampleBuffer? { | |
| let audioBufferList = pcmBuffer.mutableAudioBufferList | |
| let asbd = pcmBuffer.format.streamDescription | |
| var sampleBuffer: CMSampleBuffer? = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Advanced SwiftUI Transitions | |
| // https://swiftui-lab.com | |
| // https://swiftui-lab.com/advanced-transitions | |
| import SwiftUI | |
| struct CrossEffectDemo: View { | |
| let animationDuration: Double = 2 | |
| let images = ["photo1", "photo2", "photo3", "photo4"] | |
| @State private var idx = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Darwin.C | |
| import Dispatch | |
| signal(SIGINT, SIG_IGN) | |
| let source = DispatchSource.makeSignalSource(signal: SIGINT, queue: .main) | |
| var count = 0 | |
| source.setEventHandler { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import AVFoundation | |
| var tb = mach_timebase_info() // イニシャライザ | |
| mach_timebase_info(&tb) // こっちは関数呼び出し | |
| let tsc = mach_absolute_time() | |
| let t = Double(tsc) * Double(tb.numer) / Double(tb.denom) / 1000000000.0 | |
| let seconds = AVAudioTime.seconds(forHostTime: tsc) | |
| let cmtime = CMTime(seconds: seconds, preferredTimescale: 1000000000) |
Worth a read for some more context.
Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:
/// Package.xcconfigNewerOlder