Skip to content

Instantly share code, notes, and snippets.

View NSExceptional's full-sized avatar

Tanner Bennett NSExceptional

View GitHub Profile
@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 / 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 / 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 / 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";

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 / 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
@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 / CodeSignIPA.sh
Last active November 8, 2017 23:39
A bash function to re-sign an IPA and optionally change its bundle ID.
# Code sign an IPA
# Usage: csipa [-e entitlements -i identity -b newBundleID] <path to IPA>
csipa() {
# Create temp directory
if [[ ! -d /tmp/csipa ]]; then
mkdir /tmp/csipa
fi
# Default variable values
local ipaPath=
//
// SwiftMetadata.h
// Swift Test
//
// Created by Tanner on 10/28/17.
// Copyright © 2017 Tanner Bennett. All rights reserved.
//
#import <Foundation/Foundation.h>
@NSExceptional
NSExceptional / ObjcSimulator.swift
Created October 19, 2017 20:42
A small Objective-C-like simulation in Swift.
//
// main.swift
//
// Created by Tanner Bennett on 10/19/17.
// Copyright © 2017 Tanner Bennett. All rights reserved.
//
import Foundation
// For shorthand casting