Skip to content

Instantly share code, notes, and snippets.

View AlexKobachiJP's full-sized avatar

Alex Kovács AlexKobachiJP

View GitHub Profile
@AlexKobachiJP
AlexKobachiJP / Process+Run.swift
Created February 21, 2023 08:55
Creates a process and launches an exectuable with arguments.
// Copyright © 2022 Alex Kovács. All rights reserved.
#if os(macOS)
import Foundation
extension Process {
/// Creates a process and launches an exectuable with arguments.
///
@AlexKobachiJP
AlexKobachiJP / XcodeCommand
Last active June 1, 2024 20:26
Sort file and package references in an Xcode project.
// Copyright © 2023 Alex Kovács. All rights reserved.
import ArgumentParser
import Foundation
import PathKit
import XcodeProj
// See below for `MainCommand` skeleton.
extension MainCommand {
struct XcodeCommand: ParsableCommand {
@AlexKobachiJP
AlexKobachiJP / IDETemplateMacros.plist
Created February 17, 2023 21:39
Custom header for new files in Xcode. Edit the copyright string and put it in ~/Library/Developer/Xcode/UserData/.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string> Copyright © 2023 Alex Kovács. All rights reserved.</string>
</dict>
</plist>
@AlexKobachiJP
AlexKobachiJP / DebugLogsOnSimulator.swift
Created February 16, 2023 00:49
Fallback for Console.app not picking up debug/trace logs for simulator devices on macOS 13.2.1 (22D68)
// Copyright © 2023 Alex Kovács. All rights reserved.
#if targetEnvironment(simulator)
import OSLog
extension Logger {
/// Hack! Cannot get Console.app to pick up trace logs from simulator (as of macOS 13.2.1 (22D68)), so just falling
/// back to info level logs for debugging. This shadows the existing [Logger.trace()](https://developer.apple.com/documentation/os/logger/3551624-trace) function which
@AlexKobachiJP
AlexKobachiJP / EditMode.swift
Last active February 15, 2024 05:24
Reimplementation of SwiftUI EditMode enum for macOS
// Documentation comments are copied from the official documentation for iOS.
import SwiftUI
#if os(macOS)
/// Reimplemenation of [EditMode](https://developer.apple.com/documentation/swiftui/editmode) for macOS.
public enum EditMode {
/// The user can edit the view content.