Skip to content

Instantly share code, notes, and snippets.

View lukaskubanek's full-sized avatar

Lukas Kubanek lukaskubanek

View GitHub Profile
lukaskubanek / Bundle+TestFlight.swift
Last active April 26, 2024 08:48
A code snippet for detecting the TestFlight environment for a macOS app at runtime
/// MIT License
/// Copyright (c) 2021 Lukas Kubanek, Structured Path GmbH
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
lukaskubanek / SwiftUIListRowHighlightFix.swift
Last active March 26, 2024 17:51
A workaround for fixing SwiftUI’s list row highlighting behavior by preventing unwanted delays
import InterposeKit
import SwiftUI
/// A workaround for an issue in SwiftUI related to delayed highlighting of list rows upon user
/// interaction, rendering it inconsistent with UIKit.
/// This fix implements the solution proposed by Léo Natan and utilizes `InterposeKit` by Peter
/// Steinberger to modify the behavior of `UICollectionViewCell` instances used internally
/// by SwiftUI.
lukaskubanek /
Last active February 21, 2024 16:26
macOS Monterey Keyboard Shortcuts Leveraging the Fn Key
Shortcut Description Overridable?[^1]
Fn-A Navigate Dock No
Fn-Shift-A Launchpad No
Fn-C Control Center No
Fn-E Emoji & Symbols Yes
Fn-F Enter/Exit Full Screen Yes
Fn-H Desktop No
Fn-M Navigate Main Menu Yes
Fn-N Notifications No
lukaskubanek / View+KeyboardAvoidance.swift
Created December 4, 2023 07:28
A patch for SwiftUI views that disables keyboard avoidance
import InterposeKit
import UIKit
import SwiftUI
import SwiftUIIntrospect
extension View {
public func keyboardAvoidanceDisabled() -> some View {
self.introspect(.viewController, on: .iOS(.v17)) { viewController in
if let hostingView = viewController.parent?.view {
if String(describing: type(of: hostingView)).hasPrefix("_UIHostingView") {
lukaskubanek / NSView Drawing Issue on macOS Big
Last active July 18, 2022 08:09
NSView Drawing Issue on macOS Big Sur

This is an excerpt from our internal documentation describing an issue with drawing in NSViews on macOS Big Sur.

1️⃣ Introduction

In macOS Big Sur (probably starting with β9), Apple changed the default contents format for backing layers of NSViews. Instead of an explicit CALayerContentsFormat.RGBA8Uint value, an „Automatic“ value is now used. Even though it also resolves into „RGBA8“ in our testing, it has some serious implications as it breaks assumptions our code relies on.

I first stumbled upon this issue in this tweet by Frank. It links to a thread on Apple Forums by Mark that contains valuable information as well as ideas for workarounds. The changed behavior was also confirmed by Marcin in this tweet.

2️⃣ Impact on Diagrams

lukaskubanek / NSBezierPath+CGPath.swift
Created June 14, 2015 08:19
import AppKit
public extension NSBezierPath {
public convenience init(path: CGPath) {
let pathPtr = UnsafeMutablePointer<NSBezierPath>.alloc(1)
lukaskubanek / XCTAssertThrowsError.swift
Created March 14, 2021 18:58
XCTAssertThrowsError(…) With Error Equality Check
import XCTest
public func XCTAssertThrowsError<T, E: Error & Equatable>(
_ expression: @autoclosure () throws -> T,
expected expectedError: E,
_ message: String = "",
file: StaticString = #filePath,
line: UInt = #line
) {
XCTAssertThrowsError(try expression(), message, file: file, line: line) { error in
lukaskubanek /
Last active April 7, 2016 12:36
Updating public key to work with GitHub
  1. Import keys to GPG locally (→ link)
  2. Add new email address to the public key (→ link)
  3. Export the public key and upload it to again (→ link)
  4. Configure GPG for Git locally (→ link)
lukaskubanek / disable_undo.m
Created January 12, 2014 21:46
Disabling undo for a specific operation of Core Data
- (void)method
NSUndoManager *undoManager = [self undoManager];
[undoManager disableUndoRegistration];
/* do something */
[self.managedObjectContext processPendingChanges];
[undoManager enableUndoRegistration];
lukaskubanek /
Last active December 11, 2015 02:18
Disable the Notification Center in Mac OS X using cURL.
# commands taken from
# usage: curl -L | sh
launchctl unload -w /System/Library/LaunchAgents/
killall NotificationCenter