fastlane-plugin-memory_leak_detector 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +52 -0
- data/lib/fastlane/plugin/memory_leak_detector/actions/memory_leak_detector_action.rb +47 -0
- data/lib/fastlane/plugin/memory_leak_detector/helper/memory_leak_detector_helper.rb +16 -0
- data/lib/fastlane/plugin/memory_leak_detector/version.rb +5 -0
- data/lib/fastlane/plugin/memory_leak_detector.rb +118 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e04f3ae11817aa2645365d2c19e82eeffee412f96fb6716f48ab0fa878e4b4d9
|
4
|
+
data.tar.gz: 84ddf41d23c3c884b2793424b89163c7a600a390d156fa577b0536d806e67a07
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c96a53beaac7e44ac74bbb4098504f1a8f929eb2cede99b46055c9f1bcf8b84e71b8933f9419814b68770e1364ffbb5eb104c105ea2e68eb9754e5abb6c249e7
|
7
|
+
data.tar.gz: a235186a6943c5d928de4518a6244da384202b39a72ff7aa8099fccae9a765e37c96566f2c40d2e33a3f49141336f91e2a0d2f8d1181d3b35d031b272d587cae
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Nurzhan <nurzhaan0@gmial.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# memory_leak_detector plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-memory_leak_detector)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-memory_leak_detector`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin memory_leak_detector
|
11
|
+
```
|
12
|
+
|
13
|
+
## About memory_leak_detector
|
14
|
+
|
15
|
+
Memory leak detector
|
16
|
+
|
17
|
+
**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
|
+
|
23
|
+
**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
|
24
|
+
|
25
|
+
## Run tests for this plugin
|
26
|
+
|
27
|
+
To run both the tests, and code style validation, run
|
28
|
+
|
29
|
+
```
|
30
|
+
rake
|
31
|
+
```
|
32
|
+
|
33
|
+
To automatically fix many of the styling issues, use
|
34
|
+
```
|
35
|
+
rubocop -a
|
36
|
+
```
|
37
|
+
|
38
|
+
## Issues and Feedback
|
39
|
+
|
40
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
41
|
+
|
42
|
+
## Troubleshooting
|
43
|
+
|
44
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
45
|
+
|
46
|
+
## Using _fastlane_ Plugins
|
47
|
+
|
48
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
49
|
+
|
50
|
+
## About _fastlane_
|
51
|
+
|
52
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/memory_leak_detector_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class MemoryLeakDetectorAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
UI.message("The memory_leak_detector plugin is working!")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
"Memory leak detector"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.authors
|
16
|
+
["Nurzhan"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.return_value
|
20
|
+
# If your method provides a return value, you can describe here what it does
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.details
|
24
|
+
# Optional:
|
25
|
+
"The Memory Leak Detector is a Fastlane plugin designed to help iOS developers detect memory leaks during builds or tests. By integrating with Xcode’s Instruments tool, it automatically scans the app for potential memory leaks and provides detailed reports, including information about the affected classes and objects. This plugin streamlines the process of identifying and addressing memory management issues, improving the stability and performance of iOS applications."
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.available_options
|
29
|
+
[
|
30
|
+
# FastlaneCore::ConfigItem.new(key: :your_option,
|
31
|
+
# env_name: "MEMORY_LEAK_DETECTOR_YOUR_OPTION",
|
32
|
+
# description: "A description of your option",
|
33
|
+
# optional: false,
|
34
|
+
# type: String)
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.is_supported?(platform)
|
39
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
40
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
41
|
+
#
|
42
|
+
# [:ios, :mac, :android].include?(platform)
|
43
|
+
true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
5
|
+
|
6
|
+
module Helper
|
7
|
+
class MemoryLeakDetectorHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::MemoryLeakDetectorHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the memory_leak_detector plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'fastlane/plugin/memory_leak_detector/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Actions
|
5
|
+
class MemoryLeakDetectorAction < Action
|
6
|
+
def self.run(params)
|
7
|
+
UI.message("Running Memory Leak Detection...")
|
8
|
+
|
9
|
+
# Optional: Set the Xcode scheme and configuration for testing
|
10
|
+
scheme = params[:scheme]
|
11
|
+
configuration = params[:configuration]
|
12
|
+
output_file = params[:output_file] || "memory_leak_report.txt" # Default to a text file
|
13
|
+
|
14
|
+
# Run the Instruments command to detect memory leaks
|
15
|
+
command = "xcrun instruments -t 'Leaks' -D '#{output_file}' #{scheme} #{configuration}"
|
16
|
+
|
17
|
+
# Execute the command to detect memory leaks
|
18
|
+
result = sh(command)
|
19
|
+
|
20
|
+
# Check if the command's result indicates any leaks
|
21
|
+
if result.include?("leak detected")
|
22
|
+
UI.error("Memory leak detected!")
|
23
|
+
# Capture and save the details of the leak to a file
|
24
|
+
save_report(output_file)
|
25
|
+
else
|
26
|
+
UI.success("No memory leaks detected!")
|
27
|
+
save_report(output_file, no_leaks: true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.save_report(output_file, no_leaks: false)
|
32
|
+
# If no leaks are detected, output a clean "No leaks" message
|
33
|
+
if no_leaks
|
34
|
+
File.open(output_file, 'w') do |file|
|
35
|
+
file.puts "Memory Leak Report - No leaks detected"
|
36
|
+
file.puts "Timestamp: #{Time.now}"
|
37
|
+
end
|
38
|
+
else
|
39
|
+
# If leaks are detected, provide detailed information in the report
|
40
|
+
leak_details = get_leak_details(output_file)
|
41
|
+
|
42
|
+
File.open(output_file, 'w') do |file|
|
43
|
+
file.puts "Memory Leak Report - Leaks Detected"
|
44
|
+
file.puts "Timestamp: #{Time.now}"
|
45
|
+
file.puts "Leak details:"
|
46
|
+
|
47
|
+
leak_details.each_with_index do |leak, index|
|
48
|
+
file.puts "Leak ##{index + 1}:"
|
49
|
+
file.puts "Class: #{leak[:class]}"
|
50
|
+
file.puts "Object: #{leak[:object]}"
|
51
|
+
file.puts "File: #{leak[:file]}"
|
52
|
+
file.puts "Line: #{leak[:line]}"
|
53
|
+
file.puts "Stack trace: #{leak[:stack_trace]}"
|
54
|
+
file.puts "Retained reference count: #{leak[:ref_count]}"
|
55
|
+
file.puts "-" * 50
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
UI.message("Report saved to #{output_file}")
|
61
|
+
end
|
62
|
+
|
63
|
+
# Simulated function to extract leak details from the Instruments log
|
64
|
+
def self.get_leak_details(output_file)
|
65
|
+
# Example of what the leak details might look like
|
66
|
+
# You would replace this part with logic to parse Instruments output
|
67
|
+
# and extract the actual leak details.
|
68
|
+
leaks = [
|
69
|
+
{
|
70
|
+
class: "MyClass",
|
71
|
+
object: "MyObject",
|
72
|
+
file: "MyClass.swift",
|
73
|
+
line: 42,
|
74
|
+
stack_trace: "SomeStackTrace -> SomeMethod",
|
75
|
+
ref_count: 2
|
76
|
+
},
|
77
|
+
{
|
78
|
+
class: "AnotherClass",
|
79
|
+
object: "AnotherObject",
|
80
|
+
file: "AnotherClass.swift",
|
81
|
+
line: 35,
|
82
|
+
stack_trace: "AnotherStackTrace -> AnotherMethod",
|
83
|
+
ref_count: 3
|
84
|
+
}
|
85
|
+
]
|
86
|
+
|
87
|
+
leaks
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.description
|
91
|
+
"Detect memory leaks in your app during builds or tests and generate a detailed report"
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.available_options
|
95
|
+
[
|
96
|
+
FastlaneCore::ConfigItem.new(key: :scheme,
|
97
|
+
description: "The Xcode scheme to use",
|
98
|
+
optional: false,
|
99
|
+
type: String),
|
100
|
+
FastlaneCore::ConfigItem.new(key: :configuration,
|
101
|
+
description: "The build configuration (e.g., Debug, Release)",
|
102
|
+
optional: false,
|
103
|
+
type: String),
|
104
|
+
FastlaneCore::ConfigItem.new(key: :output_file,
|
105
|
+
description: "The output file for the memory leak report",
|
106
|
+
optional: true,
|
107
|
+
type: String,
|
108
|
+
default_value: "memory_leak_report.txt")
|
109
|
+
]
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.is_supported?(platform)
|
113
|
+
platform == :ios
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-memory_leak_detector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nurzhan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: nurzhaan0@gmial.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/fastlane/plugin/memory_leak_detector.rb
|
22
|
+
- lib/fastlane/plugin/memory_leak_detector/actions/memory_leak_detector_action.rb
|
23
|
+
- lib/fastlane/plugin/memory_leak_detector/helper/memory_leak_detector_helper.rb
|
24
|
+
- lib/fastlane/plugin/memory_leak_detector/version.rb
|
25
|
+
homepage: https://github.com/Nurzhan0/fastlane-plugin-memory-leak-detector
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata:
|
29
|
+
rubygems_mfa_required: 'true'
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.6'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubygems_version: 3.5.23
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Memory leak detector
|
49
|
+
test_files: []
|