Skip to content

Commit 1f3fe5b

Browse files
committed
Added list of changes over original implementation
1 parent d541340 commit 1f3fe5b

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

README-legacy.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,6 @@ InterposeKit can hook classes and object. Class hooking is similar to swizzling,
5858

5959
Caveat: Hooking will fail with an error if the object uses KVO. The KVO machinery is fragile and it's to easy to cause a crash. Using KVO after a hook was created is supported and will not cause issues.
6060

61-
## Various ways to define the signature
62-
63-
Next to using `methodSignature` and `hookSignature`, following variants to define the signature are also possible:
64-
65-
### methodSignature + casted block
66-
```
67-
let interposer = try Interpose(testObj) {
68-
try $0.hook(
69-
#selector(TestClass.sayHi),
70-
methodSignature: (@convention(c) (AnyObject, Selector) -> String).self) { store in { `self` in
71-
let string = store.original(`self`, store.selector)
72-
return string + testString
73-
} as @convention(block) (AnyObject) -> String }
74-
}
75-
```
76-
77-
### Define type via store object
78-
```
79-
// Functions need to be `@objc dynamic` to be hookable.
80-
let interposer = try Interpose(testObj) {
81-
try $0.hook(#selector(TestClass.returnInt)) { (store: TypedHook<@convention(c) (AnyObject, Selector) -> Int, @convention(block) (AnyObject) -> Int>) in {
82-
83-
// You're free to skip calling the original implementation.
84-
let int = store.original($0, store.selector)
85-
return int + returnIntOverrideOffset
86-
}
87-
}
88-
}
89-
```
90-
9161
## FAQ
9262

9363
### Why didn't you call it Interpose? "Kit" feels so old-school.

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,36 @@ This is a continuation and modernization of [Peter Steinberger’s original impl
2626
- arm64 and x86_64 architectures
2727
- Examples: instance method on class, class method on class, object
2828

29-
## Changes from [Original Implementation](https://github.com/steipete/InterposeKit)
29+
## What’s Changed
3030

31-
- ...
31+
Compared to the [original implementation](https://github.com/steipete/InterposeKit), this fork introduces several API and internal changes. Here is a summary of key differences with migration hints.
32+
33+
### Environment
34+
35+
- Switched the library to Swift Package Manager only. Carthage and CocoaPods support was removed.
36+
- Raised minimum Swift version to 5.9.
37+
- Limited to Apple platforms with arm64 and x86_64 architectures. Support for Linux was removed.
38+
39+
### API Changes
40+
41+
- Class hooks now support class methods.
42+
- Removed the builder-based API `Interpose(…) { … }` for applying hooks in batches. Each hook must now be individually prepared, applied, and reverted.
43+
- Signature types must now be specified via parameters, improving clarity and streamlining the API.
44+
- Renamed `hook(…)` methods to `applyHook(…)`.
45+
- Removed fluent-style `Hook` API, meaning that methods no longer return `self`.
46+
- Introduced `HookProxy`, which is passed into the hook builder. It still provides access to the original method implementation and selector, but hides irrelevant APIs like `revert()`.
47+
- Hook types now use composition instead of inheritance. The public `Hook` class delegates to internal strategies conforming to `HookStrategy`.
48+
- Object hooks now use a global counter instead of UUIDs for dynamic subclass names.
49+
- Dynamic subclasses created at runtime are now cleaned up when the last hook is reverted on an object.
50+
- Class hooks must now target the exact class that actually implements the method to ensure the revert functionality works correctly.
51+
- Added initial Swift 6 compatibility with some thread-safety checks. Most usage is still expected to be single-threaded, though.
52+
- Removed support for [delayed hooking](https://steipete.com/posts/mac-catalyst-crash-hunt/) (`whenAvailable(…)`) to keep the library laser-focused.
53+
- …and heavily refactored the Swift part of the codebase: cleaner use of Objective-C runtime APIs, a revamped `InterposeError` enum, and new supporting types like `HookScope` or `HookState`.
54+
55+
### Fixes
56+
57+
- Fixed a crash where `IKTAddSuperImplementationToClass` was stripped in release builds per [steipete/InterposeKit#29](https://github.com/steipete/InterposeKit#29) by using the fix from [steipete/InterposeKit#30](https://github.com/steipete/InterposeKit#30) submitted by @Thomvis, which replaces a call via dynamic library with a direct Swift call to `IKTSuperBuilder.addSuperInstanceMethod(to:selector:)`.
58+
- Fixed floating-point register handling on arm64 using the patch from [steipete/InterposeKit#37](https://github.com/steipete/InterposeKit#37) submitted by @ishutinvv, which resolves an issue affecting swizzled methods with `CGFloat` parameters or structs like `CGPoint` and `CGRect` due to floating-point registers not being restored in the correct order after the trampoline call.
3259

3360
## References
3461

0 commit comments

Comments
 (0)