LifetimeTracker icon indicating copy to clipboard operation
LifetimeTracker copied to clipboard

Not displaying

Open elemanhillary-zz opened this issue 4 years ago • 6 comments

I set it up like below

#if DEBUG
	LifetimeTracker.setup(onUpdate: LifetimeTrackerDashboardIntegration(visibility: .alwaysVisible, style: .bar).refreshUI)
#endif

and its not working

elemanhillary-zz avatar Oct 26 '20 19:10 elemanhillary-zz

Me too!

plusend avatar Oct 29 '20 09:10 plusend

+1

moo611 avatar Nov 29 '20 03:11 moo611

iOS/Xcode version?

krzysztofzablocki avatar Nov 29 '20 07:11 krzysztofzablocki

Xcode 12.2

On Sun, 29 Nov 2020 at 10:52 AM Krzysztof Zabłocki [email protected] wrote:

iOS/Xcode version?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/krzysztofzablocki/LifetimeTracker/issues/66#issuecomment-735357312, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM4W6MFQZTRBQ6HEYBSBPLSSH4TTANCNFSM4S7Z3F4Q .

elemanhillary-zz avatar Nov 29 '20 09:11 elemanhillary-zz

Did you implement LifetimeTrackable at least once ? It doesn't show if you don't have any LifetimeTrackable

ajacquelin avatar Feb 13 '21 22:02 ajacquelin

+1

mickaelhero avatar Apr 10 '22 10:04 mickaelhero

+1 I've implemented LifetimeTrackable and setup lifetimeConfiguration and it still doesn't show up.

PinYuanChen avatar Jan 04 '23 09:01 PinYuanChen

a sample app where it doesn't work would help, are you causing a leak? in default mode it only shows when you do

krzysztofzablocki avatar Jan 04 '23 10:01 krzysztofzablocki

My Xcode version is 14.1 and I use pods 1.8.1 I have added the integration code in SceneDelegate:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        
        guard let windowScene = (scene as? UIWindowScene) else { return }
        let window = UIWindow(windowScene: windowScene)
        let viewController = ViewController()
        window.rootViewController = viewController
        self.window = window
        #if DEBUG
        LifetimeTracker.setup( onUpdate: LifetimeTrackerDashboardIntegration(visibility: .alwaysVisible,style: .bar).refreshUI)
        #endif
        window.makeKeyAndVisible()
    }

I add a button on my ViewController to create leaks

class ViewController: UIViewController, LifetimeTrackable {
    static var lifetimeConfiguration: LifetimeConfiguration {
        return LifetimeConfiguration(maxCount: 1, groupName: "VC")
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        trackLifetime()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        trackLifetime()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        addButton()
    }
    
    func addButton() {
        button.setTitle("Create Leaks", for: .normal)
        button.addTarget(self, action: #selector(createLeaks), for: .touchUpInside)
        view.addSubview(button)
        button.snp.makeConstraints {
            $0.width.equalTo(100)
            $0.height.equalTo(20)
            $0.center.equalToSuperview()
        }
    }
    
    @objc func createLeaks() {
        var a: AClass? = .init()
        var b: BClass? = .init()
        a?.b = b
        b?.a = a
        a = nil
        b = nil
    }
    
    private let button = UIButton()

}

The two classes simply look like this:

class AClass {
    var b: BClass?
    deinit {
        print("A deinits")
    }
}

class BClass {
    var a: AClass?
    deinit {
        print("B deinits")
    }
}

When I click the button the visual notification doesn't show up.

PinYuanChen avatar Jan 11 '23 03:01 PinYuanChen

You are not leaking the object you are tracking (VC)

krzysztofzablocki avatar Jan 11 '23 09:01 krzysztofzablocki

I see. I tried to track the leaking objects like this

class AClass: LifetimeTrackable {
    static var lifetimeConfiguration: LifetimeConfiguration {
        return LifetimeConfiguration(maxCount: 1, groupName: "AClass")
    }
    
    init() {
        trackLifetime()
    }
    
    var b: BClass?
    
    deinit {
        print("A deinits")
    }
}

class BClass: LifetimeTrackable {
    static var lifetimeConfiguration: LifetimeConfiguration {
        return LifetimeConfiguration(maxCount: 1, groupName: "BClass")
    }
    
    init() {
        trackLifetime()
    }
    
    var a: AClass?
    
    deinit {
        print("B deinits")
    }
}

But it crashes as soon as I click the button because 'Could not find a storyboard named 'BarDashboard' in bundle'. Do I have to do other settings to make it work?

PinYuanChen avatar Jan 11 '23 10:01 PinYuanChen

Try pinning 1.8.0 instead of newest tag, since there seems to be some regression in 1.8.1

krzysztofzablocki avatar Jan 11 '23 12:01 krzysztofzablocki

1.8.0 works fine Thanks~

PinYuanChen avatar Jan 12 '23 02:01 PinYuanChen

Hi. I've been faced with the same issue.

Xcode Version - 14.3 Swift Language Version - Swift 5 LifetimeTracker Version - 1.8.0 (Swift Package Manager)

In SceneDelegate file, #if DEBUG LifetimeTracker.setup(onUpdate: LifetimeTrackerDashboardIntegration(visibility: .alwaysVisible, style: .circular).refreshUI) #endif

In ViewController file,

    static var lifetimeConfiguration: LifetimeConfiguration {
        return LifetimeConfiguration(maxCount: 1, groupName: "VC")
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        trackLifetime()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        trackLifetime()
    }

Dashboard never appears 😢 I need some help.

eunbijang avatar Aug 01 '23 07:08 eunbijang

There was initial showing bug that I just fixed in 1.8.2

krzysztofzablocki avatar Nov 16 '23 07:11 krzysztofzablocki