Skip to content

Commit 0d00f0d

Browse files
committed
Get the original implementation before replacement
1 parent 6eef7be commit 0d00f0d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/InterposeKit/ClassHook.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ extension Interpose {
1111

1212
override func replaceImplementation() throws {
1313
let method = try validate()
14-
origIMP = class_replaceMethod(`class`, selector, replacementIMP, method_getTypeEncoding(method))
14+
let _origIMP = class_getMethodImplementation(`class`, selector)
15+
origIMP = class_replaceMethod(`class`, selector, replacementIMP, method_getTypeEncoding(method)) ?? _origIMP
1516
guard origIMP != nil else { throw InterposeError.nonExistingImplementation(`class`, selector) }
1617
Interpose.log("Swizzled -[\(`class`).\(selector)] IMP: \(origIMP!) -> \(replacementIMP!)")
1718
}

0 commit comments

Comments
 (0)