cocoapods-bin 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -1
- data/README.md +72 -23
- data/cocoapods-bin.gemspec +1 -0
- data/lib/cocoapods-bin/command/bin.rb +1 -0
- data/lib/cocoapods-bin/command/bin/archive.rb +127 -0
- data/lib/cocoapods-bin/gem_version.rb +1 -1
- data/lib/cocoapods-bin/helpers/framework.rb +62 -0
- data/lib/cocoapods-bin/helpers/framework_builder.rb +190 -0
- data/lib/cocoapods-bin/helpers/sources_helper.rb +1 -1
- data/lib/cocoapods-bin/native/specification.rb +23 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dd4d011994f2955b7f1575aedab51ad1b74459b
|
4
|
+
data.tar.gz: e35ee996c447f36ca7f8d81a1f586fa6ff3b2f04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a4302e677e058d979adffd31371b201ff38db69df4a316c85240f2bb21decea7f56a8de4a7ae8459662e9e5616e5434f63d54fe252aedbd1a66cc385b3ef696
|
7
|
+
data.tar.gz: 49e96d900da837d6c34d41d3eead93c9d3138a56139dcec0667983d893cbfc00a473d6cf98a52b03e6d512c79f68ecc5fe5c4492852f14c7ca2113c31f871fca
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocoapods-bin (0.1.
|
4
|
+
cocoapods-bin (0.1.18)
|
5
5
|
cocoapods (~> 1.4)
|
6
|
+
cocoapods-generate (~> 1.4)
|
6
7
|
parallel
|
7
8
|
|
8
9
|
GEM
|
@@ -41,7 +42,10 @@ GEM
|
|
41
42
|
fuzzy_match (~> 2.0.4)
|
42
43
|
nap (~> 1.0)
|
43
44
|
cocoapods-deintegrate (1.0.4)
|
45
|
+
cocoapods-disable-podfile-validations (0.1.1)
|
44
46
|
cocoapods-downloader (1.2.2)
|
47
|
+
cocoapods-generate (1.5.0)
|
48
|
+
cocoapods-disable-podfile-validations (~> 0.1.1)
|
45
49
|
cocoapods-plugins (1.0.0)
|
46
50
|
nap
|
47
51
|
cocoapods-search (1.0.0)
|
data/README.md
CHANGED
@@ -71,10 +71,26 @@ download_file_type: zip
|
|
71
71
|
|
72
72
|
插件配置完后,就可以部署静态资源服务器了。对于静态资源服务器,这里不做赘述,只提示一点:在生成二进制 podspec 时,插件会根据 `download_file_type` 设置 source 的 `:type` 字段。在下载 http/https 资源时,CocoaPods 会根据 `:type` 字段的类型采取相应的解压方式,如果设置错误就会抛错。这里提到了 **二进制 podspec 的自动生成**,后面会详细介绍。
|
73
73
|
|
74
|
-
这里额外说下打包工具 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 和 [Carthage](https://github.com/Carthage/Carthage/issues) ,前者可以通过 podspec 进行打包,只要保证 lint 通过了,就可以打成 `.framework
|
74
|
+
这里额外说下打包工具 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 和 [Carthage](https://github.com/Carthage/Carthage/issues) ,前者可以通过 podspec 进行打包,只要保证 lint 通过了,就可以打成 `.framework`,很方便,但是作者几乎不维护了,后者需要结合组件工程。具体使用哪个可以结合自身团队,甚至可以自己写打包脚本,或者使用本插件的打包命令。
|
75
75
|
|
76
76
|
## 使用插件
|
77
77
|
|
78
|
+
接入二进制版本后,常规的发布流程需要做如下变更:
|
79
|
+
|
80
|
+
```shell
|
81
|
+
# 1 打出二进制产物 && 提交产物至静态文件服务器
|
82
|
+
pod bin archive YOUR_OPTIONS
|
83
|
+
curl xxxxxxx
|
84
|
+
|
85
|
+
# 2.1 发布二进制 podspec
|
86
|
+
pod bin repo push --binary YOUR_OPTIONS
|
87
|
+
|
88
|
+
# 2.2 发布源码 podspec
|
89
|
+
pod bin repo push YOUR_OPTIONS
|
90
|
+
```
|
91
|
+
|
92
|
+
如果团队内部集成了 CI 平台,那么上面的每大步都可以对应一个 CI stage,源码和二进制版本可并行发布,对应一个 stage 中的两个 job。
|
93
|
+
|
78
94
|
### 基本信息
|
79
95
|
|
80
96
|
`cocoapods-bin` 命令行信息可以输入以下命令查看:
|
@@ -88,7 +104,7 @@ Usage:
|
|
88
104
|
组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
|
89
105
|
|
90
106
|
Commands:
|
91
|
-
|
107
|
+
+ archive 将组件归档为静态 framework.
|
92
108
|
+ init 初始化插件.
|
93
109
|
+ lib 管理二进制 pod.
|
94
110
|
+ list 展示二进制 pods .
|
@@ -98,6 +114,28 @@ Commands:
|
|
98
114
|
+ spec 管理二进制 spec.
|
99
115
|
```
|
100
116
|
|
117
|
+
### 构建二进制产物
|
118
|
+
|
119
|
+
```shell
|
120
|
+
➜ ~ pod bin archive --help
|
121
|
+
Usage:
|
122
|
+
|
123
|
+
$ pod bin archive [NAME.podspec]
|
124
|
+
|
125
|
+
将组件归档为静态 framework,仅支持 iOS 平台 此静态 framework 不包含依赖组件的 symbol
|
126
|
+
|
127
|
+
Options:
|
128
|
+
|
129
|
+
--code-dependencies 使用源码依赖
|
130
|
+
--allow-prerelease 允许使用 prerelease 的版本
|
131
|
+
--use-modular-headers 使用 modular headers (modulemap)
|
132
|
+
--no-clean 保留构建中间产物
|
133
|
+
--no-zip 不压缩静态 framework 为 zip
|
134
|
+
...
|
135
|
+
```
|
136
|
+
|
137
|
+
`pod bin archive` 会根据 podspec 文件构建静态 framework ,此静态 framework 不会包含依赖组件的符号信息。命令内部利用 [cocoapods-generate](https://github.com/square/cocoapods-generate) 插件生成工程,并移植了 [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) 插件的部分打包功能,以构建前者生成的工程,默认条件下,命令会生成一个 zip 压缩包。
|
138
|
+
|
101
139
|
### 二进制 podspec
|
102
140
|
|
103
141
|
`cocoapods-bin` 针对一个组件,同时使用了两种 podspec,分别为源码 podspec 和二进制 podspec,这种方式在没有工具支撑的情况下,势必会增加开发者维护组件的工作量。做为开发者来说,我是不希望同时维护两套 podspec 的。为了解决这个问题, 插件提供了自动生成二进制 podspec 功能,开发者依旧只需要关心源码 podspec 即可。
|
@@ -217,7 +255,7 @@ end
|
|
217
255
|
|
218
256
|
```
|
219
257
|
|
220
|
-
那么就需要开发者提供 `A.binary-template.podspec`(此模版中的写法假定组件的所有 subspec 都打进一个 `.framework` 里,如果 subpsec 都有属于自己的 `.framework`
|
258
|
+
那么就需要开发者提供 `A.binary-template.podspec`(此模版中的写法假定组件的所有 subspec 都打进一个 `.framework` 里,如果 subpsec 都有属于自己的 `.framework` ,就可以采用其他写法。),**这里要注意源码版本 subspec 集合需要为二进制版本 subspec 集合的子集,否则会出现源码拉取失败或抛出 subspec 不存在错误的情况**:
|
221
259
|
|
222
260
|
```ruby
|
223
261
|
Pod::Spec.new do |s|
|
@@ -411,26 +449,6 @@ SPEC REPOS:
|
|
411
449
|
...
|
412
450
|
```
|
413
451
|
|
414
|
-
#### use_binaries_with_spec_selector!
|
415
|
-
|
416
|
-
过滤出需要使用二进制版本组件。
|
417
|
-
|
418
|
-
假如开发者只需要 `YYModel` 的二进制版本,那么他可以在 Podfile 中添加以下代码:
|
419
|
-
|
420
|
-
```ruby
|
421
|
-
use_binaries_with_spec_selector! do |spec|
|
422
|
-
spec.name == 'YYModel'
|
423
|
-
end
|
424
|
-
```
|
425
|
-
|
426
|
-
一个实际应用是,三方组件采用二进制版本,团队编写的组件依旧采用源码版本。如果三方组件都在 `cocoapods-repo` 组下,就可以使用以下代码过滤出三方组件:
|
427
|
-
|
428
|
-
```ruby
|
429
|
-
use_binaries_with_spec_selector! do |spec|
|
430
|
-
git = spec.source && spec.source['git']
|
431
|
-
git && git.include?('cocoapods-repo')
|
432
|
-
end
|
433
|
-
```
|
434
452
|
|
435
453
|
#### set_use_source_pods
|
436
454
|
|
@@ -456,6 +474,37 @@ Sending stats
|
|
456
474
|
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
|
457
475
|
```
|
458
476
|
|
477
|
+
#### use_binaries_with_spec_selector!
|
478
|
+
|
479
|
+
过滤出需要使用二进制版本组件。
|
480
|
+
|
481
|
+
假如开发者只需要 `YYModel` 的二进制版本,那么他可以在 Podfile 中添加以下代码:
|
482
|
+
|
483
|
+
```ruby
|
484
|
+
use_binaries_with_spec_selector! do |spec|
|
485
|
+
spec.name == 'YYModel'
|
486
|
+
end
|
487
|
+
```
|
488
|
+
|
489
|
+
**需要注意的是,如果组件有 subspec ,使用组件名作为判断条件应如下**:
|
490
|
+
|
491
|
+
```ruby
|
492
|
+
use_binaries_with_spec_selector! do |spec|
|
493
|
+
spec.name.start_with? == '组件名'
|
494
|
+
end
|
495
|
+
```
|
496
|
+
|
497
|
+
如果像上个代码块一样,**直接对比组件名,则插件会忽略此组件的所有 subspec,导致资源拉取错误**,这种场景下,最好通过 `set_use_source_pods` 语句配置依赖。
|
498
|
+
|
499
|
+
一个实际应用是,三方组件采用二进制版本,团队编写的组件依旧采用源码版本。如果三方组件都在 `cocoapods-repo` 组下,就可以使用以下代码过滤出三方组件:
|
500
|
+
|
501
|
+
```ruby
|
502
|
+
use_binaries_with_spec_selector! do |spec|
|
503
|
+
git = spec.source && spec.source['git']
|
504
|
+
git && git.include?('cocoapods-repo')
|
505
|
+
end
|
506
|
+
```
|
507
|
+
|
459
508
|
#### 其他设置
|
460
509
|
|
461
510
|
插件默认开启多线程下载组件资源,如果要禁用这个功能,Podfile 添加以下代码即可:
|
data/cocoapods-bin.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'parallel'
|
22
22
|
spec.add_dependency 'cocoapods', '~> 1.4'
|
23
|
+
spec.add_dependency 'cocoapods-generate', '~> 1.4'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
26
|
spec.add_development_dependency 'rake'
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'cocoapods-bin/native/podfile'
|
2
|
+
require 'cocoapods/command/gen'
|
3
|
+
require 'cocoapods/generate'
|
4
|
+
require 'cocoapods-bin/helpers/framework_builder'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Command
|
8
|
+
class Bin < Command
|
9
|
+
class Archive < Bin
|
10
|
+
self.summary = '将组件归档为静态 framework.'
|
11
|
+
self.description = <<-DESC
|
12
|
+
将组件归档为静态 framework,仅支持 iOS 平台
|
13
|
+
此静态 framework 不包含依赖组件的 symbol
|
14
|
+
DESC
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
['--code-dependencies', '使用源码依赖'],
|
19
|
+
['--allow-prerelease', '允许使用 prerelease 的版本'],
|
20
|
+
['--use-modular-headers', '使用 modular headers (modulemap)'],
|
21
|
+
['--no-clean', '保留构建中间产物'],
|
22
|
+
['--no-zip', '不压缩静态 framework 为 zip'],
|
23
|
+
].concat(super)
|
24
|
+
end
|
25
|
+
|
26
|
+
self.arguments = [
|
27
|
+
CLAide::Argument.new('NAME.podspec', false),
|
28
|
+
]
|
29
|
+
|
30
|
+
def initialize(argv)
|
31
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
32
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
33
|
+
@clean = argv.flag?('clean', true)
|
34
|
+
@zip = argv.flag?('zip', true)
|
35
|
+
@use_modular_headers = argv.flag?('use-modular-headers')
|
36
|
+
@platform = Platform.new(:ios)
|
37
|
+
super
|
38
|
+
|
39
|
+
@additional_args = argv.remainder!
|
40
|
+
end
|
41
|
+
|
42
|
+
def run
|
43
|
+
@spec = Specification.from_file(spec_file)
|
44
|
+
generate_project
|
45
|
+
build_static_framework
|
46
|
+
zip_static_framework if @zip
|
47
|
+
clean_workspace if @clean
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def generate_project
|
53
|
+
Podfile.execute_with_bin_plugin do
|
54
|
+
Podfile.execute_with_allow_prerelease(@allow_prerelease) do
|
55
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
56
|
+
argvs = [
|
57
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
58
|
+
"--gen-directory=#{gen_name}",
|
59
|
+
'--clean',
|
60
|
+
'--use-libraries',
|
61
|
+
*@additional_args
|
62
|
+
]
|
63
|
+
|
64
|
+
argvs << '--use-modular-headers' if @use_modular_headers
|
65
|
+
argvs << spec_file if spec_file
|
66
|
+
|
67
|
+
gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
|
68
|
+
gen.validate!
|
69
|
+
gen.run
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def zip_static_framework
|
76
|
+
output_name = "#{framework_name}.zip"
|
77
|
+
raise Informative, "没有需要压缩的 framework 文件:#{framework_name}" unless File.exist?(framework_name)
|
78
|
+
|
79
|
+
UI.puts "Compressing #{framework_name} into #{output_name}"
|
80
|
+
|
81
|
+
`zip --symlinks -r #{output_name} #{framework_name}`
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_static_framework
|
85
|
+
source_dir = Dir.pwd
|
86
|
+
file_accessor = Sandbox::FileAccessor.new(Pathname.new(".").expand_path, @spec.consumer(@platform))
|
87
|
+
Dir.chdir(workspace_directory) do
|
88
|
+
builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir)
|
89
|
+
builder.build
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def clean_workspace
|
94
|
+
UI.puts "Cleaning workspace"
|
95
|
+
|
96
|
+
FileUtils.rm_rf(gen_name)
|
97
|
+
FileUtils.rm_rf(framework_name) if @zip
|
98
|
+
end
|
99
|
+
|
100
|
+
def gen_name
|
101
|
+
"bin-archive"
|
102
|
+
end
|
103
|
+
|
104
|
+
def framework_name
|
105
|
+
"#{@spec.name}.framework"
|
106
|
+
end
|
107
|
+
|
108
|
+
def workspace_directory
|
109
|
+
File.expand_path("./#{gen_name}/#{@spec.name}")
|
110
|
+
end
|
111
|
+
|
112
|
+
def spec_file
|
113
|
+
@spec_file ||= begin
|
114
|
+
if @podspec
|
115
|
+
find_spec_file(@podspec)
|
116
|
+
else
|
117
|
+
raise Informative, "当前目录下没有找到可用源码 podspec." if code_spec_files.empty?
|
118
|
+
|
119
|
+
spec_file = code_spec_files.first
|
120
|
+
spec_file
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
class Framework
|
5
|
+
attr_reader :headers_path
|
6
|
+
attr_reader :module_map_path
|
7
|
+
attr_reader :resources_path
|
8
|
+
attr_reader :root_path
|
9
|
+
attr_reader :versions_path
|
10
|
+
|
11
|
+
def initialize(name, platform)
|
12
|
+
@name = name
|
13
|
+
@platform = platform
|
14
|
+
end
|
15
|
+
|
16
|
+
def make
|
17
|
+
make_root
|
18
|
+
make_framework
|
19
|
+
make_headers
|
20
|
+
make_resources
|
21
|
+
make_current_version
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_resources
|
25
|
+
Pathname.new(@resources_path).rmtree
|
26
|
+
(Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def make_current_version
|
32
|
+
current_version_path = @versions_path + Pathname.new('../Current')
|
33
|
+
`ln -sf A #{current_version_path}`
|
34
|
+
`ln -sf Versions/Current/Headers #{@fwk_path}/`
|
35
|
+
`ln -sf Versions/Current/Resources #{@fwk_path}/`
|
36
|
+
`ln -sf Versions/Current/#{@name} #{@fwk_path}/`
|
37
|
+
end
|
38
|
+
|
39
|
+
def make_framework
|
40
|
+
@fwk_path = @root_path + Pathname.new(@name + '.framework')
|
41
|
+
@fwk_path.mkdir unless @fwk_path.exist?
|
42
|
+
|
43
|
+
@module_map_path = @fwk_path + Pathname.new('Modules')
|
44
|
+
@versions_path = @fwk_path + Pathname.new('Versions/A')
|
45
|
+
end
|
46
|
+
|
47
|
+
def make_headers
|
48
|
+
@headers_path = @versions_path + Pathname.new('Headers')
|
49
|
+
@headers_path.mkpath unless @headers_path.exist?
|
50
|
+
end
|
51
|
+
|
52
|
+
def make_resources
|
53
|
+
@resources_path = @versions_path + Pathname.new('Resources')
|
54
|
+
@resources_path.mkpath unless @resources_path.exist?
|
55
|
+
end
|
56
|
+
|
57
|
+
def make_root
|
58
|
+
@root_path = Pathname.new(@platform)
|
59
|
+
@root_path.mkpath unless @root_path.exist?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
2
|
+
|
3
|
+
require 'cocoapods-bin/helpers/framework.rb'
|
4
|
+
|
5
|
+
module CBin
|
6
|
+
class Framework
|
7
|
+
class Builder
|
8
|
+
include Pod
|
9
|
+
|
10
|
+
def initialize(spec, file_accessor, platform, source_dir)
|
11
|
+
@spec = spec
|
12
|
+
@source_dir = source_dir
|
13
|
+
@file_accessor = file_accessor
|
14
|
+
@platform = platform
|
15
|
+
@vendored_libraries = (file_accessor.vendored_static_frameworks + file_accessor.vendored_static_libraries).map(&:to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
def build
|
19
|
+
UI.section("Building static framework #{@spec}") do
|
20
|
+
defines = compile
|
21
|
+
|
22
|
+
build_sim_libraries(defines)
|
23
|
+
output = framework.versions_path + Pathname.new(@spec.name)
|
24
|
+
build_static_library_for_ios(output)
|
25
|
+
|
26
|
+
copy_headers
|
27
|
+
copy_license
|
28
|
+
copy_resources
|
29
|
+
|
30
|
+
cp_to_source_dir
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def cp_to_source_dir
|
37
|
+
target_dir = "#{@source_dir}/#{@spec.name}.framework"
|
38
|
+
FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
|
39
|
+
|
40
|
+
`cp -fa #{@platform.to_s}/#{@spec.name}.framework #{@source_dir}`
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_sim_libraries(defines)
|
44
|
+
UI.message 'Building simulator libraries'
|
45
|
+
xcodebuild(defines, '-sdk iphonesimulator', 'build-simulator')
|
46
|
+
end
|
47
|
+
|
48
|
+
def copy_headers
|
49
|
+
public_headers = @file_accessor.public_headers
|
50
|
+
UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
|
51
|
+
|
52
|
+
public_headers.each do |h|
|
53
|
+
`ditto #{h} #{framework.headers_path}/#{h.basename}`
|
54
|
+
end
|
55
|
+
|
56
|
+
# If custom 'module_map' is specified add it to the framework distribution
|
57
|
+
# otherwise check if a header exists that is equal to 'spec.name', if so
|
58
|
+
# create a default 'module_map' one using it.
|
59
|
+
if !@spec.module_map.nil?
|
60
|
+
module_map_file = @file_accessor.module_map
|
61
|
+
module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
|
62
|
+
elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}.h")
|
63
|
+
module_map = <<-MAP
|
64
|
+
framework module #{@spec.name} {
|
65
|
+
umbrella header "#{@spec.name}.h"
|
66
|
+
|
67
|
+
export *
|
68
|
+
module * { export * }
|
69
|
+
}
|
70
|
+
MAP
|
71
|
+
end
|
72
|
+
|
73
|
+
unless module_map.nil?
|
74
|
+
UI.message "Writing module map #{module_map}"
|
75
|
+
framework.module_map_path.mkpath unless framework.module_map_path.exist?
|
76
|
+
File.write("#{framework.module_map_path}/module.modulemap", module_map)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def copy_license
|
81
|
+
UI.message "Copying license"
|
82
|
+
license_file = @spec.license[:file] || 'LICENSE'
|
83
|
+
`cp "#{license_file}" .` if Pathname(license_file).exist?
|
84
|
+
end
|
85
|
+
|
86
|
+
def copy_resources
|
87
|
+
bundles = Dir.glob("./build/*.bundle")
|
88
|
+
|
89
|
+
bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
90
|
+
consumer = spec.consumer(@platform)
|
91
|
+
consumer.resource_bundles.keys +
|
92
|
+
consumer.resources.map do |r|
|
93
|
+
File.basename(r, '.bundle') if File.extname(r) == 'bundle'
|
94
|
+
end
|
95
|
+
end.compact.uniq
|
96
|
+
|
97
|
+
bundles.select! do |bundle|
|
98
|
+
bundle_name = File.basename(bundle, '.bundle')
|
99
|
+
bundle_names.include?(bundle_name)
|
100
|
+
end
|
101
|
+
|
102
|
+
if bundles.count > 0
|
103
|
+
UI.message "Copying bundle files #{bundles}"
|
104
|
+
bundle_files = bundles.join(' ')
|
105
|
+
`cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
|
106
|
+
end
|
107
|
+
|
108
|
+
resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
109
|
+
expand_paths(spec.consumer(@platform).resources)
|
110
|
+
end.compact.uniq
|
111
|
+
|
112
|
+
if resources.count == 0 && bundles.count == 0
|
113
|
+
framework.delete_resources
|
114
|
+
return
|
115
|
+
end
|
116
|
+
if resources.count > 0
|
117
|
+
UI.message "Copying resources #{resources}"
|
118
|
+
`cp -rp #{resources.join(' ')} #{framework.resources_path}`
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def static_libs_in_sandbox(build_dir = 'build')
|
123
|
+
Dir.glob("#{build_dir}/lib#{@spec.name}.a")
|
124
|
+
end
|
125
|
+
|
126
|
+
def build_static_library_for_ios(output)
|
127
|
+
UI.message "Building ios libraries with archs #{ios_architectures}"
|
128
|
+
static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-simulator') + @vendored_libraries
|
129
|
+
libs = ios_architectures.map do |arch|
|
130
|
+
library = "build/package-#{arch}.a"
|
131
|
+
`libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
|
132
|
+
library
|
133
|
+
end
|
134
|
+
|
135
|
+
`lipo -create -output #{output} #{libs.join(' ')}`
|
136
|
+
end
|
137
|
+
|
138
|
+
def ios_build_options
|
139
|
+
"ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
|
140
|
+
end
|
141
|
+
|
142
|
+
def ios_architectures
|
143
|
+
archs = %w(x86_64 arm64 armv7 armv7s)
|
144
|
+
@vendored_libraries.each do |library|
|
145
|
+
archs = `lipo -info #{library}`.split & archs
|
146
|
+
end
|
147
|
+
archs
|
148
|
+
end
|
149
|
+
|
150
|
+
def compile
|
151
|
+
defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited)'"
|
152
|
+
defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
|
153
|
+
|
154
|
+
options = ios_build_options
|
155
|
+
xcodebuild(defines, options)
|
156
|
+
|
157
|
+
defines
|
158
|
+
end
|
159
|
+
|
160
|
+
def xcodebuild(defines = '', args = '', build_dir = 'build')
|
161
|
+
command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration Release -target #{@spec.name} -project ./Pods.xcodeproj 2>&1"
|
162
|
+
output = `#{command}`.lines.to_a
|
163
|
+
|
164
|
+
if $?.exitstatus != 0
|
165
|
+
raise <<-EOF
|
166
|
+
Build command failed: #{command}
|
167
|
+
Output:
|
168
|
+
#{output.map { |line| " #{line}" }.join}
|
169
|
+
EOF
|
170
|
+
|
171
|
+
Process.exit
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def expand_paths(path_specs)
|
176
|
+
path_specs.map do |path_spec|
|
177
|
+
Dir.glob(File.join(@source_dir, path_spec))
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def framework
|
182
|
+
@framework ||= begin
|
183
|
+
framework = Framework.new(@spec.name, @platform.name.to_s)
|
184
|
+
framework.make
|
185
|
+
framework
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -25,7 +25,7 @@ module CBin
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def sources_option(code_dependencies, additional_sources)
|
28
|
-
(valid_sources(code_dependencies).map(&:
|
28
|
+
(valid_sources(code_dependencies).map(&:url) + Array(additional_sources)).join(',')
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,6 +1,29 @@
|
|
1
|
+
require 'cocoapods-bin/native/sources_manager'
|
2
|
+
|
1
3
|
module Pod
|
2
4
|
class Specification
|
3
5
|
VALID_EXTNAME = %w[.binary.podspec.json .binary.podspec .podspec.json .podspec]
|
4
6
|
DEFAULT_TEMPLATE_EXTNAME = %w[.binary-template.podspec .binary-template.podspec.json]
|
7
|
+
|
8
|
+
# TODO
|
9
|
+
# 可以在这里根据组件依赖二进制或源码调整 sources 的先后顺序
|
10
|
+
# 如果是源码,则调整 code_source 到最前面
|
11
|
+
# 如果是二进制,则调整 binary_source 到最前面
|
12
|
+
# 这样 CocoaPods 分析时,就会优先获取到对应源的 podspec
|
13
|
+
#
|
14
|
+
# 先要把 Podfile 里面的配置数据保存到单例中,再在这里判断,就不需要 resolver 了
|
15
|
+
# 但是现在这个插件依旧可用,重构需要时间 = = ,没什么动力去重构了呀。。。
|
16
|
+
#
|
17
|
+
# class Set
|
18
|
+
# old_initialize = instance_method(:initialize)
|
19
|
+
# define_method(:initialize) do |name, sources|
|
20
|
+
# if name == 'TDFAdaptationKit'
|
21
|
+
# sources_manager = Pod::Config.instance.sources_manager
|
22
|
+
# # sources = [sources_manager.binary_source, *sources].uniq
|
23
|
+
# sources = [sources_manager.code_source, *sources].uniq
|
24
|
+
# end
|
25
|
+
# old_initialize.bind(self).call(name, sources)
|
26
|
+
# end
|
27
|
+
# end
|
5
28
|
end
|
6
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tripleCC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cocoapods-generate
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,6 +98,7 @@ files:
|
|
84
98
|
- lib/cocoapods-bin.rb
|
85
99
|
- lib/cocoapods-bin/command.rb
|
86
100
|
- lib/cocoapods-bin/command/bin.rb
|
101
|
+
- lib/cocoapods-bin/command/bin/archive.rb
|
87
102
|
- lib/cocoapods-bin/command/bin/init.rb
|
88
103
|
- lib/cocoapods-bin/command/bin/lib.rb
|
89
104
|
- lib/cocoapods-bin/command/bin/lib/lint.rb
|
@@ -100,6 +115,8 @@ files:
|
|
100
115
|
- lib/cocoapods-bin/config/config_asker.rb
|
101
116
|
- lib/cocoapods-bin/gem_version.rb
|
102
117
|
- lib/cocoapods-bin/helpers.rb
|
118
|
+
- lib/cocoapods-bin/helpers/framework.rb
|
119
|
+
- lib/cocoapods-bin/helpers/framework_builder.rb
|
103
120
|
- lib/cocoapods-bin/helpers/sources_helper.rb
|
104
121
|
- lib/cocoapods-bin/helpers/spec_creator.rb
|
105
122
|
- lib/cocoapods-bin/helpers/spec_files_helper.rb
|