Skip to content

Instantly share code, notes, and snippets.

View shepting's full-sized avatar

Steven Hepting shepting

View GitHub Profile
@available(iOS 15.0, *)
public struct RichTextEditor : SwiftUICore.View {
public init(text: SwiftUICore.Binding<Foundation.AttributedString>)
@_Concurrency.MainActor @preconcurrency public var body: some SwiftUICore.View {
get
}
@available(iOS 15.0, *)
public typealias Body = @_opaqueReturnTypeOf("$s7SwiftUI14RichTextEditorV4bodyQrvp", 0) __
}
@available(*, unavailable)
@stephancasas
stephancasas / DumbHTTPServer.swift
Created March 29, 2024 16:28
A low-level HTTP server offering a SwiftUI-observable lifecycle.
//
// DumbHTTPServer.swift
// DumbHTTPServer
//
// Created by Stephan Casas on 3/29/24.
//
import SwiftUI;
import Combine;
@saagarjha
saagarjha / library_injector.cpp
Last active April 22, 2025 17:07
Load a library into newly spawned processes (using DYLD_INSERT_LIBRARIES and EndpointSecurity)
// To compile: clang++ -arch x86_64 -arch arm64 -std=c++20 library_injector.cpp -lbsm -lEndpointSecurity -o library_injector,
// then codesign with com.apple.developer.endpoint-security.client and run the
// program as root.
#include <EndpointSecurity/EndpointSecurity.h>
#include <algorithm>
#include <array>
#include <bsm/libbsm.h>
#include <cstddef>
#include <cstdint>
@saagarjha
saagarjha / stop_at_entry.c
Last active July 24, 2024 20:55
Endpoint Security client that sends SIGSTOP to newly spawned processes
// To compile: clang stop_at_entry.c -lbsm -lEndpointSecurity -o stop_at_entry,
// then codesign with com.apple.developer.endpoint-security.client and run the
// program as root.
#include <EndpointSecurity/EndpointSecurity.h>
#include <assert.h>
#include <bsm/libbsm.h>
#include <dispatch/dispatch.h>
#include <signal.h>
#include <stdbool.h>
# typed: true
# frozen_string_literal: true
require('dev')
require('fileutils')
module Dev
module Helpers
class APFSVolume
extend(T::Sig)

Debugging the Swift Toolchain

Use these steps to debug components of the Swift toolchain. This allows you to see Swift's source code from the debugger – instead of disassembly. The debugger can also provide some variable names and values. This has been initially tested with libswiftCore.dylib.

These instructions were updated as of Swift 5.2.1.

Prerequisites

# typed: false
# frozen_string_literal: true
# Note: This is loaded *ludicrously* early in the boot process: please don't
# introduce other dependencies here.
# ===
# Okay so here's the deal. When we compile a bundle of ruby code via
# `bundlerEnv`, we install all the gems individually into a bunch of separate
@kastiglione
kastiglione / swift-llvm-headers-swiftpm.md
Last active February 4, 2020 11:28
Using Swift and LLVM headers in SwiftPM

Recently, we wanted call swift-demangle from code, but calling out to the process frequently was a bit too slow, and meant parsing the output of -tree-only, since we wanted to access module and class names, for example.

Fortunately there's libswiftDemangle.dylib for this, but it's a C++ API. Compiling against it requires #includeing headers from both Swift and LLVM.

Using CMake, both Swift and LLVM can easily be added as dependencies, but we build this project with SwiftPM. To build with SwiftPM, we imported the necessary headers. Roughly, here are the steps to determine which specific Swift

@Omar-Ikram
Omar-Ikram / EndpointSecurityDemo.m
Last active May 4, 2025 13:20
A demo of using Apple's EndpointSecurity framework - tested on macOS Monterey 12.2.1 (21D62)
//
// main.m
// EndpointSecurityDemo
//
// Created by Omar Ikram on 17/06/2019 - macOS Catalina 10.15 Beta 1 (19A471t)
// Updated by Omar Ikram on 15/08/2019 - macOS Catalina 10.15 Beta 5 (19A526h)
// Updated by Omar Ikram on 01/12/2019 - macOS Catalina 10.15 (19A583)
// Updated by Omar Ikram on 31/01/2021 - macOS Big Sur 11.1 (20C69)
// Updated by Omar Ikram on 07/05/2021 - macOS Big Sur 11.3.1 (20E241)
// Updated by Omar Ikram on 04/07/2021 - macOS Monterey 12 Beta 2 (21A5268h)
@jerrymarino
jerrymarino / nix-tips.md
Created June 3, 2019 18:20
Tips for using the nix package manager on macOS