objcthin 0.2.0 → 0.3.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 +4 -4
- data/.idea/workspace.xml +99 -45
- data/README.md +11 -1
- data/lib/objcthin.rb +100 -68
- data/lib/objcthin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa16ca065502f0339726d925f6c5869fb7ae380c
|
4
|
+
data.tar.gz: 545f115b3d91274f34c937588617aae3bd2a50af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a382092be8ec097f92502ff57a71211f736e71b2ac4d679f99034b2ab882ce549b55f1af7dcdbffdb890d4d31e7443f124a3023243157509a62ea4c0a065799b
|
7
|
+
data.tar.gz: 51ffb2b02c51230870771c299c37cd286a2478923dad755dac2b68b48361f2f36618f9a63395c24a0543c8848533c223cd99ff18c7dc90d8909d8498c1ee2d06
|
data/.idea/workspace.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<project version="4">
|
3
3
|
<component name="ChangeListManager">
|
4
4
|
<list default="true" id="69d66805-a1ec-48e6-b641-a43f752f569e" name="Default" comment="">
|
5
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/
|
5
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/objcthin/version.rb" afterPath="$PROJECT_DIR$/lib/objcthin/version.rb" />
|
6
6
|
</list>
|
7
7
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
8
8
|
<option name="TRACKING_ENABLED" value="true" />
|
@@ -13,11 +13,11 @@
|
|
13
13
|
</component>
|
14
14
|
<component name="FileEditorManager">
|
15
15
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
16
|
-
<file leaf-file-name="
|
17
|
-
<entry file="file://$PROJECT_DIR$/
|
16
|
+
<file leaf-file-name="Rakefile" pinned="false" current-in-tab="false">
|
17
|
+
<entry file="file://$PROJECT_DIR$/Rakefile">
|
18
18
|
<provider selected="true" editor-type-id="text-editor">
|
19
|
-
<state relative-caret-position="
|
20
|
-
<caret line="
|
19
|
+
<state relative-caret-position="300">
|
20
|
+
<caret line="20" column="21" lean-forward="false" selection-start-line="20" selection-start-column="21" selection-end-line="20" selection-end-column="21" />
|
21
21
|
<folding />
|
22
22
|
</state>
|
23
23
|
</provider>
|
@@ -27,8 +27,8 @@
|
|
27
27
|
<entry file="file://$PROJECT_DIR$/README.md">
|
28
28
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
29
29
|
<state split_layout="SPLIT">
|
30
|
-
<first_editor relative-caret-position="
|
31
|
-
<caret line="
|
30
|
+
<first_editor relative-caret-position="389">
|
31
|
+
<caret line="33" column="63" lean-forward="false" selection-start-line="33" selection-start-column="63" selection-end-line="33" selection-end-column="63" />
|
32
32
|
<folding />
|
33
33
|
</first_editor>
|
34
34
|
<second_editor />
|
@@ -36,21 +36,11 @@
|
|
36
36
|
</provider>
|
37
37
|
</entry>
|
38
38
|
</file>
|
39
|
-
<file leaf-file-name="version.rb" pinned="false" current-in-tab="
|
39
|
+
<file leaf-file-name="version.rb" pinned="false" current-in-tab="true">
|
40
40
|
<entry file="file://$PROJECT_DIR$/lib/objcthin/version.rb">
|
41
41
|
<provider selected="true" editor-type-id="text-editor">
|
42
|
-
<state relative-caret-position="
|
43
|
-
<caret line="
|
44
|
-
<folding />
|
45
|
-
</state>
|
46
|
-
</provider>
|
47
|
-
</entry>
|
48
|
-
</file>
|
49
|
-
<file leaf-file-name="Rakefile" pinned="false" current-in-tab="true">
|
50
|
-
<entry file="file://$PROJECT_DIR$/Rakefile">
|
51
|
-
<provider selected="true" editor-type-id="text-editor">
|
52
|
-
<state relative-caret-position="300">
|
53
|
-
<caret line="20" column="21" lean-forward="false" selection-start-line="20" selection-start-column="21" selection-end-line="20" selection-end-column="21" />
|
42
|
+
<state relative-caret-position="15">
|
43
|
+
<caret line="1" column="16" lean-forward="false" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
|
54
44
|
<folding />
|
55
45
|
</state>
|
56
46
|
</provider>
|
@@ -59,9 +49,11 @@
|
|
59
49
|
<file leaf-file-name="objcthin.rb" pinned="false" current-in-tab="false">
|
60
50
|
<entry file="file://$PROJECT_DIR$/lib/objcthin.rb">
|
61
51
|
<provider selected="true" editor-type-id="text-editor">
|
62
|
-
<state relative-caret-position="
|
63
|
-
<caret line="
|
64
|
-
<folding
|
52
|
+
<state relative-caret-position="452">
|
53
|
+
<caret line="281" column="0" lean-forward="true" selection-start-line="281" selection-start-column="0" selection-end-line="281" selection-end-column="0" />
|
54
|
+
<folding>
|
55
|
+
<element signature="e#1411#1780#0" expanded="false" />
|
56
|
+
</folding>
|
65
57
|
</state>
|
66
58
|
</provider>
|
67
59
|
</entry>
|
@@ -71,6 +63,7 @@
|
|
71
63
|
<component name="FindInProjectRecents">
|
72
64
|
<findStrings>
|
73
65
|
<find>objcthin</find>
|
66
|
+
<find>prefex</find>
|
74
67
|
</findStrings>
|
75
68
|
</component>
|
76
69
|
<component name="Git.Settings">
|
@@ -81,10 +74,10 @@
|
|
81
74
|
<list>
|
82
75
|
<option value="$PROJECT_DIR$/exe/objcthin" />
|
83
76
|
<option value="$PROJECT_DIR$/objcthin.gemspec" />
|
77
|
+
<option value="$PROJECT_DIR$/Rakefile" />
|
84
78
|
<option value="$PROJECT_DIR$/lib/objcthin.rb" />
|
85
79
|
<option value="$PROJECT_DIR$/README.md" />
|
86
80
|
<option value="$PROJECT_DIR$/lib/objcthin/version.rb" />
|
87
|
-
<option value="$PROJECT_DIR$/Rakefile" />
|
88
81
|
</list>
|
89
82
|
</option>
|
90
83
|
</component>
|
@@ -115,10 +108,20 @@
|
|
115
108
|
<foldersAlwaysOnTop value="true" />
|
116
109
|
</navigator>
|
117
110
|
<panes>
|
118
|
-
<pane id="Scratches" />
|
119
111
|
<pane id="Scope" />
|
112
|
+
<pane id="Scratches" />
|
120
113
|
<pane id="ProjectPane">
|
121
114
|
<subPane>
|
115
|
+
<PATH>
|
116
|
+
<PATH_ELEMENT>
|
117
|
+
<option name="myItemId" value="objcthin" />
|
118
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
119
|
+
</PATH_ELEMENT>
|
120
|
+
<PATH_ELEMENT>
|
121
|
+
<option name="myItemId" value="External Libraries" />
|
122
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
|
123
|
+
</PATH_ELEMENT>
|
124
|
+
</PATH>
|
122
125
|
<PATH>
|
123
126
|
<PATH_ELEMENT>
|
124
127
|
<option name="myItemId" value="objcthin" />
|
@@ -181,6 +184,7 @@
|
|
181
184
|
</component>
|
182
185
|
<component name="PropertiesComponent">
|
183
186
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
187
|
+
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
|
184
188
|
</component>
|
185
189
|
<component name="RunDashboard">
|
186
190
|
<option name="ruleStates">
|
@@ -352,11 +356,12 @@
|
|
352
356
|
<updated>1508233449256</updated>
|
353
357
|
<workItem from="1508233450613" duration="12864000" />
|
354
358
|
<workItem from="1508466982795" duration="1227000" />
|
359
|
+
<workItem from="1508565800048" duration="7433000" />
|
355
360
|
</task>
|
356
361
|
<servers />
|
357
362
|
</component>
|
358
363
|
<component name="TimeTrackingManager">
|
359
|
-
<option name="totallyTimeSpent" value="
|
364
|
+
<option name="totallyTimeSpent" value="22122000" />
|
360
365
|
</component>
|
361
366
|
<component name="ToolWindowManager">
|
362
367
|
<frame x="0" y="23" width="1280" height="745" extended-state="6" />
|
@@ -392,6 +397,51 @@
|
|
392
397
|
<watches-manager />
|
393
398
|
</component>
|
394
399
|
<component name="editorHistoryManager">
|
400
|
+
<entry file="file://$PROJECT_DIR$/objcthin.gemspec">
|
401
|
+
<provider selected="true" editor-type-id="text-editor">
|
402
|
+
<state relative-caret-position="345">
|
403
|
+
<caret line="23" column="5" lean-forward="false" selection-start-line="23" selection-start-column="5" selection-end-line="23" selection-end-column="5" />
|
404
|
+
<folding />
|
405
|
+
</state>
|
406
|
+
</provider>
|
407
|
+
</entry>
|
408
|
+
<entry file="file://$PROJECT_DIR$/README.md">
|
409
|
+
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
410
|
+
<state split_layout="SPLIT">
|
411
|
+
<first_editor relative-caret-position="375">
|
412
|
+
<caret line="25" column="4" lean-forward="true" selection-start-line="25" selection-start-column="4" selection-end-line="25" selection-end-column="4" />
|
413
|
+
<folding />
|
414
|
+
</first_editor>
|
415
|
+
<second_editor />
|
416
|
+
</state>
|
417
|
+
</provider>
|
418
|
+
</entry>
|
419
|
+
<entry file="file://$PROJECT_DIR$/lib/objcthin/version.rb">
|
420
|
+
<provider selected="true" editor-type-id="text-editor">
|
421
|
+
<state relative-caret-position="45">
|
422
|
+
<caret line="3" column="0" lean-forward="true" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
|
423
|
+
<folding />
|
424
|
+
</state>
|
425
|
+
</provider>
|
426
|
+
</entry>
|
427
|
+
<entry file="file://$PROJECT_DIR$/lib/objcthin.rb">
|
428
|
+
<provider selected="true" editor-type-id="text-editor">
|
429
|
+
<state relative-caret-position="3630">
|
430
|
+
<caret line="242" column="28" lean-forward="true" selection-start-line="242" selection-start-column="28" selection-end-line="242" selection-end-column="28" />
|
431
|
+
<folding>
|
432
|
+
<element signature="e#1411#1780#0" expanded="false" />
|
433
|
+
</folding>
|
434
|
+
</state>
|
435
|
+
</provider>
|
436
|
+
</entry>
|
437
|
+
<entry file="file://$PROJECT_DIR$/Rakefile">
|
438
|
+
<provider selected="true" editor-type-id="text-editor">
|
439
|
+
<state relative-caret-position="300">
|
440
|
+
<caret line="20" column="21" lean-forward="false" selection-start-line="20" selection-start-column="21" selection-end-line="20" selection-end-column="21" />
|
441
|
+
<folding />
|
442
|
+
</state>
|
443
|
+
</provider>
|
444
|
+
</entry>
|
395
445
|
<entry file="file://$PROJECT_DIR$/objcthin.gemspec">
|
396
446
|
<provider selected="true" editor-type-id="text-editor">
|
397
447
|
<state relative-caret-position="345">
|
@@ -415,7 +465,9 @@
|
|
415
465
|
<provider selected="true" editor-type-id="text-editor">
|
416
466
|
<state relative-caret-position="1485">
|
417
467
|
<caret line="99" column="45" lean-forward="false" selection-start-line="99" selection-start-column="45" selection-end-line="99" selection-end-column="45" />
|
418
|
-
<folding
|
468
|
+
<folding>
|
469
|
+
<element signature="e#1411#1780#0" expanded="false" />
|
470
|
+
</folding>
|
419
471
|
</state>
|
420
472
|
</provider>
|
421
473
|
</entry>
|
@@ -453,7 +505,6 @@
|
|
453
505
|
<provider selected="true" editor-type-id="text-editor">
|
454
506
|
<state relative-caret-position="0">
|
455
507
|
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
456
|
-
<folding />
|
457
508
|
</state>
|
458
509
|
</provider>
|
459
510
|
</entry>
|
@@ -499,7 +550,9 @@
|
|
499
550
|
<provider selected="true" editor-type-id="text-editor">
|
500
551
|
<state relative-caret-position="197">
|
501
552
|
<caret line="99" column="45" lean-forward="false" selection-start-line="99" selection-start-column="45" selection-end-line="99" selection-end-column="45" />
|
502
|
-
<folding
|
553
|
+
<folding>
|
554
|
+
<element signature="e#1411#1780#0" expanded="false" />
|
555
|
+
</folding>
|
503
556
|
</state>
|
504
557
|
</provider>
|
505
558
|
</entry>
|
@@ -544,7 +597,6 @@
|
|
544
597
|
<provider selected="true" editor-type-id="text-editor">
|
545
598
|
<state relative-caret-position="0">
|
546
599
|
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
547
|
-
<folding />
|
548
600
|
</state>
|
549
601
|
</provider>
|
550
602
|
</entry>
|
@@ -577,19 +629,29 @@
|
|
577
629
|
</state>
|
578
630
|
</provider>
|
579
631
|
</entry>
|
580
|
-
<entry file="file://$PROJECT_DIR$/
|
632
|
+
<entry file="file://$PROJECT_DIR$/Rakefile">
|
581
633
|
<provider selected="true" editor-type-id="text-editor">
|
582
|
-
<state relative-caret-position="
|
583
|
-
<caret line="
|
634
|
+
<state relative-caret-position="300">
|
635
|
+
<caret line="20" column="21" lean-forward="false" selection-start-line="20" selection-start-column="21" selection-end-line="20" selection-end-column="21" />
|
584
636
|
<folding />
|
585
637
|
</state>
|
586
638
|
</provider>
|
587
639
|
</entry>
|
640
|
+
<entry file="file://$PROJECT_DIR$/lib/objcthin.rb">
|
641
|
+
<provider selected="true" editor-type-id="text-editor">
|
642
|
+
<state relative-caret-position="452">
|
643
|
+
<caret line="281" column="0" lean-forward="true" selection-start-line="281" selection-start-column="0" selection-end-line="281" selection-end-column="0" />
|
644
|
+
<folding>
|
645
|
+
<element signature="e#1411#1780#0" expanded="false" />
|
646
|
+
</folding>
|
647
|
+
</state>
|
648
|
+
</provider>
|
649
|
+
</entry>
|
588
650
|
<entry file="file://$PROJECT_DIR$/README.md">
|
589
651
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
590
652
|
<state split_layout="SPLIT">
|
591
|
-
<first_editor relative-caret-position="
|
592
|
-
<caret line="
|
653
|
+
<first_editor relative-caret-position="389">
|
654
|
+
<caret line="33" column="63" lean-forward="false" selection-start-line="33" selection-start-column="63" selection-end-line="33" selection-end-column="63" />
|
593
655
|
<folding />
|
594
656
|
</first_editor>
|
595
657
|
<second_editor />
|
@@ -598,16 +660,8 @@
|
|
598
660
|
</entry>
|
599
661
|
<entry file="file://$PROJECT_DIR$/lib/objcthin/version.rb">
|
600
662
|
<provider selected="true" editor-type-id="text-editor">
|
601
|
-
<state relative-caret-position="
|
602
|
-
<caret line="
|
603
|
-
<folding />
|
604
|
-
</state>
|
605
|
-
</provider>
|
606
|
-
</entry>
|
607
|
-
<entry file="file://$PROJECT_DIR$/Rakefile">
|
608
|
-
<provider selected="true" editor-type-id="text-editor">
|
609
|
-
<state relative-caret-position="300">
|
610
|
-
<caret line="20" column="21" lean-forward="false" selection-start-line="20" selection-start-column="21" selection-end-line="20" selection-end-column="21" />
|
663
|
+
<state relative-caret-position="15">
|
664
|
+
<caret line="1" column="16" lean-forward="false" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
|
611
665
|
<folding />
|
612
666
|
</state>
|
613
667
|
</provider>
|
data/README.md
CHANGED
@@ -6,6 +6,10 @@ this script can find unused selector and class for you project.app or LinkMap fi
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
+
this script use ruby 2.4.* above, please check you ruby version:
|
10
|
+
|
11
|
+
$ ruby -v
|
12
|
+
|
9
13
|
Add this line to your application's Gemfile:
|
10
14
|
|
11
15
|
```ruby
|
@@ -26,9 +30,15 @@ find unused selector:
|
|
26
30
|
|
27
31
|
$ objcthin findsel apppath(the execuse app path)
|
28
32
|
|
33
|
+
# add the special prefix
|
34
|
+
$ objcthin findsel apppath(the execuse app path) --prefix='UI'
|
35
|
+
|
29
36
|
find unused class:
|
30
37
|
|
31
|
-
$ objcthin findclass apppath(the execuse app path)
|
38
|
+
$ objcthin findclass apppath(the execuse app path)
|
39
|
+
|
40
|
+
# add the special prefix
|
41
|
+
$ objcthin findclass apppath(the execuse app path) --prefix='UI'
|
32
42
|
|
33
43
|
## Development
|
34
44
|
|
data/lib/objcthin.rb
CHANGED
@@ -2,17 +2,20 @@ require "objcthin/version"
|
|
2
2
|
require 'thor'
|
3
3
|
require 'rainbow'
|
4
4
|
require 'pathname'
|
5
|
+
require 'singleton'
|
5
6
|
|
6
7
|
module Objcthin
|
7
8
|
class Command < Thor
|
8
9
|
desc 'findsel','find unused method sel'
|
10
|
+
method_option :prefix, :default => '', :type => :string, :desc => 'the class prefix you want find'
|
9
11
|
def findsel(path)
|
10
|
-
Imp::UnusedClass.find_unused_sel(path)
|
12
|
+
Imp::UnusedClass.instance.find_unused_sel(path, options[:prefix])
|
11
13
|
end
|
12
14
|
|
13
15
|
desc 'findclass', 'find unused class list'
|
16
|
+
method_option :prefix => :string, :default => '', :desc => 'the class prefix you want find'
|
14
17
|
def findclass(path)
|
15
|
-
Imp::UnusedClass.find_unused_class(path)
|
18
|
+
Imp::UnusedClass.instance.find_unused_class(path, options[:prefix])
|
16
19
|
end
|
17
20
|
|
18
21
|
desc'version','print version'
|
@@ -24,7 +27,10 @@ end
|
|
24
27
|
|
25
28
|
module Imp
|
26
29
|
class UnusedClass
|
27
|
-
|
30
|
+
|
31
|
+
include Singleton
|
32
|
+
|
33
|
+
def find_unused_sel(path, prefix)
|
28
34
|
check_file_type(path)
|
29
35
|
all_sels = find_impl_methods(path)
|
30
36
|
used_sel = reference_selectors(path)
|
@@ -37,12 +43,18 @@ module Imp
|
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
40
|
-
puts Rainbow('below selector is unused
|
46
|
+
puts Rainbow('below selector is unused:').red
|
47
|
+
if prefix
|
48
|
+
unused_sel.select! do |classname_selector|
|
49
|
+
current_prefix = classname_selector.byteslice(2, prefix.length)
|
50
|
+
current_prefix == prefix
|
51
|
+
end
|
52
|
+
end
|
41
53
|
|
42
54
|
puts unused_sel
|
43
55
|
end
|
44
56
|
|
45
|
-
def
|
57
|
+
def check_file_type(path)
|
46
58
|
pathname = Pathname.new(path)
|
47
59
|
unless pathname.exist?
|
48
60
|
raise "#{path} not exit!"
|
@@ -58,19 +70,16 @@ module Imp
|
|
58
70
|
pathname
|
59
71
|
end
|
60
72
|
|
61
|
-
def
|
62
|
-
|
63
|
-
app = %w[1 2]
|
64
|
-
|
73
|
+
def find_impl_methods(path)
|
65
74
|
apple_protocols = [
|
66
75
|
'tableView:canEditRowAtIndexPath:',
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
76
|
+
'commitEditingStyle:forRowAtIndexPath:',
|
77
|
+
'tableView:viewForHeaderInSection:',
|
78
|
+
'tableView:cellForRowAtIndexPath:',
|
79
|
+
'tableView:canPerformAction:forRowAtIndexPath:withSender:',
|
80
|
+
'tableView:performAction:forRowAtIndexPath:withSender:',
|
81
|
+
'tableView:accessoryButtonTappedForRowWithIndexPath:',
|
82
|
+
'tableView:willDisplayCell:forRowAtIndexPath:',
|
74
83
|
'tableView:commitEditingStyle:forRowAtIndexPath:',
|
75
84
|
'tableView:didEndDisplayingCell:forRowAtIndexPath:',
|
76
85
|
'tableView:didEndDisplayingHeaderView:forSection:',
|
@@ -81,32 +90,40 @@ module Imp
|
|
81
90
|
'tableView:willDisplayHeaderView:forSection:',
|
82
91
|
'tableView:willSelectRowAtIndexPath:',
|
83
92
|
'willMoveToSuperview:',
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
93
|
+
'scrollViewDidEndScrollingAnimation:',
|
94
|
+
'scrollViewDidZoom',
|
95
|
+
'scrollViewWillEndDragging:withVelocity:targetContentOffset:',
|
96
|
+
'searchBarTextDidEndEditing:',
|
97
|
+
'searchBar:selectedScopeButtonIndexDidChange:',
|
98
|
+
'shouldInvalidateLayoutForBoundsChange:',
|
99
|
+
'textFieldShouldReturn:',
|
100
|
+
'numberOfSectionsInTableView:',
|
101
|
+
'actionSheet:willDismissWithButtonIndex:',
|
102
|
+
'gestureRecognizer:shouldReceiveTouch:',
|
103
|
+
'gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:',
|
104
|
+
'gestureRecognizer:shouldReceiveTouch:',
|
105
|
+
'imagePickerController:didFinishPickingMediaWithInfo:',
|
106
|
+
'imagePickerControllerDidCancel:',
|
107
|
+
'animateTransition:',
|
108
|
+
'animationControllerForDismissedController:',
|
109
|
+
'animationControllerForPresentedController:presentingController:sourceController:',
|
110
|
+
'navigationController:animationControllerForOperation:fromViewController:toViewController:',
|
111
|
+
'navigationController:interactionControllerForAnimationController:',
|
112
|
+
'alertView:didDismissWithButtonIndex:',
|
113
|
+
'URLSession:didBecomeInvalidWithError:',
|
114
|
+
'setDownloadTaskDidResumeBlock:',
|
115
|
+
'tabBarController:didSelectViewController:',
|
116
|
+
'tabBarController:shouldSelectViewController:',
|
117
|
+
'applicationDidReceiveMemoryWarning:',
|
118
|
+
'application:didRegisterForRemoteNotificationsWithDeviceToken:',
|
119
|
+
'application:didFailToRegisterForRemoteNotificationsWithError:',
|
120
|
+
'application:didReceiveRemoteNotification:fetchCompletionHandler:',
|
121
|
+
'application:didRegisterUserNotificationSettings:',
|
122
|
+
'application:performActionForShortcutItem:completionHandler:',
|
123
|
+
'application:continueUserActivity:restorationHandler:'].freeze
|
108
124
|
|
109
125
|
# imp -[class sel]
|
126
|
+
|
110
127
|
sub_patten = /[+|-]\[.+\s(.+)\]/
|
111
128
|
patten = /\s*imp\s*(#{sub_patten})/
|
112
129
|
sel_set_patten = /set[A-Z].*:$/
|
@@ -139,7 +156,7 @@ module Imp
|
|
139
156
|
imp.sort
|
140
157
|
end
|
141
158
|
|
142
|
-
def
|
159
|
+
def reference_selectors(path)
|
143
160
|
patten = /__TEXT:__objc_methname:(.+)/
|
144
161
|
output = `/usr/bin/otool -v -s __DATA __objc_selrefs #{path}`
|
145
162
|
|
@@ -159,7 +176,9 @@ end
|
|
159
176
|
module Imp
|
160
177
|
class UnusedClass
|
161
178
|
|
162
|
-
|
179
|
+
include Singleton
|
180
|
+
|
181
|
+
def check_file_type(path)
|
163
182
|
pathname = Pathname.new(path)
|
164
183
|
unless pathname.exist?
|
165
184
|
raise "#{path} not exit!"
|
@@ -171,12 +190,25 @@ module Imp
|
|
171
190
|
unless output.include?('Mach-O')
|
172
191
|
raise 'input file not mach-o file type'
|
173
192
|
end
|
174
|
-
puts Rainbow('will begin process...').green
|
193
|
+
#puts Rainbow('will begin process...').green
|
175
194
|
pathname
|
176
195
|
end
|
177
196
|
|
178
|
-
def
|
179
|
-
|
197
|
+
def split_segment_and_find(path, prefix)
|
198
|
+
|
199
|
+
arch_command = "lipo -info #{path}"
|
200
|
+
arch_output = `#{arch_command}`
|
201
|
+
|
202
|
+
arch = 'arm64'
|
203
|
+
if arch_output.include? 'arm64'
|
204
|
+
arch = 'arm64'
|
205
|
+
elsif arch_output.include? 'x86_64'
|
206
|
+
arch = 'x86_64'
|
207
|
+
elsif arch_output.include? 'armv7'
|
208
|
+
arch = 'armv7'
|
209
|
+
end
|
210
|
+
|
211
|
+
command = "/usr/bin/otool -arch #{arch} -V -o #{path}"
|
180
212
|
output = `#{command}`
|
181
213
|
|
182
214
|
class_list_identifier = 'Contents of (__DATA,__objc_classlist) section'
|
@@ -187,10 +219,16 @@ module Imp
|
|
187
219
|
end
|
188
220
|
|
189
221
|
patten = /Contents of \(.*\) section/
|
190
|
-
|
222
|
+
|
223
|
+
name_patten_string = '.*'
|
224
|
+
if prefix.length > 0
|
225
|
+
name_patten_string = "#{prefix}.*"
|
226
|
+
end
|
227
|
+
vmaddress_to_class_name_patten = /^(\d*\w*)\s(0x\d*\w*)\s_OBJC_CLASS_\$_(#{name_patten_string})/
|
191
228
|
|
192
229
|
class_list = []
|
193
230
|
class_refs = []
|
231
|
+
used_vmaddress_to_class_name_hash = {}
|
194
232
|
|
195
233
|
can_add_to_list = false
|
196
234
|
can_add_to_refs = false
|
@@ -213,44 +251,38 @@ module Imp
|
|
213
251
|
end
|
214
252
|
|
215
253
|
if can_add_to_refs && line
|
216
|
-
|
217
|
-
|
254
|
+
vmaddress_to_class_name_patten.match(line) do |m|
|
255
|
+
unless used_vmaddress_to_class_name_hash[m[2]]
|
256
|
+
used_vmaddress_to_class_name_hash[m[2]] = m[3]
|
257
|
+
end
|
218
258
|
end
|
219
259
|
end
|
220
260
|
end
|
221
261
|
|
262
|
+
# remove cocoapods class
|
263
|
+
podsd_dummy = 'PodsDummy'
|
222
264
|
|
223
|
-
|
224
|
-
class_name_patten = /name\s0x\d*\w*\s(.*)/
|
225
|
-
|
226
|
-
current_key = nil
|
227
|
-
class_name_address_hash = {}
|
228
|
-
|
265
|
+
vmaddress_to_class_name_hash = {}
|
229
266
|
class_list.each do |line|
|
230
|
-
if
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
if class_name_patten.match?(line) && current_key
|
235
|
-
value = class_name_patten.match(line)[1]
|
236
|
-
class_name_address_hash[current_key] = value
|
237
|
-
current_key = nil
|
267
|
+
next if line.include? podsd_dummy
|
268
|
+
vmaddress_to_class_name_patten.match(line) do |m|
|
269
|
+
vmaddress_to_class_name_hash[m[2]] = m[3]
|
238
270
|
end
|
239
271
|
end
|
240
272
|
|
241
|
-
result =
|
242
|
-
|
243
|
-
if
|
244
|
-
result.delete(
|
273
|
+
result = vmaddress_to_class_name_hash
|
274
|
+
vmaddress_to_class_name_hash.each do |key, value|
|
275
|
+
if used_vmaddress_to_class_name_hash.keys.include?(key)
|
276
|
+
result.delete(key)
|
245
277
|
end
|
246
278
|
end
|
247
279
|
|
248
280
|
result
|
249
281
|
end
|
250
282
|
|
251
|
-
def
|
283
|
+
def find_unused_class(path, prefix)
|
252
284
|
check_file_type(path)
|
253
|
-
result = split_segment_and_find(path)
|
285
|
+
result = split_segment_and_find(path, prefix)
|
254
286
|
puts result.values
|
255
287
|
end
|
256
288
|
|
data/lib/objcthin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: objcthin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jamy_gu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|