Skip to content

Instantly share code, notes, and snippets.

View alemar11's full-sized avatar

Alessandro alemar11

View GitHub Profile
@apptekstudios
apptekstudios / CustomPicker.swift
Last active May 28, 2021 02:35
A variation on the picker designed by Federico Zanetello in his blog post (https://fivestars.blog/swiftui/inspecting-views.html) that allows any type of content to be used
//
// CustomPicker.swift
//
// Created by T Brennan on 27/3/21.
//
import SwiftUI
struct ContentView: View {
@State private var selection: Int? = 0

This page is now depreacted!

Check out the repo instead. The Wisdom of Quinn Now with 100% more archived PDFs.

The Wisdom of Quinn

Informative DevForum posts from everyone's favorite DTS member.

(Arranged newest to oldest)

@keith
keith / README.md
Last active January 8, 2025 18:59
A test of `@_dynamicReplacement` in Swift

Usage

  1. swiftc main.swift -emit-module-path main.swiftmodule -emit-executable -enable-private-imports -Xfrontend -enable-implicit-dynamic
  2. ./main -> prints From original bar()
  3. swiftc -emit-library inject.swift -o inject.dylib -I . -Xlinker -undefined -Xlinker suppress -Xlinker -flat_namespace -Xfrontend -disable-access-control
  4. DYLD_INSERT_LIBRARIES=inject.dylib ./main -> prints From replacement bar()

Notes

  • Passing -Xfrontend -enable-implicit-dynamic removes you from having to add dynamic to everything you want to be replacable
@shaps80
shaps80 / Models.swift
Last active January 9, 2021 16:48
Swift type for representing a UserAgent (includes an implementation similar of Appleโ€™s Version from SPM)
import UIKit
extension UIDevice {
/*
List can be updated here:
https://gist.github.com/adamawolf/3048717
*/
internal static var models: String = """
@steipete
steipete / OSLogStream.swift
Last active December 21, 2024 15:11
Access streaming OSLogStore at runtime with SPI. (FB8519418) https://steipete.com/posts/logging-in-swift/
//
// OSLogStream.swift
// LoggingTest
//
// Created by Peter Steinberger on 24.08.20.
//
// Requires importing https://github.com/apple/llvm-project/blob/apple/master/lldb/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h via bridging header
import Foundation
@seanlabastille
seanlabastille / LogReader.swift
Created July 8, 2020 09:47
Attempting to read OSLogStore in iOS 14 Beta 2
import OSLog
class LogReader: ObservableObject {
var log: OSLogStore
init?() {
do {
log = try OSLogStore.init(scope: .currentProcessIdentifier)
dump(log)
/*
@chriseidhof
chriseidhof / boilerplate.swift
Last active April 17, 2025 11:08
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@douglashill
douglashill / MenuAlignment.swift
Last active April 15, 2023 15:45
Swizzles the iOS contextual menu and share sheet to improve usability by showing the icon on the leading side. Read more: https://douglashill.co/menu-icon-swizzling/
// Douglas Hill, March 2020
// Code for the article at https://douglashill.co/menu-icon-swizzling/
import UIKit
struct MenuAlignmentFixError: Error, CustomStringConvertible {
let description: String
}
@IsaacXen
IsaacXen / README.md
Last active April 12, 2025 01:49
(Almost) Every WWDC videos download links for aria2c.
@chriseidhof
chriseidhof / viewmirror.swift
Last active April 3, 2025 08:40
View Mirror
import SwiftUI
struct ContentView: View {
var body: some View {
HStack {
Text("Hello")
.padding()
.background(.blue)
.overlay {
Color.yellow