Skip to content

Instantly share code, notes, and snippets.

HiddenJester / Color+UIColor.swift
Last active Feb 28, 2021
A simple extension to SwiftUI Color that bridges over the "missing" colors from UIColor. Write `Text("Hello").foregroundColor(.label)` instead of `Text("Hello").foregroundColor(Color(UIColor.label))`
View Color+UIColor.swift
// Color+UIColor.swift
// Swatches
// Created by Timothy Sanders on 2019-11-15.
import Foundation
import SwiftUI
import UIKit
HiddenJester /
Last active Aug 26, 2020
Mocking SceneDelegate for Unit Tests on iOS 13

Replacing the SceneDelegate When Running Unit Tests


I've been working through the exercises in the excellent iOS Unit Testing by Example book by Jon Reid, which I highly recommend. However, the book is in beta at the moment and there are some curveballs thrown by iOS 13 that aren't handled in the text yet. Specifically, when I hit the section about using a testing AppDelegate class I thought "This is very good. But what about the SceneDelegate?"

In Chapter 4 the recommendation is to remove the @UIApplicationMain decoration and make a manual top-level call to UIApplicationMain. To wit:

import UIKit
HiddenJester / WatchKit Versioning pre-commit hook
Last active Aug 29, 2015
A script usable as a git pre-commit hook that sets the CFBundleVersion of a specified plist to a count of commits in the repository. This is useful for WatchKit apps that cannot run a Run Scripts phase, but must sync version information to the host app.
View WatchKit Versioning pre-commit hook
# Hacky script to update the version of the WatchKit App bundle version to everything else. All of the other targets
# a run script phase that uses out of HJSKit to set the build version to the commit info from git.
# But WatchKit apps can't have a run script phase yet so this pre-commit script mimics the effects but actually edits
# the Info.plist used by by the WatchKit target. Pieces of this are from, choppped & screwed.
# Redirect output to stderr.
exec 1>&2
HiddenJester / KeepViewAboveKeyboard.swift
Last active Aug 29, 2015
Simple widget to manage a simple UIView with child views that need to be put above the keyboard.
View KeepViewAboveKeyboard.swift
// NOTE 2015-04-22: This is out of date, but my current implementation has a couple of different tricks and ends up
// being multiple source files and isn't really suitable for gist-posting. I'm currently looking at putting all of HJSKit
// up on GitHub but that's a low-priority project. If you are interested in using something like this contact me (Tim Sanders)
// and I'll get you the latest code.
// KeepViewAboveKeyboard.swift
// HJSExtension
// Created by Timothy Sanders on 2014-12-04.
// Copyright (c) 2014 HIddenJester Software. All rights reserved.