-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class category injection failed on device #72
Comments
Ha, It's a known potential issue, the category would be in a separate file from the class right? Is this on device? If you roll me a small example project I can look at it for you. There should be a way if you think it's important. I'm a little surprised the category methods aren't returned by |
Yes, it's on device. Here is the demo. You can check the @objc override open func extractClasses(dl: UnsafeMutableRawPointer,
tmpfile: String) throws -> [AnyClass] {
var classes = [AnyClass]()
SwiftTrace.forAllClasses(bundlePath: searchLastLoaded()) {
aClass, stop in
classes.append(aClass)
}
if classes.count > 0 && !SwiftTrace.deviceInjection {
print("\(APP_PREFIX)Loaded .dylib - Ignore any duplicate class warning ⬆️")
}
return classes
} |
Thanks for the project but there is something odd about it which I can't figure out and be able to debug it. Anyways.. Are you absolutely sure categories aren't injecting? When you load a category the new implementation is always updated on the class, in fact, this is how the very original version of injection worked. The injection code doesn't need to do anything. |
You won't get the class but categories inject automatically themselves as part of being dynamically loaded. Edit the print message in your category and verify if it is being updated when you call it (it was for me in my test project). Injection has to swizzle classes as there can be instances outstanding on the class with their own "isa" pointing to the oldClass.. |
Got it, I was misled by the following message 😅. |
Nothing is worse than a bogus message... I've pushed a commit which should silence it when there are categories present. |
When I inject in a class category, found it couldn't get a class in
func extractClasses
.So, is this a known issue?
Or it isn't a recommend way?
The text was updated successfully, but these errors were encountered: