Code Monkey home page Code Monkey logo

Comments (7)

johnno1962 avatar johnno1962 commented on June 12, 2024

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 class_copyMethodList().

from hotreloading.

qmkCamel avatar qmkCamel commented on June 12, 2024

Yes, it's on device. Here is the demo. You can check the DemoViewController+Debug.
I debug the HotReloading, and found it may not because of the class_copyMethodList().
The below function return [], so it didn't execute the following code.

@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
    }

hot_reload_demo 2.zip

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

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.

from hotreloading.

qmkCamel avatar qmkCamel commented on June 12, 2024

For more information, I use the build phase to trigger InjectionServer instead of the InjectionIII App on the github. If I inject in a category DemoViewController+Debug, can't get a class like beblow.
image
What else can I provide to help confirm the case?

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

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

from hotreloading.

qmkCamel avatar qmkCamel commented on June 12, 2024

Got it, I was misled by the following message 😅.
🔥 ⚠️ Injection may have failed. Have you added -Xlinker -interposable to the "Other Linker Flags" of the executable/framework? ⚠️
Thanks for your patience.

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

Nothing is worse than a bogus message... I've pushed a commit which should silence it when there are categories present.

from hotreloading.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.