LeakCanaryiOS 0.8.0

LeakCanaryiOS 0.8.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jan 2017

Maintained by Hai Feng Kao.



  • By
  • Hai Feng Kao

Do you want to know if there is a memory leak in your XCTest? This is the tool for you.

Motivated by Leak Canary and HeapInspector.

Usage

Add the follow codes to your test case

- (void)setUp
{
    [LeakCanary beginSnapShot:@[@"UIView"]];
}

- (void)tearDown
{
    NSSet* leakedObjects = [LeakCanary endSnapShot];
    XCTAssertTrue(leakedObjects.count == 0, @"should not have leaked UIView and UIViewController objects");
}

If you use Kiwi

#import <LeakCanary/LeakCanary.h>
#import <Kiwi/Kiwi.h>

beforeEach(^{
    [LeakCanary beginSnapShot:@[@"UIView"]];
});
afterEach(^{
    NSSet* leakedObjects = [LeakCanary endSnapShot];
    [[@(leakedObjects.count) should] equal:@(0)];
});

Requirements

Installation

LeakCanaryiOS is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "LeakCanaryiOS"

Author

Hai Feng Kao, [email protected]

License

LeakCanaryiOS is available under the MIT license. See the LICENSE file for more info.