Skip to content

Commit ce814e9

Browse files
committed
README: Finalized the Q&A section
1 parent 9060cd6 commit ce814e9

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

README-legacy.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ InterposeKit can hook classes and object. Class hooking is similar to swizzling,
1818

1919
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.
2020

21-
## FAQ
22-
23-
### Why didn't you call it Interpose? "Kit" feels so old-school.
24-
Naming it Interpose was the plan, but then [SR-898](https://bugs.swift.org/browse/SR-898) came. While having a class with the same name as the module works [in most cases](https://forums.swift.org/t/frameworkname-is-not-a-member-type-of-frameworkname-errors-inside-swiftinterface/28962), [this breaks](https://twitter.com/BalestraPatrick/status/1260928023357878273) when you enable build-for-distribution. There's some [discussion](https://forums.swift.org/t/pitch-fully-qualified-name-syntax/28482/81) to get that fixed, but this will be more towards end of 2020, if even.
25-
26-
### I want to hook into Swift! You made another ObjC swizzle thingy, why?
27-
UIKit and AppKit won't go away, and the bugs won't go away either. I see this as a rarely-needed instrument to fix system-level issues. There are ways to do some of that in Swift, but that's a separate (and much more difficult!) project. (See [Dynamic function replacement #20333](https://github.com/apple/swift/pull/20333) aka `@_dynamicReplacement` for details.)
28-
29-
### Can I ship this?
30-
Yes, absolutely. The goal for this one project is a simple library that doesn't try to be too smart. I did this in [Aspects](https://github.com/steipete/Aspects) and while I loved this to no end, it's problematic and can cause side-effects with other code that tries to be clever. InterposeKit is boring, so you don't have to worry about conditions like "We added New Relic to our app and now [your thing crashes](https://github.com/steipete/Aspects/issues/21)".
31-
3221
## Improvement Ideas
3322

3423
- Write proposal to allow to [convert the calling convention of existing types](https://twitter.com/steipete/status/1266799174563041282?s=21).

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,28 @@ Compared to the [original implementation](https://github.com/steipete/InterposeK
153153

154154
## Q&A
155155

156-
### Why did Peter call it InterposeKit?
156+
### Why is it called InterposeKit?
157+
158+
Peter originally wanted to go with _Interpose_, but [Swift had (and still has) a bug](https://github.com/swiftlang/swift/issues/43510) where using the same name for a module and a type can break things in certain scenarios.
159+
157160
### Why another Objective-C swizzling library?
158-
### Can I hook Swift methods? And what about pure C functions?
159161

160-
No. Peter had plans to experiment with [Swift method hooking](https://github.com/rodionovd/SWRoute) and hooking C functions via [`dyld_dynamic_interpose`](https://twitter.com/steipete/status/1258482647933870080), but neither made it into the library. And honestly, it doesn’t really fit the scope of this library anyway.
162+
UIKit, AppKit, and other system frameworks written in Objective-C won’t go away and sometimes you still need to swizzle to fix bugs or tweak internal behavior. InterposeKit is meant as a rarely-needed tool for these cases, providing a simple, Swift-friendly API.
161163

162164
### What the fork?
165+
166+
This version of InterposeKit started as a fork of [Peter Steinberger’s original library](https://github.com/steipete/InterposeKit) but has since evolved into a significantly reworked and modernized version. The core ideas and underlying runtime techniques remain, but large parts of the Swift codebase were restructured and rewritten. <!-- To learn more about my motivation, see [my blog post](#). -->
167+
168+
### Can I hook Swift methods? And what about pure C functions?
169+
170+
No. Peter had plans to experiment with [Swift method hooking](https://github.com/rodionovd/SWRoute), [Swift dynamic function replacement](https://github.com/swiftlang/swift/pull/20333), and hooking C functions via [`dyld_dynamic_interpose`](https://twitter.com/steipete/status/1258482647933870080), but none made it into the library. And honestly, it doesn’t really fit the scope of this library anyway.
171+
163172
### Can I ship this?
164173

174+
Modifying the internal behavior of system frameworks always carries risks. You should know what you’re doing, use defensive programming techniques, and assume that future OS updates might break your hooks.
175+
176+
That said, InterposeKit is designed to be safe for production use. It includes guardrails that verify method state before applying or reverting hooks, helping catch unexpected conditions early. The focus is on simplicity and predictability, avoiding clever tricks that could introduce hidden side effects.
177+
165178
## Improvement Ideas
166179

167180
- Support for hooking KVO-enabled objects

0 commit comments

Comments
 (0)