InjectionIII icon indicating copy to clipboard operation
InjectionIII copied to clipboard

How to make the present VC display normally.

Open RisingSSR opened this issue 5 months ago • 2 comments

Device: real device - iPhone 15 Xcode: 16.2 Code:

@_exported import InjectHotReload

class MMWindow: UIWindow {
    
    override var rootViewController: UIViewController? {
        get { super.rootViewController }
        set {
            if let newValue {
//                  super.rootViewController = newValue
                super.rootViewController = InjectHotReload.ViewControllerHost(newValue)
            } else {
                super.rootViewController = nil
            }
        }
    }
    
    override func makeKeyAndVisible() {
        super.makeKeyAndVisible()
        
        do {
            // simulatorBundle
//            let simulatorBundle = Bundle.init(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")
//            if let bundle = simulatorBundle {
//                try bundle.loadAndReturnError()
//                debugPrint("Injection simulator Bundle成功")
//            } else {
//                debugPrint("Injection simulator 注入失败,未能检测到Injection")
//            }
            
            // realDeviceBundlePath
            if let realDeviceBundlePath = Bundle.main.path(forResource: "iOSInjection", ofType: "bundle"), let realDeviceBundle = Bundle(path: realDeviceBundlePath) {
                try realDeviceBundle.loadAndReturnError()
                debugPrint("Injection RealDevice Bundle成功")
            } else {
                debugPrint("Injection RealDevice 注失败,未能检测到Injection")
            }
        } catch {
            debugPrint("Injection注入失败\(error)")
        }
    }
}

then, when i present another vc, it cannot works

I think it's the UITransitionView that's causing the problem

Image

so how can i works

RisingSSR avatar Jul 18 '25 03:07 RisingSSR

@krzysztofzablocki, is this more of an Inject question?

johnno1962 avatar Jul 18 '25 06:07 johnno1962

This is never going to work properly, hosts are set-up with auto closure per documentation, if you set it up via value you simply re-assign existing instance and not re-initialize it

krzysztofzablocki avatar Jul 18 '25 06:07 krzysztofzablocki