Click to toggle contents of `code`
CODE!
| // | |
| // ColorSchemeApp.swift | |
| // ColorScheme | |
| // | |
| // Created by Craig Hockenberry on 9/11/24. | |
| // | |
| import SwiftUI | |
| @main |
| extension StringProtocol { | |
| /// str[NSRange(location:0, length: 9)] | |
| subscript(_ range: NSRange) -> SubSequence { | |
| guard let stringRange = Range<String.Index>(range, in: self) else { | |
| fatalError("String index is out of range") | |
| } | |
| return self[stringRange] | |
| } | |
| import SwiftUI | |
| struct XForm <Content>: View where Content: View { | |
| let content: Content | |
| init(@ViewBuilder content: () -> Content) { | |
| self.content = content() | |
| } | |
| var body: some View { |
| /* | |
| During Dark Mode migration for macOS, I found it helpful to have a global hotkey | |
| which toggled between Light/Dark Mode. | |
| This hack attempts to do something similar for iOS. | |
| 1) Add your main window in -applicationDidFinishLaunching: | |
| 2) Triple tap the window (I tend to do this near the title bar) to flip between light and dark. | |
| */ |
| #!/bin/bash | |
| # Exit the script immediately on error | |
| set -e | |
| # We'll work in /tmp | |
| cd /tmp | |
| # Clone mach_override unless we already have it | |
| if [ ! -d mach_override ]; then |
| // Created by Caleb Davenport on 7/14/17. | |
| import UIKit | |
| final class ActionSheetPresentationController: UIPresentationController { | |
| // MARK: - Properties | |
| private var dimmingView: UIView! | |
| /** | |
| * Perform a throwing expression, and throw a custom error in case the expression threw | |
| * | |
| * - parameter expression: The expression to execute | |
| * - parameter error: The custom error to throw instead of the expression's error | |
| * - throws: The given error | |
| * - returns: The return value of the given expression | |
| */ | |
| func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T { | |
| do { |
| call ((NSWindow *)[(NSArray *)[[NSApplication sharedApplication] windows] lastObject]).collectionBehavior = 1<<7|1<<8|1<<11 |
CODE!
| # 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) |