Skip to content

yume190/LeakDetect

Repository files navigation

Leak Detect


A Tool to Detect Swift Potential Leaks

Installation

brew install mint
mint install yume190/LeakDetect

Usage

leakDetect \
    --module "SCHEME NAME" \
    --file Sample.xcworkspace

leakDetect \
    --module "SCHEME NAME" \
    --file Sample.xcodeproj

Detect assign instance function.

  1. x = self.func

    • Check function is instance function.
    • Check self is struct
  2. y(self.func)

    • Check function is instance function.
    • Check parameter is escaping closure

see Don't use this syntax!.

func escape(block: @escaping () -> Void) {}
class Temp {
  func instanceFunction() {}
  func leak() {
    let x = self.instanceFunction
    escape(block: self.instanceFunction)
  }
}

Capture

Detect instance captured by blocks(closure/function).

Example

# Example:
git clone https://github.com/antranapp/LeakDetector
cd LeakDetector

leakDetect \
    --module LeakDetectorDemo \
    --file LeakDetectorDemo.xcworkspace