Created
August 6, 2018 23:00
-
-
Save zhuowei/dd2d2a9b905e4facd21b31502f2baca0 to your computer and use it in GitHub Desktop.
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
// 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