A Tool to Detect Swift Potential Leaks
brew install mint
mint install yume190/LeakDetect
leakDetect \
--module "SCHEME NAME" \
--file Sample.xcworkspace
leakDetect \
--module "SCHEME NAME" \
--file Sample.xcodeproj
# spm
leakDetect \
--module TARGET_NAME \
--file .
# file
leakDetect \
--sdk macosx \
--file xxx.swift
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: yume190/LeakDetect@0.0.7
with:
# https://github.com/antranapp/LeakDetector
module: LeakDetectorDemo
file: LeakDetectorDemo.xcworkspace
token: ${{secrets.GITHUB_TOKEN}}
Detect assign instance function.
-
x = self.func
- Check function is
instance function
. - Check self is
struct
- Check function is
-
y(self.func)
- Check function is
instance function
. - Check parameter is
escaping closure
- Check function is
func escape(block: @escaping () -> Void) {}
class Temp {
func instanceFunction() {}
func leak() {
let x = self.instanceFunction
escape(block: self.instanceFunction)
}
}
Detect instance captured by blocks(closure/function).
# Example:
git clone https://github.com/antranapp/LeakDetector
cd LeakDetector
leakDetect \
--module LeakDetectorDemo \
--file LeakDetectorDemo.xcworkspace