Skip to content

Instantly share code, notes, and snippets.

View seanlabastille's full-sized avatar

Seán Labastille seanlabastille

View GitHub Profile
@seanlabastille
seanlabastille / OSLogStoreTestApp.swift
Last active July 28, 2021 07:07
Test App for reading the current process OSLogStore — updated for iOS 15 Beta 4
import SwiftUI
import OSLog
@main
struct LogReaderApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
@seanlabastille
seanlabastille / LogReader.swift
Created July 8, 2020 09:47
Attempting to read OSLogStore in iOS 14 Beta 2
import OSLog
class LogReader: ObservableObject {
var log: OSLogStore
init?() {
do {
log = try OSLogStore.init(scope: .currentProcessIdentifier)
dump(log)
/*
@seanlabastille
seanlabastille / ClearPermission.swift
Last active March 5, 2021 01:26
Clear a simulator permission entry by adjusting the TCC database and killing the simulator's tccd
import Cocoa
func getBootedSimulatorTCCDBPath() -> String {
let getBundlePath = Process()
let outputPipe = Pipe()
getBundlePath.standardOutput = outputPipe
getBundlePath.executableURL = URL(fileURLWithPath: "/usr/bin/xcrun")
getBundlePath.arguments = ["simctl", "get_app_container", "booted", "sean.systems.SimpleUITest"]
getBundlePath.launch()
getBundlePath.waitUntilExit()
@seanlabastille
seanlabastille / SwiftPlaygroundiPadRuntimeSpelunking.swift
Created January 19, 2019 06:19
Runtime Spelunking with Swift Playgrounds on iPad: Using Bundle.didLoadNotification to see what goodies a private framework contains
import ObjectiveC
import PlaygroundSupport
import Foundation
var loadedClasses = [String]()
NotificationCenter.default.addObserver(forName: Bundle.didLoadNotification, object: nil, queue: nil, using: { (n) in
let classes = n.userInfo?[NSLoadedClasses] as! [String]
loadedClasses.append(contentsOf: classes)
loadedClasses.sort()
@seanlabastille
seanlabastille / MPRemoteCommandCenter.swift
Created January 10, 2017 10:46
MPRemoteCommandCenter logging
//: Playground - noun: a place where people can play
import Cocoa
import MediaPlayer
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
if #available(OSX 10.12.2, *) {
let centre = MPRemoteCommandCenter.shared()
import AVFoundation
import WebKit
import PlaygroundSupport
let playbackRate = 1.7
let session = "417"
let userScript = WKUserScript(source: "document.querySelector('video').playbackRate = \(playbackRate);", injectionTime: .atDocumentEnd, forMainFrameOnly: true)
@seanlabastille
seanlabastille / EnumConundrum.swift
Created October 22, 2015 13:49
A curious issue when attempting use an enum case as a dictionary subscript.
//: Enums and Dictionaries: how do they work?
import Foundation
enum Enum {
case A
case B
}
class O: NSObject {}
Sep 22 18:38:20 Bane-of-TXL pkd[116] <Warning>: assigning plug-in com.pcalc.mobile.watchkitapp.watchkitextension(3.5) to plugin sandbox
Sep 22 18:38:20 Bane-of-TXL pkd[116] <Warning>: enabling pid=100 for plug-in com.pcalc.mobile.watchkitapp.watchkitextension(3.5) 4D89534E-38B4-4DA9-927E-BC916E3036A4 /private/var/mobile/Containers/Bundle/Application/DB2AC5B3-2F01-4DA5-811F-B214DA74CEA0/PCalc WatchKit App.app/PlugIns/PCalc WatchKit Extension.appex
Sep 22 18:38:20 Bane-of-TXL kernel[0] <Notice>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42004
Sep 22 18:38:20 Bane-of-TXL com.apple.xpc.launchd[1] (com.pcalc.mobile.watchkitapp.watchkitextension[707]) <Warning>: FairPlay decryption failed on binary.
Sep 22 18:38:20 Bane-of-TXL gizmoappd[100] <Warning>: plugin com.pcalc.mobile.watchkitapp.watchkitextension interrupted
@seanlabastille
seanlabastille / gist:bc92115018a50a62a681
Last active August 29, 2015 14:14
Open file in Xcode at a given line and give it a hand scrolling to the right position
xed -l 42 file && osascript << SCRIPT
tell application "Xcode-Beta"
activate
end tell
tell application "System Events"
tell application process "Xcode"
click menu item "Jump to Selection" of menu "Navigate" of menu bar 1
end tell
end tell