Skip to content

Instantly share code, notes, and snippets.

View WiesnerPeti's full-sized avatar

Peter Adam Wiesner WiesnerPeti

View GitHub Profile
@WiesnerPeti
WiesnerPeti / desymb.sh
Last active October 21, 2020 12:35
Desymbolicate Crash
#Prerequisites
#- APP_NAME.app is in PWD folder
#- APP_NAME.app.dSYM is in PWD folder
#Thread 4 Crashed:: [...]
#0 YOUR_BUNDLE_ID 0x0 0x01 + 1234
LOAD_ADDRESS=0x01
SYMBOL_ADDRESS=0x0
#OR
@WiesnerPeti
WiesnerPeti / Stringify_OTHERLDFLAGS_Hash.rb
Created January 3, 2020 12:51
Stringify XCCONFIG other linker flags hashmap
#Helper to stringify OTHER_LDFLAGS content
def stringFromhash(hash)
items = hash.reduce([]) do |sum,(key,val)|
if key == :simple
sum += val.to_a.map{ |i| "#{i}"}
elsif key == :frameworks
sum += val.to_a.map{ |i| "-framework \"#{i}\""}
elsif key == :weak_frameworks
sum += val.to_a.map{ |i| "-weak_framework \"#{i}\""}
elsif key == :libraries
@WiesnerPeti
WiesnerPeti / PodPostInstall.rb
Last active January 3, 2020 12:45
Pod Post install hook to modify linker flags and framework search attributes
post_install do |installer|
installer.aggregate_targets.each do |aggregate_target|
if aggregate_target.name == "YOUR_TARGET"
aggregate_target.xcconfigs.each do |config_name, config_file|
#Example to get and set attributes
frameworkSearchPaths = config_file.attributes["FRAMEWORK_SEARCH_PATHS"]
config_file.attributes["FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]"] = frameworkSearchPaths
#Example to delete attributes
@WiesnerPeti
WiesnerPeti / Pod Licenses.sh
Created January 3, 2020 12:38
Extracting license type from pods
#!/bin/bash
#Works only for single-row type license parameters in pod spec
for i in {list of pod names space separated}; do pod spec cat $i ;done | grep license
@WiesnerPeti
WiesnerPeti / DictionaryExtension.swift
Last active January 3, 2020 12:35
Convert String-keyed dictionary to RawRepresentable-Enum-keyed dictionary
extension Dictionary where Key == String {
//Generic method to convert the dictionary [String:Any] dict to a specific [enum String:Any] dict
func enumDict<R:RawRepresentable>(as type:R.Type) -> [R:Any] where R.RawValue == String {
var dict:[R:Any] = [:]
self.forEach{
guard let k = R.init(rawValue: $0.key) else {return}
dict[k] = $0.value
}
return dict
}
@WiesnerPeti
WiesnerPeti / DebuggerCheck.swift
Created January 3, 2020 11:06
iOS Swift Check if debugger is attached
func debuggerAttached() -> Bool {
var process_info:kinfo_proc = kinfo_proc()
var process_info_len:size_t = MemoryLayout<kinfo_proc>.size
var process_info_mib:[Int32] = [
CTL_KERN,
KERN_PROC,
KERN_PROC_PID,
getpid()
];