Skip to content

Commit 86abddc

Browse files
committed
README: Various tweaks
1 parent 1f3fe5b commit 86abddc

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

README-legacy.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Instead of [adding new methods and exchanging implementations](https://nshipster.com/method-swizzling/) based on [`method_exchangeImplementations`](https://developer.apple.com/documentation/objectivec/1418769-method_exchangeimplementations), this library replaces the implementation directly using [`class_replaceMethod`](https://developer.apple.com/documentation/objectivec/1418677-class_replacemethod). This avoids some of [the usual problems with swizzling](https://pspdfkit.com/blog/2019/swizzling-in-swift/).
2-
31
## Usage
42

53
Let's say you want to amend `sayHi` from `TestClass`:

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# InterposeKit
22

3-
[![CI](https://github.com/structuredpath/InterposeKit/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/structuredpath/InterposeKit/actions/workflows/ci.yml) ![Xcode 15+](https://img.shields.io/badge/Xcode-15%2B-blue.svg) ![Swift 5.9+](https://img.shields.io/badge/Swift-5.9%2B-orange.svg)
3+
[![CI](https://github.com/structuredpath/InterposeKit/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/structuredpath/InterposeKit/actions/workflows/ci.yml) ![Swift 5.9+](https://img.shields.io/badge/Swift-5.9%2B-orange.svg) ![Xcode 15+](https://img.shields.io/badge/Xcode-15%2B-blue.svg)
44

55
**InterposeKit** is a modern library for hooking Objective-C methods in Swift, also known as method swizzling. It supports both class-based and object-based hooks and it provides a clean, block-based, Swift-friendly API.
66

77
This is a continuation and modernization of [Peter Steinberger’s original implementation](https://github.com/steipete/InterposeKit). For the background on why and how this revamp came about, see [my blog post](#). If you’re migrating, check out [what’s changed](#).
88

99
## Key Features
1010

11-
- Swift-friendly, minimal, thread-safe API.
11+
- Swift-friendly, modern, and minimal API.
1212
- Block-based hooks targeting both classes and individual objects.
1313
- Support for both instance and class methods.
1414
- Hooks get access to the original implementation via a proxy.
@@ -19,12 +19,25 @@ This is a continuation and modernization of [Peter Steinberger’s original impl
1919
- There’s no runtime type checking, and the signature has to be written twice—a trade-off to avoid `NSInvocation`.
2020
- Written almost entirely in Swift on top of the Objective-C runtime[^2].
2121

22-
## Getting Started
22+
## Installation
2323

2424
- Installation Swift Package Manager
2525
- Swift 5.9+, Xcode 15+
2626
- arm64 and x86_64 architectures
27-
- Examples: instance method on class, class method on class, object
27+
28+
## Usage
29+
30+
### Class Hook: Instance Method
31+
32+
33+
34+
### Class Hook: Class Method
35+
36+
37+
38+
### Object Hook
39+
40+
2841

2942
## What’s Changed
3043

@@ -48,14 +61,14 @@ Compared to the [original implementation](https://github.com/steipete/InterposeK
4861
- Object hooks now use a global counter instead of UUIDs for dynamic subclass names.
4962
- Dynamic subclasses created at runtime are now cleaned up when the last hook is reverted on an object.
5063
- 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.
64+
- Added initial Swift 6 support with basic concurrency checks. Should be thread-safe, but most usage is still expected to be single-threaded.
5265
- Removed support for [delayed hooking](https://steipete.com/posts/mac-catalyst-crash-hunt/) (`whenAvailable(…)`) to keep the library laser-focused.
5366
- …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`.
5467

5568
### Fixes
5669

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.
70+
- Fixed a crash where `IKTAddSuperImplementationToClass` was stripped in release builds per [steipete/InterposeKit#29](https://github.com/steipete/InterposeKit/issues/29) by using the fix from [steipete/InterposeKit#30](https://github.com/steipete/InterposeKit/issues/30) submitted by @Thomvis, which replaces a call via dynamic library with a direct Swift call to `IKTSuperBuilder.addSuperInstanceMethod(to:selector:)`.
71+
- Fixed floating-point register handling on arm64 using the patch from [steipete/InterposeKit#37](https://github.com/steipete/InterposeKit/issues/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.
5972

6073
## References
6174

0 commit comments

Comments
 (0)