Skip to content

Instantly share code, notes, and snippets.

Peter Steinberger steipete

Block or report user

Report or block steipete

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@steipete
steipete / gist:7a125b20cce461bf9a072dfacd805507
Created May 20, 2020
Twitter app crashing on 10.15.5b4
View gist:7a125b20cce461bf9a072dfacd805507
Process: Twitter [18613]
Path: /Applications/Twitter.app/Contents/MacOS/Twitter
Identifier: Twitter
Version: 8.19 (8.19.1)
App Item ID: 1482454543
App External ID: 835910359
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Twitter [18613]
User ID: 501
@steipete
steipete / gist:504e79558d861211a3a9ff794e09c817
Created May 20, 2020
Twitter crash on 12-inch MBP on macOS 10.15.4 stable
View gist:504e79558d861211a3a9ff794e09c817
Process: Twitter [45863]
Path: /Applications/Twitter.app/Contents/MacOS/Twitter
Identifier: Twitter
Version: 8.19 (8.19.1)
App Item ID: 1482454543
App External ID: 835910359
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Twitter [45863]
User ID: 501
View boilerplate.swift
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
public func run<V: View>(view: V) {
let delegate = AppDelegate(view)
let app = NSApplication.shared
NSApp.setActivationPolicy(.regular)
app.mainMenu = app.customMenu
@steipete
steipete / gist:92f66ec9387e8e4c7c17ffebb0824a8e
Created May 14, 2020
deciphering kernel debug=0x104c44
View gist:92f66ec9387e8e4c7c17ffebb0824a8e
Need to run with csrutil disable or recovery
sudo nvram boot-args="debug=0x104c44”
0x104c44 = 1 0000 0100 1100 0100 0100
DB_NMI 0x4 // changes the power-button to create a non-maskable interrupt?
DB_ARP 0x40 // allows debugging across subnets via ARP?
DB_KERN_DUMP_ON_PANIC 0x400 // Trigger core dump on panic
@steipete
steipete / FirebaseCoordinator.swift
Created Apr 13, 2020
If you're as confused as I am that there's an API for custom options, yet Google still requires a file named GoogleService-Info.plist in your app, here's some swizzling that fixes that for ya. All Swift :)
View FirebaseCoordinator.swift
class FirebaseCoordinator {
static let shared = FirebaseCoordinator()
static let initialize: Void = {
/// We modify Google Firebase (and eventually Analytics) to load the mac-specific plist at runtime.
/// Google enforces that we have a file named "GoogleService-Info.plist" in the app resources.
/// This is unfortunate since we need two different files based on iOS and Mac version
/// One solution is a custom build step that copies in the correct file:
/// https://stackoverflow.com/questions/37615405/use-different-googleservice-info-plist-for-different-build-schemes
/// However, this is basically impossible since Catalyst doesn't set any custom build variables, so detection is extremely difficult.
/// We swizzle to modify the loading times.
@steipete
steipete / RuntimeScanner.swift
Last active Apr 9, 2020
Runtime Scanner to find large ObjC encodings. Inspired by https://medium.com/@dmaclach/objective-c-encoding-and-you-866624cc02de - this code scans the runtime to find excessive Objective-C type encodings, usually created when you mix it with C++. We were able to reduce the binary size by 100KB with rewriting just a few methods that were extremel…
View RuntimeScanner.swift
//
// Copyright © 2020 PSPDFKit GmbH, Peter Steinberger. MIT Licensed.
//
import Foundation
extension String {
fileprivate init?(maybeCString: UnsafePointer<CChar>?) {
guard let cString = maybeCString else { return nil }
self.init(cString: cString)
@steipete
steipete / PSPDFPointerInteractionSupport.h
Created Mar 26, 2020
Support Pointer Interactions while CI still running on Xcode 11.3
View PSPDFPointerInteractionSupport.h
//
// Copyright © 2020 PSPDFKit GmbH. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
// This notice may not be removed from this file.
//
#import <Foundation/Foundation.h>
@steipete
steipete / gist:cb92914494763b2ed5aa20e5dc589280
Created Feb 21, 2020
Twitter crashes on macOS 10.15.4b2
View gist:cb92914494763b2ed5aa20e5dc589280
Process: Twitter [12485]
Path: /Applications/Twitter.app/Contents/MacOS/Twitter
Identifier: maccatalyst.com.atebits.Tweetie2
Version: 8.9 (8.9)
App Item ID: 1482454543
App External ID: 834769122
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Twitter [12485]
User ID: 501
View AppKitHelper.m
@implementation UIImage (ResourceProxyHack)
+ (UIImage *)_iconForResourceProxy:(id)proxy format:(int)format {
// HACK: proxy seems garbage so we always show PDF for now.
let cgImage = [_bridge imageForFileType:@"pdf"];
// HACK: We use mainScreen here but could have multiple screens.
let image = [UIImage imageWithCGImage:cgImage scale:UIScreen.mainScreen.scale orientation:UIImageOrientationUp];
return image;
}
View AppKitHelper.m
@implementation UIImage (ResourceProxyHack)
+ (UIImage *)_iconForResourceProxy:(id)proxy format:(int)format {
// HACK: proxy seems garbage so we always show PDF for now.
let cgImage = [_bridge imageForFileType:@"pdf"];
// HACK: We use mainScreen here but could have multiple screens.
let image = [UIImage imageWithCGImage:cgImage scale:UIScreen.mainScreen.scale orientation:UIImageOrientationUp];
return image;
}
You can’t perform that action at this time.