This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display shared libraries that your binary attempts to load | |
otool -L <binary> | |
# Display DYLD symbols for exports and imports | |
nm <binary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
class MyTestCase: XCTestCase { | |
func testExample() { | |
XCTAssertTrue(true) | |
} | |
} | |
MyTestCase.defaultTestSuite.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Utility Class that can hold on to any number of delegates and invoke arbitrary blocks of code on them | |
public class MulticastDelegate<T: AnyObject> { | |
/// HashTable containing any number of delegates, held weakly | |
private let delegates: NSHashTable<AnyObject> = NSHashTable.weakObjects() | |
/// Adds delegate to list of delegates | |
/// | |
/// - Parameter delegate: Delegate to add to list of known delegates | |
public func add(_ delegate: T) { | |
delegates.add(delegate as AnyObject) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension DispatchQueue { | |
fileprivate static let mainQueueKey = DispatchSpecificKey<()>() | |
static func configureMainQueue() { | |
main.setSpecific(key: mainQueueKey, value: ()) | |
} | |
} | |
public extension DispatchQueue { | |
/// Easy and safe way of checking if the current queue is the main queue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// The HasCustomView protocol defines a customView property for UIViewControllers to be used in exchange of the regular view property. | |
/// In order for this to work, you have to provide a custom view to your UIViewController at the loadView() method. | |
public protocol HasCustomView { | |
associatedtype CustomView: UIView | |
} | |
extension HasCustomView where Self: UIViewController { | |
/// The custom typed view | |
public var customView: CustomView { | |
guard let customView = view as? CustomView else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum AssociationPolicy { | |
case assign | |
case retain | |
case copy | |
case retainNonatomic | |
case copyNonatomic | |
fileprivate var policy: objc_AssociationPolicy { | |
switch self { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIWindow { | |
final class StatusBarPreferringViewController: UIViewController { | |
// MARK: - Inputs | |
private let statusBarStyle: UIStatusBarStyle | |
// MARK: - Initialization | |
init(statusBarStyle: UIStatusBarStyle) | |
self.statusBarStyle = statusBarStyle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Sets your audio input source to "Internal Microphone" | |
-- Frequently needed if you use bluetooth headpohones and | |
-- run the Xcode iOS simulator, which will often set your | |
-- headphones to be the input device, resulting in a drastic | |
-- decrease in sound quality, and making it mono | |
tell application "System Preferences" to activate | |
tell application "System Preferences" | |
reveal anchor "input" of pane id "com.apple.preference.sound" | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Lint any changed files using swiftlint. | |
# | |
# This works both independently and as a run phase script. | |
# Path to installed version of Swift lint. | |
readonly SWIFT_LINT_PATH=$(which swiftlint) | |
if [ -z "$SWIFT_LINT_PATH" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Xcode sometimes gets sad and won't index or other shenanigans. You can easily cheer up Xcode | |
# and get things happy again by simply removing some files. This little script does just that. | |
# Quit Xcode | |
osascript -e 'tell app "Xcode" to quit' | |
# Remove derived data | |
rm -rf ~/Library/Developer/Xcode/DerivedData/* |