Skip to content

Instantly share code, notes, and snippets.

View SquaredTiki's full-sized avatar

Josh Garnham SquaredTiki

View GitHub Profile
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@steipete
steipete / workaround.m
Created January 6, 2015 22:14
If you're implementing child view controllers and want automaticallyAdjustsScrollViewInsets to work...
// This ensures that the automaticallyAdjustsScrollViewInsets magic works
// On our newly added view controller as well.
// This triggers _layoutViewController which then triggers
// _computeAndApplyScrollContentInsetDeltaForViewController:
// which finally updates our content inset of the scroll view (if any)
// rdar://19053416
[self.navigationController.view setNeedsLayout];
@interface UIWindow (resize)
-(void)_adjustSizeClassesAndResizeWindowToFrame:(CGRect)frame;
@end
typedef enum _UICustomRes
{
UICustomResiPadTwoThirds,
UICustomResiPadHalf,
UICustomResiPadOneThird,
UICustomResiPhone47,
@depth42
depth42 / gist:6886194
Last active December 25, 2015 00:09
The xib compiler in Xcode 5.0.1 always sets the scaling bit of all NSViews which results in dramatically reduced performance. Until Apple fixes this severe bug, we work around this by patching NSKeyedUnarchiver to clear the bit during decoding of the compiled xib files. By the way: We filed this bug three months ago under rdar://14359398.
@interface NSKeyedUnarchiver (Xcode5Fix)
@end
@implementation NSKeyedUnarchiver (Xcode5Fix)
+ (void)load
{
[self exchangeInstanceMethod:@selector(decodeInt32ForKey:)
withMethod:@selector(xcode5Fix_decodeInt32ForKey:)];
}
@OdNairy
OdNairy / main.m
Last active December 21, 2015 00:28
// Source: https://devforums.apple.com/message/866487#866487
typedef int (*PYStdWriter)(void *, const char *, int);
static PYStdWriter _oldStdWrite;
int __pyStderrWrite(void *inFD, const char *buffer, int size)
{
if ( strncmp(buffer, "AssertMacros: queueEntry", 24) == 0 ) {
return 0;
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@tarnfeld
tarnfeld / gist:4534175
Created January 14, 2013 22:36
Create a bezier path with rounded corners based on a radius and existing frame. Most useful if you want to add in other shapes into the path while still maintaining rounded corners (for example, an arrow).
- (UIBezierPath *)roundedPathFromRect(CGRect)f
{
UIBezierPath *path = [[UIBezierPath alloc] init];
NSInteger radius = 4.0;
// Draw the path
[path moveToPoint:CGPointMake(radius, 0)];
[path addLineToPoint:CGPointMake(f.size.width - radius, 0)];
[path addArcWithCenter:CGPointMake(f.size.width - radius, radius)
radius:radius