# enable internal menu
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES
alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <mach-o/dyld.h> | |
#include <mach-o/nlist.h> | |
#include <mach-o/dyld_images.h> | |
#include <mach/mach_vm.h> | |
/* Dyld is the OSX Dynamic Linker | |
* /usr/include//mach-o/loader.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Decodable where Self: Encodable { | |
/// Creates a new instance and changes the value for the provided key. | |
/// | |
/// - Parameters: | |
/// - key: The key path to the property that you want to modify. | |
/// Use period to separate levels and [] for indexes. | |
/// Examples: "id", "name.firstName", "children[2].name.firstName" | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <execinfo.h> | |
typedef void (*cxa_throw_type)(void *, void *, void (*) (void *)); | |
cxa_throw_type orig_cxa_throw = 0; | |
void load_orig_throw_code() | |
{ | |
orig_cxa_throw = (cxa_throw_type) dlsym(RTLD_NEXT, "__cxa_throw"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension RangeReplaceableCollection { | |
static func += (collection: inout Self, element: Element) { | |
collection.append(element) | |
} | |
static func += (collection: inout Self, element: Element?) { | |
if let element = element { | |
collection.append(element) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Regex { | |
let pattern: String | |
let options: NSRegularExpressionOptions! | |
private var matcher: NSRegularExpression { | |
return NSRegularExpression(pattern: self.pattern, options: self.options, error: nil) | |
} | |
init(pattern: String, options: NSRegularExpressionOptions = nil) { | |
self.pattern = pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Singleton.h | |
------------- | |
@protocol Singleton | |
@optional | |
+ (instancetype)sharedInstance; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Darwin | |
extension Int { | |
static func random() -> Int { | |
return Int(arc4random()) | |
} | |
static func random(range: Range<Int>) -> Int { | |
return Int(arc4random_uniform(UInt32(range.endIndex - range.startIndex))) + range.startIndex | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> $PROJECT_DIR/merge.swift; find $PROJECT_DIR/ -iname *.swift -not -name merge.swift -exec cat {} >> $PROJECT_DIR/merge.swift \; |
Xcode loads xcspec files (ascii plists) that specify everything (tools, buildphases, compilers, rules, etc) based on a set of conditions.
To evaluate these conditions you have to load these files and simulate the build process and construct your own "environment"
The target's build settings will help to resolve most of the environment variables by taking the basics from the
particular platform you are using for the target (resolved from the SDKROOT value xcrun --show-sdk-platform-path --sdk
)
when you load the spec of the compiler there is a key on it called "Options" which is an array of dictionaries that have