Skip to content

Instantly share code, notes, and snippets.

@kam800
kam800 / pbxproj_unused_files.rb
Created January 19, 2015 09:07
Prints files that where not added to all xcode targets given in parameter
#
# pbxproj_unused_files.rb
# v.1.0.0
#
# Copyright (c) 2015 Kamil Borzym
# Released under the MIT License
#
require 'rubygems'
require 'json'
@kam800
kam800 / TWTRGenericKeychainItem.m
Created January 20, 2016 08:53
Override TwitterKit keychain kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlock
@import Foundation;
#import <objc/runtime.h>
@interface TWTRGenericKeychainItem: NSObject
- (NSMutableDictionary *)fullRawRepresentation;
@end
@interface TWTRGenericKeychainItem (KeychainFix)
@end
var results = new(id)
var query = @{ kSecReturnAttributes : kCFBooleanTrue,
kSecMatchLimit: kSecMatchLimitAll,
kSecClass: kSecClassGenericPassword,
kSecReturnData: kCFBooleanTrue }
SecItemCopyMatching(query, results)
var r = *results
import Foundation
public extension Bundle {
private final class Marker {}
// Looking for bundle involves a lot of IO
private static let cache: NSCache<NSString, Bundle> = NSCache<NSString, Bundle>()
public static func resourcesBundle(forModuleName moduleName: String) -> Bundle {
#!/bin/bash
source_framework_path="$1"
target_bundle_dir="$2"
framework_name="$(basename "${source_framework_path}")"
module_name="$(basename -s .framework "${framework_name}")"
bundle_name="${module_name}.bundle"
target_bundle_path="${target_bundle_dir}/${bundle_name}"
print_usage() {
#!/bin/bash
# This script checks the binary and all nested frameworks for duplicated classes (both ObjectiveC and Swift).
# The script fails if it finds any duplicated classes.
function print_classes() {
otool -ov "$1" |
sed -n '/Contents of (__DATA,__objc_classlist)/,/Contents of/p' | # all lines for (__DATA,__objc_classlist) section
egrep '^[0-9]' | # take just a class header
cut -d ' ' -f 3 | # take just a symbol name
# This snippet shows how to enable dyld `closured` and how to fix `read` implementation in dyld using lldb.
# Following text is a bash/lldb command mix and it contains the relevant stdout content and my comments.
// `DYLD_PRINT_WARNINGS=1` environment variable will print dyld logs
$ DYLD_PRINT_WARNINGS=1 lldb /Users/kamil.borzym/tmp/TestMacApp.app/Contents/MacOS/TestMacApp
(lldb) process launch --stop-at-entry
(lldb) image list
[ 0] D355CCB5-8584-33E3-8DF7-7BA95BAD41AF 0x0000000100000000 /Users/kamil.borzym/tmp/TestMacApp.app/Contents/MacOS/TestMacApp
@kam800
kam800 / IDETemplateMacros.plist
Created September 2, 2018 21:48
xcshareddata/IDETemplateMacros.plist
<?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___</string>
<key>FILEHEADER_comment</key>
<string>FILEHEADER is the text placed at the top of every new text file. It can be overridden, but can not be removed.</string>
</dict>
</plist>