FishHook is a lightweight, pure-Swift library that enables dynamically rebinding symbols in Mach-O binaries running on iOS in the simulator and on device. This project is heavily inspired by the popular fishhook.
typealias NewPrintf = @convention(thin) (String, Any...) -> Void
func newPrinf(str: String, arg: Any...) -> Void {
print("test success")
}
public func fishhookPrint(newMethod: UnsafeMutableRawPointer) {
var oldMethod: UnsafeMutableRawPointer?
rebindSymbol("printf", replacement: newMethod, replaced: &oldMethod)
}
fishhookPrint(newMethod: unsafeBitCast(newPrinf as NewPrintf, to: UnsafeMutableRawPointer.self))
- iOS 8.0+
- Swift 4.0-5.x
Add the following line to your Cartfile
git "https://github.com/woshiccm/FishHook.git" "master"
Aspect is released under the MIT license. See LICENSE for details.