LifetimeTracker
LifetimeTracker copied to clipboard
Not displaying
I set it up like below
#if DEBUG
LifetimeTracker.setup(onUpdate: LifetimeTrackerDashboardIntegration(visibility: .alwaysVisible, style: .bar).refreshUI)
#endif
and its not working
Me too!
+1
iOS/Xcode version?
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 .
Did you implement LifetimeTrackable
at least once ? It doesn't show if you don't have any LifetimeTrackable
+1
+1 I've implemented LifetimeTrackable and setup lifetimeConfiguration and it still doesn't show up.
a sample app where it doesn't work would help, are you causing a leak? in default mode it only shows when you do
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.
You are not leaking the object you are tracking (VC)
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?
Try pinning 1.8.0 instead of newest tag, since there seems to be some regression in 1.8.1
1.8.0 works fine Thanks~
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.
There was initial showing bug that I just fixed in 1.8.2