cocoapods-ybin 0.0.2 → 0.0.3
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/README.md +101 -6
- data/lib/cocoapods-ybin/command/ybin/link.rb +40 -27
- data/lib/cocoapods-ybin/gem_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40278d03a980ab09c6e027ecc4b32f3d56fccf7263c4e32dda65c3665f2c8a3
|
4
|
+
data.tar.gz: 3cc644f8bfb358c543e7ab6cf1ab571fc522856e3c15185365d83ab73f7c9330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a4b1537ab50147be6a0e6df71f22260714b59619b46ffbc0980b9cf24aab53f98c1cdc32abe1d0e9d030da9fff669e1925d8ac21412edcfc54bcd19c629a5d2
|
7
|
+
data.tar.gz: 11a6ba2e42caef75685fbca58731eb85a5f3e26f7976c02bf6ac3b503cf077540130bb7a0d38c0d3d7ce1dfd944f460adf788fe56fbb31600f10cfe4c9293d28
|
data/README.md
CHANGED
@@ -1,15 +1,110 @@
|
|
1
1
|
[](https://badge.fury.io/rb/cocoapods-ybin)
|
2
2
|
|
3
|
-
#
|
3
|
+
# 一、背景
|
4
4
|
|
5
|
-
|
5
|
+
  随着项目业务的不断迭代和新增,每个业务线负责不同的功能模块,组件化势必是需要进行的工作。业界内,无论是哪种组件化方案,目的是一样的,分离业务和功能。
|
6
6
|
|
7
|
-
|
7
|
+
  组件化虽好,但是组件化只是将不同的业务分离或者不同的功能分离和分层,实际上还是在一个代码池里每次 **build** 需要进行编译、汇编、链接等过程。每次编译的占用的时间还是挺奢侈的,在编译速度上并没有提升。**pod install** 来回切换二进制和源码也更是一件可行不可取的开发模式。
|
8
8
|
|
9
|
-
|
9
|
+
  **cocoapods-ybin** 解决二进制和源码之间的映射问题,无需来回切换源码,实现二进制断点可进入源码进行调试。实现原理是简单的,但区别于 **Android** 里的 **aar** 或 **jar** 内的 Class 文件。
|
10
10
|
|
11
|
-
|
11
|
+
**cocoapods-ybin** 满足以下几个诉求考虑实现:
|
12
12
|
|
13
|
-
|
13
|
+
- **小而好用、低成本接入**
|
14
|
+
- **与二进制库的制作和存储无关,只需二进制库和源码存储位置即可映射**
|
15
|
+
- **同时支持多项目并行开发**
|
16
|
+
- **只存储一份源码**
|
17
|
+
- **无需频繁的 clone 代码**
|
18
|
+
|
19
|
+
# 二、先睹为快
|
20
|
+
|
21
|
+
**cocoapods-ybin-demo** 示例效果视频,[示例代码地址](https://github.com/monetking/cocoapods-ybin-demo.git)
|
22
|
+
|
23
|
+
<video id="video" width="756" height="426" controls="" preload="none" poster="https://img.58cdn.com.cn/dist/rn/course/ybin_demo_cover.png">
|
24
|
+
<source id="mp4" src="https://img.58cdn.com.cn/dist/rn/course/ybin_demo_small.mp4" type="video/mp4">
|
25
|
+
</video>
|
26
|
+
|
27
|
+
# 三、安装
|
28
|
+
|
29
|
+
## 3.1 直接安装
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ sudo gem install cocoapods-ybin
|
33
|
+
```
|
34
|
+
|
35
|
+

|
36
|
+
|
37
|
+
## 3.2 使用 Gemfile 管理 pod 版本
|
38
|
+
|
39
|
+
添加 **cocoapods-ybin** 到 Gemfile 文件
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
gem 'cocoapods-ybin'
|
43
|
+
```
|
44
|
+
|
45
|
+
## 3.3 安装校验
|
46
|
+
|
47
|
+
执行命令 **pod --help** 查看当前 pod 版本 **ybin** 是否安装成功。
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ pod --help
|
51
|
+
```
|
52
|
+
|
53
|
+

|
54
|
+
|
55
|
+

|
56
|
+
|
57
|
+
# 四、使用教程
|
58
|
+
|
59
|
+
|
60
|
+
打开示例项目 **ocoapods-ybin-demo** [示例代码](https://github.com/monetking/cocoapods-ybin-demo.git) 的 Podfile 目录。示例项目使用了 **Bundler** 对 pod 的版本进行了控制,实际项目根据所需选择是否采用,与本插件无关联,请酌情选择。
|
61
|
+
|
62
|
+
## 4.1 执行二进制和源码映射指令
|
63
|
+
|
64
|
+
```bash
|
65
|
+
$ pod ybin link 二进制库名称
|
66
|
+
```
|
67
|
+
|
68
|
+

|
69
|
+
|
70
|
+
## 4.2 查看已映射列表
|
71
|
+
|
72
|
+
```bash
|
73
|
+
$ pod ybin link --list
|
74
|
+
```
|
75
|
+
|
76
|
+

|
77
|
+
|
78
|
+
## 4.3 删除某个或多个源码映射
|
79
|
+
|
80
|
+
```bash
|
81
|
+
$ pod ybin link --remove 二进制库名称1 二进制库名称2
|
82
|
+
```
|
83
|
+
|
84
|
+

|
85
|
+
|
86
|
+
## 4.4 删除所有源码映射
|
87
|
+
|
88
|
+
```bash
|
89
|
+
$ pod ybin link --remove-all
|
90
|
+
```
|
91
|
+
|
92
|
+

|
93
|
+
|
94
|
+
## 4.5 查询项目使用 Pod 管理的版本
|
95
|
+
|
96
|
+
查询项目通过Pod管理的组件库版本号,一般都是 cat Podfile.lock 文件,目视解析版本及依赖版本。阅读起来非常不友好,使用插件 **--lib-version** 扩展即可快速查看 Pod 管理的版本。
|
97
|
+
|
98
|
+
```bash
|
99
|
+
$ pod ybin link --lib-version
|
100
|
+
```
|
101
|
+
|
102
|
+

|
103
|
+
|
104
|
+
# 五、期待
|
105
|
+
|
106
|
+
- 如果在使用过程中遇到Bug,希望您能Issues我,谢谢(或者尝试下载使用最新版本看看Bug修复没有)
|
107
|
+
- 如果在使用过程中发现功能不够用,希望你能Issues我,非常想为这个工具增加更多好用的功能,谢谢
|
108
|
+
- 如果你想为cocoapods-ybin输出代码,请拼命Pull Requests我
|
14
109
|
|
15
110
|
|
@@ -11,7 +11,7 @@ module Pod
|
|
11
11
|
DESC
|
12
12
|
|
13
13
|
self.arguments = [
|
14
|
-
CLAide::Argument.new('
|
14
|
+
CLAide::Argument.new('LIB_NAME', false)
|
15
15
|
]
|
16
16
|
def self.options
|
17
17
|
[
|
@@ -74,11 +74,11 @@ module Pod
|
|
74
74
|
def linkLibSource
|
75
75
|
|
76
76
|
if @names.nil?
|
77
|
-
UI.puts "[Error] 请输入需要映射的组件库. 示例: $ pod ybin foo\n".red
|
77
|
+
UI.puts "[Error] 请输入需要映射的组件库. 示例: $ pod ybin link foo\n".red
|
78
78
|
return
|
79
79
|
else
|
80
80
|
if @names.count > 1
|
81
|
-
UI.puts "[Error] 不支持一次映射多个源码. 示例: $ pod ybin foo\n".red
|
81
|
+
UI.puts "[Error] 不支持一次映射多个源码. 示例: $ pod ybin link foo\n".red
|
82
82
|
return
|
83
83
|
end
|
84
84
|
end
|
@@ -101,8 +101,16 @@ module Pod
|
|
101
101
|
config = config_with_asker
|
102
102
|
lib_path = config["libPath"]
|
103
103
|
sourcePath = config["sourcePath"]
|
104
|
+
lib_name = source_lib_name(lib_path)
|
105
|
+
|
106
|
+
lib_real_path = ""
|
107
|
+
if Pathname.new(lib_path).extname == ".framework"
|
108
|
+
lib_real_path = "#{lib_path}/#{lib_name}"
|
109
|
+
elsif Pathname.new(lib_path).extname == ".a"
|
110
|
+
lib_real_path = lib_path
|
111
|
+
end
|
104
112
|
|
105
|
-
if
|
113
|
+
if lib_real_path == "" || !File.exist?(lib_real_path)
|
106
114
|
UI.puts "\n[Error] 二进制文件不存在, 请检查文件位置!\n".red
|
107
115
|
return
|
108
116
|
end
|
@@ -112,23 +120,25 @@ module Pod
|
|
112
120
|
return
|
113
121
|
end
|
114
122
|
|
115
|
-
|
116
|
-
link_source_code(lib_path, sourcePath, lib_name)
|
123
|
+
link_source_code(lib_real_path, sourcePath, lib_name)
|
117
124
|
end
|
118
125
|
|
119
126
|
def link_source_code(lib_path, sourcePath, lib_name)
|
120
127
|
|
121
128
|
comp_dir_path = `dwarfdump "#{lib_path}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2`
|
122
129
|
if comp_dir_path == nil || comp_dir_path == ""
|
123
|
-
UI.puts "\n[Error] #{lib_name}
|
130
|
+
UI.puts "\n[Error] #{lib_name} 不支持映射源码\n".red
|
124
131
|
return
|
125
132
|
end
|
126
133
|
|
127
134
|
lib_debug_path = comp_dir_path.chomp.strip
|
128
|
-
if File.exist?(lib_debug_path) || File.directory?(lib_debug_path)
|
129
|
-
|
130
|
-
|
131
|
-
|
135
|
+
if File.exist?(lib_debug_path) || File.directory?(lib_debug_path)
|
136
|
+
if File.symlink?(lib_debug_path)
|
137
|
+
print "源码映射已存在, 无法重复映射,请删除后重新映射: #{lib_debug_path}"
|
138
|
+
else
|
139
|
+
print "源码映射目录已存在, 请检查 #{lib_debug_path} 目录(可能存在以下情况):"
|
140
|
+
UI.puts "\n1、开发源码(无需映射,即可调试) \n2、其他重复文件, 请手动移动/移除\n".red
|
141
|
+
end
|
132
142
|
else
|
133
143
|
|
134
144
|
begin
|
@@ -144,11 +154,7 @@ module Pod
|
|
144
154
|
end
|
145
155
|
|
146
156
|
FileUtils.rm_rf(lib_debug_path)
|
147
|
-
|
148
|
-
`ln -s #{sourcePath} #{lib_debug_path}`
|
149
|
-
else
|
150
|
-
`ln -s #{sourcePath} #{lib_debug_path}/#{lib_name}`
|
151
|
-
end
|
157
|
+
File.symlink(sourcePath, lib_debug_path)
|
152
158
|
check_linked(lib_path, lib_debug_path, lib_name)
|
153
159
|
end
|
154
160
|
end
|
@@ -178,7 +184,7 @@ module Pod
|
|
178
184
|
if lib_linked_path.nil? || lib_linked_path == ""
|
179
185
|
UI.puts "[Error] #{name} 的映射不存在, 无需移除".red
|
180
186
|
else
|
181
|
-
if File.exist?(lib_linked_path)
|
187
|
+
if File.exist?(lib_linked_path) && File.symlink?(lib_linked_path)
|
182
188
|
FileUtils.rm_rf(lib_linked_path)
|
183
189
|
removeLinkedFileRecord(name)
|
184
190
|
UI.puts "#{name} 成功移除".green
|
@@ -200,7 +206,7 @@ module Pod
|
|
200
206
|
records.each.with_index(0) do |record, index|
|
201
207
|
lib_linked_path = record["source_path"]
|
202
208
|
lib_name = record["lib_name"]
|
203
|
-
if File.exist?(lib_linked_path)
|
209
|
+
if File.exist?(lib_linked_path) && File.symlink?(lib_linked_path)
|
204
210
|
FileUtils.rm_rf(lib_linked_path)
|
205
211
|
removeLinkedFileRecord(lib_name)
|
206
212
|
UI.puts "#{lib_name} removing...".green
|
@@ -208,7 +214,7 @@ module Pod
|
|
208
214
|
end
|
209
215
|
UI.puts "\n已全部移除\n".green
|
210
216
|
else
|
211
|
-
UI.puts "无记录\n".green
|
217
|
+
UI.puts "\n无记录\n".green
|
212
218
|
end
|
213
219
|
end
|
214
220
|
end
|
@@ -220,13 +226,15 @@ module Pod
|
|
220
226
|
records = JSON.parse(File.read(source_record_file_path))
|
221
227
|
if records.count > 0
|
222
228
|
records.each.with_index(1) do |record, index|
|
223
|
-
|
229
|
+
lib_version_s = record["lib_version"]
|
230
|
+
lib_version_s = (lib_version_s == nil || lib_version_s == '') ? "" : "(#{lib_version_s})"
|
231
|
+
UI.puts "#{index}. #{record["lib_name"]} #{lib_version_s} ".green "Source: #{record["source_path"]}".yellow
|
224
232
|
end
|
225
233
|
else
|
226
|
-
UI.puts "无记录".green
|
234
|
+
UI.puts "\n无记录".green
|
227
235
|
end
|
228
236
|
else
|
229
|
-
UI.puts "无记录".green
|
237
|
+
UI.puts "\n无记录".green
|
230
238
|
end
|
231
239
|
print "\n"
|
232
240
|
end
|
@@ -263,8 +271,13 @@ module Pod
|
|
263
271
|
end
|
264
272
|
|
265
273
|
def source_lib_name(filePath)
|
266
|
-
file_name =
|
267
|
-
|
274
|
+
file_name = ""
|
275
|
+
if Pathname.new(filePath).extname == ".framework"
|
276
|
+
file_name = File.basename(filePath, ".framework")
|
277
|
+
elsif Pathname.new(filePath).extname == ".a"
|
278
|
+
file_name = File.basename(filePath, ".a")
|
279
|
+
file_name = file_name[3..file_name.length]
|
280
|
+
end
|
268
281
|
file_name
|
269
282
|
end
|
270
283
|
|
@@ -350,7 +363,7 @@ module Pod
|
|
350
363
|
end
|
351
364
|
@lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock))
|
352
365
|
|
353
|
-
UI.section "
|
366
|
+
UI.section "ybin analyzer" do
|
354
367
|
analyzer = Pod::Installer::Analyzer.new(config.sandbox, config.podfile, @lockfile)
|
355
368
|
@analysis_result = analyzer.analyze
|
356
369
|
@aggregate_targets = @analysis_result.targets
|
@@ -413,8 +426,8 @@ module Pod
|
|
413
426
|
|
414
427
|
def template_source
|
415
428
|
{
|
416
|
-
'libPath' => { question: '1/2
|
417
|
-
'sourcePath' => { question: '2/2
|
429
|
+
'libPath' => { question: '1/2 请输入静态二进制库的路径(如:/Users/xxx/Workspace/xxx.a 或 /Users/xxx/Workspace/xxx.framework)' },
|
430
|
+
'sourcePath' => { question: '2/2 源码路径(注意: 版本是否匹配)' },
|
418
431
|
}
|
419
432
|
end
|
420
433
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-ybin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- monetking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|