Skip to content

Instantly share code, notes, and snippets.

View NSExceptional's full-sized avatar

Tanner Bennett NSExceptional

View GitHub Profile
@NSExceptional
NSExceptional / MSHookFunction_example.xm
Last active March 12, 2018 21:17
Demonstrates how to hook methods with MSHookFunction.
// Typical tweak
%hook UIView
- (UIColor *)backgroundColor {
return [UIColor blackColor];
}
%end
@NSExceptional
NSExceptional / HomeButtonX.xm
Last active May 1, 2018 02:40
A tweak to enable 3D Touch on the home bar to go home
#import <objc/runtime.h>
#define simulateHomePress() [(SpringBoard *)[UIApplication sharedApplication] _simulateHomeButtonPress]
@interface SpringBoard : UIApplication
- (void)_simulateHomeButtonPress;
@end
static UITapGestureRecognizer *bounceTap = nil;
%subclass TBHomeBarTapGestureRecognizer : UITapGestureRecognizer

iOS Shared Cache Extraction

Having fallen off the iOS-exploration train due to completing my Masters and other commitments, I have finally climbed back aboard in pursuit of understanding the telephony stack.

Like most things in iOS that are used frequently, the vast majority of the frameworks and libraries used in the telephony stack reside in the DYLD shared cache located at /System/Library/Caches/com.apple.dyld/dyld_shared_cache_armv7.

In this post I am going to explain how to go about extracting this cache file so that you can then work with each library individually.

Get The Cache

The first step in all of this is to copy the cache over to your local machine. I did this using a program called iExplorer, but you can just as easily do it over SSH. As a side note, you can connect to your iDevice using SSH over USB if you install a tool called iProxy.

@NSExceptional
NSExceptional / NoImgurRedirect.xm
Created October 10, 2018 18:42
Tweak to prevent i.imgur.com redirecting to m.imgur.com
//
// Tweak.xm
// NoImgurRedirect
//
// Created by Tanner Bennett on 2018-10-10
// Copyright © 2018 Tanner Bennett. All rights reserved.
//
static NSString * const kTargetHost = @"i.imgur.com";
static NSString * const kUserAgentField = @"User-Agent";
@NSExceptional
NSExceptional / String+Sensible.swift
Created March 4, 2019 04:48
Sensible Swift snippets
extension String {
var length: Int {
return self.lengthOfBytes(using: .utf8)
}
subscript(index: String.Index) -> Character {
get { return self.characters[index] }
set {
self.remove(at: index)
self.insert(newValue, at: index)
@NSExceptional
NSExceptional / AppStoreOligopoly.md
Last active March 18, 2019 15:56
Common questions and arguments against App Store regulation

App Store Oligopoly FAQ

Apple and the App Store desperately need regulation. The "why" is outlined below, and I'll briefly describe the "how" right now. There are two proposed solutions:

  1. Apple is forced to allow competition in the form of alternative app stores. This would effectively be "GateKeeper for iOS" which would give developers an avenue to distribute their own apps from Safari as well, similar to how software is distributed on computers. Ideally a CA would emerge to distribute certificates for developers to use so that users could trust apps on a per-developer basis. This "GateKeeper" would have settings similar to those on macOS, with the default state being "Only allow apps from the App Store," and another option "Only allow apps from Trusted developers." It would obviously have a setting under Parental Controls as well.
  2. The App Store becomes regulated by some government body, either by antitrust laws being passed or by direct oversight. Antitrust laws are what will lead to #1 anyway.

@NSExceptional
NSExceptional / Composition.swift
Created April 4, 2019 21:28
A demonstration of a use case where inheritance is preferred to composition.
protocol Mammal {
var age: Int { get set }
var offspring: Int { get set }
func grow()
func reproduce() -> Self
}
protocol Person: Mammal {
var name: String { get }
@NSExceptional
NSExceptional / dark-reader.json
Last active August 20, 2021 19:53
Manually get and set settings with "Inspect popup" console on the extension
{
"applyToListedOnly": false,
"automation": "",
"changeBrowserTheme": false,
"customThemes": [
{
"theme": {
"brightness": 100,
"contrast": 80,
"darkSchemeBackgroundColor": "#181a1b",
@NSExceptional
NSExceptional / ClearRunDestinations.applescript
Last active November 27, 2019 15:50
A simple AppleScript to uncheck "show as run destination" for every device. Open the Devices window first.
activate application "Xcode"
tell application "System Events"
tell process "Xcode"
tell window "Devices"
set deviceList to outline 1 of scroll area 1 of splitter group 1 of group 1
set details to scroll area 1 of splitter group 1 of splitter group 1 of group 1
repeat with r in row of deviceList
select r
-- Uncheck all "Show as run destination" boxes
tell checkbox 1 of details to if value is 1 then click
@NSExceptional
NSExceptional / StudentLoanDefaultGuide.md
Created January 14, 2020 02:46
Student Loan Default: The Guide

The original guide that was recently deleted here: https://www.reddit.com/r/studentloandefaulters/comments/cg1fd7/student_loan_default_a_guide/

I take no credit for this post, just happened to have it saved in a document and thought I'd be doing an injustice by not sharing this information once I saw the original post was missing! All credit goes to the original author, and without further ado...

Student Loan Default: A Guide

I’ve been wanting to write this for a long time, and seeing that person be in $500,000 of debt and no one really helping him on r/studentloans, I felt it was time to summarize everything I’ve learned. While there is great information on this sub, it is not centralized. It requires some digging. I hope now to bring all of it to the surface.