Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created August 6, 2018 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuowei/dd2d2a9b905e4facd21b31502f2baca0 to your computer and use it in GitHub Desktop.
Save zhuowei/dd2d2a9b905e4facd21b31502f2baca0 to your computer and use it in GitHub Desktop.
// crashes Xcode 10 beta 4.
// the last line is supposed to error, not trigger a compiler segfault
import Foundation
import ObjectiveC
typealias BundleForClass_Type = @convention(c) (AnyClass, Selector, AnyClass) -> Bundle
private func AVTUIEnvironment_storeLocation_hook(bundleClass: AnyClass, selector: Selector) -> NSURL {
abort()
}
private func hookBundle() {
guard let method = class_getClassMethod(Bundle.self, Selector("bundleForClass:")) else {
fatalError("Can't find method")
}
method_setImplementation(method, unsafeBitCast(AVTUIEnvironment_storeLocation_hook as BundleForClass_Type, to: IMP.self))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment