Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / 00-reproducible-mach-o.md
Last active March 18, 2025 04:15
Reproducible Builds for macOS

Reproducible Builds for macOS

There's a neat writeup I stumbled across recently titled "Reproducible codesigning on Apple Silicon" from Keith Smiley about some gotchas when it comes to compiling a binary in a way that's repeatable and always generates the exact same byte output (which would then checksum to the exact same hash) - even if compiled on a different Mac.

In applying the suggestions I found in the blog post, I found a few other corner cases that I just wanted to get documented more explicitly somewhere.

Tools Matter

Footnote 2 from that blog post is important:

@insidegui
insidegui / lsremovearchives.sh
Created December 21, 2021 18:28
Remove Xcode app archives from macOS LaunchServices database
#!/bin/bash
# Recursivelly removes all apps from your Xcode archives from the LaunchServices database, preventing them from being used for widgets, launch at login, etc.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -R -f -u $HOME/Library/Developer/Xcode/Archives
@dsabanin
dsabanin / enable-xcode-debug-menu.sh
Last active November 7, 2022 16:17
Enable internal Xcode debug menu in Xcode 11
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode
sudo touch /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode/AppleInternal.plist
# Don't forget to restart Xcode
@steventroughtonsmith
steventroughtonsmith / UIView+Tooltips.h
Last active December 23, 2023 11:05
WIP tooltips for Mac Catalyst
//
// UIView+Tooltips.h
// Crossword
//
// Created by Steven Troughton-Smith on 13/09/2019.
// Copyright © 2019 Steven Troughton-Smith. All rights reserved.
//
#import <UIKit/UIKit.h>
@bbl
bbl / make_variable_check.md
Created July 13, 2019 12:10
Makefile check if variable is defined

Check if variable is defined in a Makefile

Using ifndef

ifndef MY_FLAG
$(error MY_FLAG is not set)
endif
@steventroughtonsmith
steventroughtonsmith / bitcode2intel
Created May 18, 2019 15:31
Converts an ARM64 iOS app with Bitcode into an X86_64 variant
#!/bin/bash
TARGET="$( cd "$(dirname "$1")" ; pwd -P )/$1"
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
TARGET_ARCH=x86_64
export IPHONEOS_DEPLOYMENT_TARGET=12.2
rm -r /tmp/bitcode2intel
mkdir -p /tmp/bitcode2intel
pushd /tmp/bitcode2intel
#import "fishhook.h" // from https://github.com/facebook/fishhook
// Replace write and writev, the two "chokepoint" functions that writes to stderr and stdout will probably pass through
static int (*originalWritev)(int fd, const struct iovec *v, int n);
static int (*originalWrite)(int fd, const void *buf, size_t size);
void checkForBadConstraintsMessage(int fd, const char *string, size_t size) {
if (strnstr(string, "UIViewAlertForUnsatisfiableConstraints", size)) {
// Write it to the console anyways before crashing
originalWrite(fd, string, size);
@DerekSelander
DerekSelander / LLDB_command_search.mm
Created November 6, 2018 21:08
A cleaned up and commented file of the dynamically generated code from the LLDB search.py command
//
// LLDB_command_search.mm
// Code Challenge
//
// Created by Derek Selander on 11/6/18.
// Copyright © 2018 Selander. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
@a-voronov
a-voronov / Monokai.xccolortheme
Last active October 27, 2023 06:16
Xcode 11 Monokai Theme 🎨
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>SFMono-Medium - 12.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@DerekSelander
DerekSelander / overlaydbg
Created February 25, 2018 20:36
Display UIDebuggingInformationOverlay on iOS 11 without swizzling
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
int imageCount = _dyld_image_count();
const struct mach_header* UIKitHeader = nil;
for (int i = 0; i < imageCount; i++) {
if (strcmp(basename((char *)_dyld_get_image_name(i)), "UIKit") == 0) {
UIKitHeader = _dyld_get_image_header(i);