Skip to content

Instantly share code, notes, and snippets.

@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
@marmoy
marmoy / DictionaryEncoder.swift
Created April 2, 2018 09:48
A DictionaryEncoder to be used with the Encodable protocol, based on the default PropertyListEncoder from the Swift project
//===----------------------------------------------------------------------===//
//
// This source file is a modification of the PropertyListEncoder from the Swift project.
// The modification consists of skipping the final serialization into binary format (in the encode function) and instead returning the dictionary representation of the object to be encoded.
//
//===----------------------------------------------------------------------===//
import Foundation
//===----------------------------------------------------------------------===//
@ddunbar
ddunbar / Xcode-user-defaults
Last active September 28, 2023 17:03
Xcode user defaults
# Enable timings on build operations
defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES
# Enable extensive per-task timings
defaults write com.apple.dt.Xcode IDEBuildOperationTimingLogLevel -int 3
# Enable old build system logging for "implicit dependencies"
defaults write com.apple.dt.Xcode IDEBuildOperationDependenciesLogLevel -int 3
# Show logs from the "prebuild" step
@ddunbar
ddunbar / xcbuild-debugging-tricks.md
Last active April 13, 2024 15:41
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen
@smirn0v
smirn0v / gist:0b4fefcb5d2452f716b1
Last active February 12, 2018 15:54
Debugserver
$ cd /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
# choose your platform
$ cd 7.1
# mount developer disk image
$ hdiutil attach DeveloperDiskImage.dmg
# copy debugserver
$ cp /Volumes/DeveloperDiskImage/usr/bin/debugserver ~/
$ cd ~/
# prepare entitlements
$ cat > entitlements.plist << 'EOF'
@steipete
steipete / CallOncePerRunloopHelper.m
Last active February 2, 2018 07:32
To work around rdar://19810773, I need a helper that can filter multiple calls to the same method during the same runloop. This is my first attempt on it.
/// Performs `block` immediately and ignores subsequent calls during the same runloop.
#define pspdf_ensureCalledOnlyOncePerRunloop(block) do { \
static const char __onceKey; _pspdf_ensureCalledOnlyOncePerRunloop(self, &__onceKey, block); } while(0)
extern void _pspdf_ensureCalledOnlyOncePerRunloop(id self, const void *key, dispatch_block_t block);
void _pspdf_ensureCalledOnlyOncePerRunloop(id self, const void *key, dispatch_block_t block) {
NSCParameterAssert(block);
NSCParameterAssert(self);
PSPDFAssertOnMainThread(); // run loop needs the main thread.
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
import lldb
import re
import shlex
# This script allows Xcode to selectively ignore Obj-C exceptions
# based on any selector on the NSException instance
def getRegister(target):
if target.triple.startswith('x86_64'):
return "rdi"
@steipete
steipete / UIKitLegacyDetector.m
Last active March 12, 2024 13:57
A simple way to detect at runtime if we're running in UIKit legacy mode or the new "flat" variant. Written for our PDF iOS SDK (http://pspdfkit.com), where the precompiled binary needs to detect at runtime in what variant it's running. Want more stuff like that? Follow me on Twitter: http://twitter.com/steipete
// Taken from http://PSPDFKit.com. This snippet is under public domain.
#define UIKitVersionNumber_iOS_7_0 0xB57
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0;
}