cocoapods-bb-bin 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.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +19 -0
  3. data/README.md +68 -0
  4. data/lib/cocoapods-bb-bin/command/bin/archive.rb +234 -0
  5. data/lib/cocoapods-bb-bin/command/bin/auto.rb +226 -0
  6. data/lib/cocoapods-bb-bin/command/bin/code.rb +295 -0
  7. data/lib/cocoapods-bb-bin/command/bin/dup.rb +78 -0
  8. data/lib/cocoapods-bb-bin/command/bin/imy.rb +46 -0
  9. data/lib/cocoapods-bb-bin/command/bin/init.rb +69 -0
  10. data/lib/cocoapods-bb-bin/command/bin/initHotKey.rb +70 -0
  11. data/lib/cocoapods-bb-bin/command/bin/install.rb +44 -0
  12. data/lib/cocoapods-bb-bin/command/bin/lib/lint.rb +69 -0
  13. data/lib/cocoapods-bb-bin/command/bin/repo/update.rb +43 -0
  14. data/lib/cocoapods-bb-bin/command/bin/spec/create.rb +73 -0
  15. data/lib/cocoapods-bb-bin/command/bin/spec/push.rb +114 -0
  16. data/lib/cocoapods-bb-bin/command/bin/update.rb +154 -0
  17. data/lib/cocoapods-bb-bin/command/bin.rb +59 -0
  18. data/lib/cocoapods-bb-bin/command.rb +2 -0
  19. data/lib/cocoapods-bb-bin/config/config.rb +136 -0
  20. data/lib/cocoapods-bb-bin/config/config_asker.rb +57 -0
  21. data/lib/cocoapods-bb-bin/config/config_builder.rb +234 -0
  22. data/lib/cocoapods-bb-bin/config/config_hot_key.rb +102 -0
  23. data/lib/cocoapods-bb-bin/config/config_hot_key_asker.rb +57 -0
  24. data/lib/cocoapods-bb-bin/gem_version.rb +10 -0
  25. data/lib/cocoapods-bb-bin/helpers/Info.plist +0 -0
  26. data/lib/cocoapods-bb-bin/helpers/build_helper.rb +217 -0
  27. data/lib/cocoapods-bb-bin/helpers/build_utils.rb +63 -0
  28. data/lib/cocoapods-bb-bin/helpers/framework.rb +85 -0
  29. data/lib/cocoapods-bb-bin/helpers/framework_builder.rb +446 -0
  30. data/lib/cocoapods-bb-bin/helpers/library.rb +54 -0
  31. data/lib/cocoapods-bb-bin/helpers/library_builder.rb +90 -0
  32. data/lib/cocoapods-bb-bin/helpers/sources_helper.rb +36 -0
  33. data/lib/cocoapods-bb-bin/helpers/spec_creator.rb +170 -0
  34. data/lib/cocoapods-bb-bin/helpers/spec_files_helper.rb +77 -0
  35. data/lib/cocoapods-bb-bin/helpers/spec_source_creator.rb +227 -0
  36. data/lib/cocoapods-bb-bin/helpers/upload_helper.rb +96 -0
  37. data/lib/cocoapods-bb-bin/helpers/xcframework_builder.rb +77 -0
  38. data/lib/cocoapods-bb-bin/helpers.rb +5 -0
  39. data/lib/cocoapods-bb-bin/native/acknowledgements.rb +27 -0
  40. data/lib/cocoapods-bb-bin/native/analyzer.rb +55 -0
  41. data/lib/cocoapods-bb-bin/native/file_accessor.rb +28 -0
  42. data/lib/cocoapods-bb-bin/native/installation_options.rb +25 -0
  43. data/lib/cocoapods-bb-bin/native/installer.rb +135 -0
  44. data/lib/cocoapods-bb-bin/native/linter.rb +26 -0
  45. data/lib/cocoapods-bb-bin/native/path_source.rb +33 -0
  46. data/lib/cocoapods-bb-bin/native/pod_source_installer.rb +19 -0
  47. data/lib/cocoapods-bb-bin/native/pod_target_installer.rb +94 -0
  48. data/lib/cocoapods-bb-bin/native/podfile.rb +91 -0
  49. data/lib/cocoapods-bb-bin/native/podfile_env.rb +37 -0
  50. data/lib/cocoapods-bb-bin/native/podfile_generator.rb +199 -0
  51. data/lib/cocoapods-bb-bin/native/podspec_finder.rb +25 -0
  52. data/lib/cocoapods-bb-bin/native/resolver.rb +230 -0
  53. data/lib/cocoapods-bb-bin/native/sandbox_analyzer.rb +34 -0
  54. data/lib/cocoapods-bb-bin/native/source.rb +35 -0
  55. data/lib/cocoapods-bb-bin/native/sources_manager.rb +20 -0
  56. data/lib/cocoapods-bb-bin/native/specification.rb +31 -0
  57. data/lib/cocoapods-bb-bin/native/target_validator.rb +41 -0
  58. data/lib/cocoapods-bb-bin/native/validator.rb +40 -0
  59. data/lib/cocoapods-bb-bin/native.rb +23 -0
  60. data/lib/cocoapods-bb-bin/source_provider_hook.rb +66 -0
  61. data/lib/cocoapods-bb-bin.rb +2 -0
  62. data/lib/cocoapods_plugin.rb +3 -0
  63. data/spec/command/bin_spec.rb +12 -0
  64. data/spec/spec_helper.rb +51 -0
  65. metadata +200 -0
@@ -0,0 +1,36 @@
1
+
2
+
3
+ require 'cocoapods-bb-bin/native/sources_manager.rb'
4
+
5
+ module CBin
6
+ module SourcesHelper
7
+ def sources_manager
8
+ Pod::Config.instance.sources_manager
9
+ end
10
+
11
+ def binary_source
12
+ sources_manager.binary_source
13
+ end
14
+
15
+ def code_source
16
+ sources_manager.code_source
17
+ end
18
+
19
+ # 优先采用对应依赖的 source
20
+ # cocoapods 内部会先匹配前面符合的 specification
21
+ # 只允许二进制的 specification subspec 比源码的 specification subspec 多
22
+ #
23
+ def valid_sources(code_dependencies = false)
24
+ sources = [code_source]
25
+ unless code_dependencies
26
+ sources << binary_source
27
+ sources.reverse!
28
+ end
29
+ sources
30
+ end
31
+
32
+ def sources_option(code_dependencies, additional_sources)
33
+ (valid_sources(code_dependencies).map(&:url) + Array(additional_sources)).join(',')
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,170 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-bb-bin/config/config'
5
+
6
+ module CBin
7
+ class Specification
8
+ class Creator
9
+ attr_reader :code_spec
10
+ attr_reader :template_spec
11
+ attr_reader :spec
12
+
13
+ def initialize(code_spec, template_spec, platforms = 'ios')
14
+ @code_spec = code_spec
15
+ @template_spec = template_spec
16
+ @platforms = Array(platforms)
17
+ validate!
18
+ end
19
+
20
+ def validate!
21
+ raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
22
+ if code_spec.subspecs.any? && template_spec.nil?
23
+ raise Pod::Informative, "不支持自动生成存在 subspec 的二进制 podspec , 需要提供模版文件 #{code_spec.name}.binary.podspec.template ."
24
+ end
25
+ end
26
+
27
+ def create
28
+ spec = template_spec ? create_from_code_spec_and_template_spec : create_from_code_spec
29
+
30
+ Pod::UI.message '生成二进制 podspec 内容: '
31
+ spec.to_pretty_json.split("\n").each do |text|
32
+ Pod::UI.message text
33
+ end
34
+
35
+ spec
36
+ end
37
+
38
+ def write_spec_file(file = filename)
39
+ create unless spec
40
+
41
+ File.open(file, 'w+') do |f|
42
+ f.write(spec.to_pretty_json)
43
+ end
44
+
45
+ @filename = file
46
+ end
47
+
48
+ def clear_spec_file
49
+ File.delete(filename) if File.exist?(filename)
50
+ end
51
+
52
+ def filename
53
+ @filename ||= "#{spec.name}.binary.podspec.json"
54
+ end
55
+
56
+ private
57
+
58
+ def create_from_code_spec
59
+ @spec = code_spec.dup
60
+ # vendored_frameworks | resources | source | source_files | public_header_files
61
+ # license | resource_bundles | vendored_libraries
62
+
63
+ # Project Linkin
64
+ @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
65
+
66
+ # Resources
67
+ extnames = []
68
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
69
+ if code_spec_consumer.resources.any?
70
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
71
+ end
72
+ if extnames.any?
73
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
74
+ end
75
+
76
+ # Source Location
77
+ @spec.source = binary_source
78
+
79
+ # Source Code
80
+ @spec.source_files = framework_contents('Headers/*')
81
+ @spec.public_header_files = framework_contents('Headers/*')
82
+
83
+ # Unused for binary
84
+ spec_hash = @spec.to_hash
85
+ # spec_hash.delete('license')
86
+ spec_hash.delete('resource_bundles')
87
+ spec_hash.delete('exclude_files')
88
+ spec_hash.delete('preserve_paths')
89
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
90
+ # 如果是静态库的话,需要移除,否则就不移除
91
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
92
+ # 这里统一只对命名后缀 .a 文件做处理
93
+ # spec_hash.delete('vendored_libraries')
94
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
95
+ spec_hash.delete('vendored_libraries')
96
+ spec_hash['vendored_libraries'] = binary_vendored_libraries
97
+
98
+ # vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
99
+ # if vendored_libraries.any?
100
+ # spec_hash['vendored_libraries'] = vendored_libraries
101
+ # end
102
+
103
+ # Filter platforms
104
+ platforms = spec_hash['platforms']
105
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
106
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
107
+
108
+ @spec = Pod::Specification.from_hash(spec_hash)
109
+ @spec
110
+ end
111
+
112
+ def create_from_code_spec_and_template_spec
113
+ @spec = template_spec.dup
114
+
115
+ @spec.version = code_spec.version
116
+ @spec.source = binary_source
117
+
118
+ @spec.source_files = binary_source_files
119
+ @spec.public_header_files = binary_public_header_files
120
+ @spec.vendored_libraries = binary_vendored_libraries
121
+
122
+ @spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
123
+
124
+
125
+
126
+ @spec
127
+ end
128
+
129
+ def binary_source
130
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
131
+ end
132
+
133
+ def code_spec_consumer(_platform = :ios)
134
+ code_spec.consumer(:ios)
135
+ end
136
+
137
+ def framework_contents(name)
138
+ ["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
139
+ end
140
+
141
+ def binary_source_files
142
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
143
+ end
144
+
145
+ def binary_source_files
146
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
147
+ end
148
+
149
+ def binary_public_header_files
150
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
151
+ end
152
+
153
+ def binary_vendored_libraries
154
+ "bin_#{code_spec.name}_#{code_spec.version}/*.a"
155
+ end
156
+
157
+ def binary_resources
158
+ "bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
159
+ end
160
+
161
+ end
162
+ end
163
+ end
164
+ #模板框架begin
165
+ # s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
166
+ # s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
167
+ # s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
168
+ #有图片资源的,要带上
169
+ #s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
170
+ #模板框架end
@@ -0,0 +1,77 @@
1
+
2
+
3
+ require 'cocoapods-bb-bin/native/sources_manager.rb'
4
+ require 'cocoapods-bb-bin/helpers/spec_creator'
5
+
6
+ module CBin
7
+ module SpecFilesHelper
8
+ def spec_files
9
+ @spec_files ||= Pathname.glob('*.podspec{,.json}')
10
+ end
11
+
12
+ def binary_spec_files
13
+ @binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}')
14
+ end
15
+
16
+ def binary_template_spec_files
17
+ @binary_spec_template_files ||= Pathname.glob('*.binary-template.podspec{,.json}')
18
+ end
19
+
20
+ def binary_template_spec_file
21
+ @binary_spec_template_file ||= binary_template_spec_files.first
22
+ end
23
+
24
+ def code_spec_files
25
+ @code_spec_files ||= spec_files - binary_spec_files - binary_template_spec_files
26
+ end
27
+
28
+ def code_spec
29
+ if code_spec_files.first
30
+ Pod::Specification.from_file(code_spec_files.first)
31
+ end
32
+ end
33
+
34
+ def binary_spec
35
+ if binary_spec_files.first
36
+ Pod::Specification.from_file(binary_spec_files.first)
37
+ end
38
+ end
39
+
40
+ def binary_template_spec
41
+ if binary_template_spec_file
42
+ Pod::Specification.from_file(binary_template_spec_file)
43
+ end
44
+ end
45
+
46
+ def find_spec_file(podspec)
47
+ path = Pathname(podspec)
48
+ raise Pod::Informative, "无法找到 #{podspec}" unless path.exist?
49
+
50
+ path
51
+ end
52
+
53
+ def create_binary_spec_file(code_spec, template_spec)
54
+ # 1. code spec 是否有 subpsec
55
+ # 1.1 有,查找 template spec,并生成
56
+ # 1.2 没有,是否有 template spec
57
+ # 1.2.1 有,根据 template spec 生成
58
+ # 1.2.2 没有,根据 code spec 生成
59
+
60
+ unless code_spec
61
+ raise Pod::Informative, '没有二进制 podspec 的情况下,必须要提供源码 podspec.'
62
+ end
63
+ if code_spec.subspecs.any? && template_spec.nil?
64
+ raise Pod::Informative, '拥有 subspec 的组件,在生成二进制 podspec 时,必须要提供模版 podspec.'
65
+ end
66
+
67
+ @spec_creator = CBin::Specification::Creator.new(code_spec, template_spec)
68
+ @spec_creator.create
69
+ @spec_creator.write_spec_file
70
+ @spec_creator.filename
71
+ end
72
+
73
+ def clear_binary_spec_file_if_needed
74
+ @spec_creator&.clear_spec_file
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,227 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-bb-bin/config/config'
5
+
6
+ module CBin
7
+ class SpecificationSource
8
+ class Creator
9
+ attr_reader :code_spec
10
+ attr_reader :spec
11
+
12
+ def initialize(code_spec, platforms = 'ios')
13
+ @code_spec = code_spec
14
+ @platforms = Array(platforms)
15
+ validate!
16
+ end
17
+
18
+ def validate!
19
+ raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
20
+ end
21
+
22
+ def create
23
+ # spec = nil
24
+ if CBin::Build::Utils.is_framework(@code_spec)
25
+ spec = create_framework_from_code_spec
26
+ else
27
+ spec = create_from_code_spec
28
+ end
29
+
30
+ spec
31
+ end
32
+
33
+ def write_spec_file(file = filename)
34
+ create unless spec
35
+
36
+ FileUtils.mkdir_p(CBin::Config::Builder.instance.binary_json_dir) unless File.exist?(CBin::Config::Builder.instance.binary_json_dir)
37
+ FileUtils.rm_rf(file) if File.exist?(file)
38
+
39
+ File.open(file, 'w+') do |f|
40
+ f.write(spec.to_pretty_json)
41
+ end
42
+
43
+ @filename = file
44
+ end
45
+
46
+ def clear_spec_file
47
+ File.delete(filename) if File.exist?(filename)
48
+ end
49
+
50
+ def filename
51
+ @filename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json"
52
+ end
53
+
54
+ private
55
+
56
+ def create_from_code_spec
57
+ @spec = code_spec.dup
58
+ # vendored_frameworks | resources | source | source_files | public_header_files
59
+ # license | resource_bundles | vendored_libraries
60
+
61
+ # Project Linkin
62
+ # @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
63
+
64
+ # Resources
65
+ extnames = []
66
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
67
+ if code_spec_consumer.resources.any?
68
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
69
+ end
70
+ if extnames.any?
71
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
72
+ end
73
+
74
+ # Source Location
75
+ @spec.source = binary_source
76
+
77
+ # Source Code
78
+ # @spec.source_files = framework_contents('Headers/*')
79
+ # @spec.public_header_files = framework_contents('Headers/*')
80
+
81
+ # Unused for binary
82
+ spec_hash = @spec.to_hash
83
+ # spec_hash.delete('license')
84
+ spec_hash.delete('resource_bundles')
85
+ spec_hash.delete('exclude_files')
86
+ spec_hash.delete('preserve_paths')
87
+
88
+ spec_hash.delete('subspecs')
89
+ spec_hash.delete('default_subspecs')
90
+ spec_hash.delete('default_subspec')
91
+ spec_hash.delete('vendored_frameworks')
92
+ spec_hash.delete('vendored_framework')
93
+
94
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
95
+ # 如果是静态库的话,需要移除,否则就不移除
96
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
97
+ # 这里统一只对命名后缀 .a 文件做处理
98
+ # spec_hash.delete('vendored_libraries')
99
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
100
+ spec_hash.delete('vendored_libraries')
101
+
102
+ # vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
103
+ # if vendored_libraries.any?
104
+ # spec_hash['vendored_libraries'] = vendored_libraries
105
+ # end
106
+
107
+ # Filter platforms
108
+ platforms = spec_hash['platforms']
109
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
110
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
111
+
112
+ @spec = Pod::Specification.from_hash(spec_hash)
113
+
114
+ #把命令 prepare_command 移除掉,如ReactiveCocoa会执行修改重命令的脚步
115
+ @spec.prepare_command = "" if @spec.prepare_command
116
+ @spec.version = code_spec.version
117
+ @spec.source = binary_source
118
+ @spec.source_files = binary_source_files
119
+ @spec.public_header_files = binary_public_header_files
120
+ @spec.vendored_libraries = binary_vendored_libraries
121
+ @spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
122
+ @spec.description = <<-EOF
123
+ converted automatically by plugin optimization
124
+ #{@spec.description}
125
+ EOF
126
+ @spec
127
+ end
128
+
129
+ def create_framework_from_code_spec
130
+ @spec = code_spec.dup
131
+ # vendored_frameworks | resources | source | source_files | public_header_files
132
+ # license | resource_bundles | vendored_libraries
133
+
134
+ # Project Linkin
135
+ @spec.vendored_frameworks = "#{code_spec.root.name}.{framework,xcframework}" # 支持framework、xcframework
136
+
137
+ # Resources
138
+ extnames = []
139
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
140
+ if code_spec_consumer.resources.any?
141
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
142
+ end
143
+ if extnames.any?
144
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
145
+ end
146
+
147
+ # Source Location
148
+ @spec.source = binary_source
149
+
150
+ # Source Code
151
+ # @spec.source_files = framework_contents('Headers/*')
152
+ # @spec.public_header_files = framework_contents('Headers/*')
153
+
154
+ # Unused for binary
155
+ spec_hash = @spec.to_hash
156
+ # spec_hash.delete('license')
157
+ spec_hash.delete('resource_bundles')
158
+ spec_hash.delete('exclude_files')
159
+ spec_hash.delete('preserve_paths')
160
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
161
+ # 如果是静态库的话,需要移除,否则就不移除
162
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
163
+ # 这里统一只对命名后缀 .a 文件做处理
164
+ # spec_hash.delete('vendored_libraries')
165
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
166
+ vendored_libraries = spec_hash.delete('vendored_libraries')
167
+ vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
168
+ if vendored_libraries.any?
169
+ spec_hash['vendored_libraries'] = vendored_libraries
170
+ end
171
+
172
+ # Filter platforms
173
+ platforms = spec_hash['platforms']
174
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
175
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
176
+
177
+ @spec = Pod::Specification.from_hash(spec_hash)
178
+ @spec.description = <<-EOF
179
+ converted automatically by plugin optimization
180
+ #{@spec.description}
181
+ EOF
182
+ @spec
183
+ end
184
+
185
+
186
+ def binary_source
187
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
188
+ end
189
+
190
+ def code_spec_consumer(_platform = :ios)
191
+ code_spec.consumer(:ios)
192
+ end
193
+
194
+ def framework_contents(name)
195
+ ["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
196
+ end
197
+
198
+ def binary_source_files
199
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
200
+ end
201
+
202
+ def binary_source_files
203
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
204
+ end
205
+
206
+ def binary_public_header_files
207
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
208
+ end
209
+
210
+ def binary_vendored_libraries
211
+ "bin_#{code_spec.name}_#{code_spec.version}/*.a"
212
+ end
213
+
214
+ def binary_resources
215
+ "bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
216
+ end
217
+
218
+ end
219
+ end
220
+ end
221
+ #模板框架begin
222
+ # s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
223
+ # s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
224
+ # s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
225
+ #有图片资源的,要带上
226
+ #s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
227
+ #模板框架end
@@ -0,0 +1,96 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ require 'cocoapods-bb-bin/native/podfile'
6
+ require 'cocoapods/command/gen'
7
+ require 'cocoapods/generate'
8
+ require 'cocoapods-bb-bin/helpers/framework_builder'
9
+ require 'cocoapods-bb-bin/helpers/library_builder'
10
+ require 'cocoapods-bb-bin/helpers/sources_helper'
11
+ require 'cocoapods-bb-bin/command/bin/spec/push'
12
+
13
+ module CBin
14
+ class Upload
15
+ class Helper
16
+ include CBin::SourcesHelper
17
+
18
+ def initialize(spec,code_dependencies,sources)
19
+ @spec = spec
20
+ @code_dependencies = code_dependencies
21
+ @sources = sources
22
+ end
23
+
24
+ def upload
25
+ Dir.chdir(CBin::Config::Builder.instance.root_dir) do
26
+ # 创建binary-template.podsepc
27
+ # 上传二进制文件
28
+ # 上传二进制 podspec
29
+ res_zip = curl_zip
30
+ if res_zip
31
+ filename = spec_creator
32
+ push_binary_repo(filename)
33
+ end
34
+ res_zip
35
+ end
36
+ end
37
+
38
+ def spec_creator
39
+ spec_creator = CBin::SpecificationSource::Creator.new(@spec)
40
+ spec_creator.create
41
+ spec_creator.write_spec_file
42
+ spec_creator.filename
43
+ end
44
+
45
+ #推送二进制
46
+ # curl http://ci.xxx:9192/frameworks -F "name=IMYFoundation" -F "version=7.7.4.2" -F "annotate=IMYFoundation_7.7.4.2_log" -F "file=@bin_zip/bin_IMYFoundation_7.7.4.2.zip"
47
+ def curl_zip
48
+ # lib
49
+ zip_file = "#{CBin::Config::Builder.instance.library_file(@spec)}.zip"
50
+ res = File.exist?(zip_file)
51
+ unless res
52
+ # framework
53
+ zip_file = CBin::Config::Builder.instance.framework_zip_file(@spec) + ".zip"
54
+ res = File.exist?(zip_file)
55
+ end
56
+ unless res
57
+ # xcframework
58
+ zip_file = CBin::Config::Builder.instance.xcframework_zip_file(@spec) + ".zip"
59
+ res = File.exist?(zip_file)
60
+ end
61
+ if res
62
+ print <<EOF
63
+ 上传二进制文件
64
+ curl #{CBin.config.binary_upload_url} -F "name=#{@spec.name}" -F "version=#{@spec.version}" -F "annotate=#{@spec.name}_#{@spec.version}_log" -F "file=@#{zip_file}"
65
+ EOF
66
+ `curl #{CBin.config.binary_upload_url} -F "name=#{@spec.name}" -F "version=#{@spec.version}" -F "annotate=#{@spec.name}_#{@spec.version}_log" -F "file=@#{zip_file}"` if res
67
+ end
68
+
69
+ res
70
+ end
71
+
72
+
73
+ # 上传二进制 podspec
74
+ def push_binary_repo(binary_podsepc_json)
75
+ argvs = [
76
+ "#{binary_podsepc_json}",
77
+ "--binary",
78
+ "--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
79
+ "--skip-import-validation",
80
+ "--use-libraries",
81
+ "--allow-warnings",
82
+ "--verbose",
83
+ "--code-dependencies"
84
+ ]
85
+ if @verbose
86
+ argvs += ['--verbose']
87
+ end
88
+
89
+ push = Pod::Command::Bin::Repo::Push.new(CLAide::ARGV.new(argvs))
90
+ push.validate!
91
+ push.run
92
+ end
93
+
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,77 @@
1
+ # copy from https://github.com/humin1102/cocoapods-bb-xcframework
2
+
3
+ require 'cocoapods/command/gen'
4
+ require 'cocoapods/generate'
5
+
6
+ require 'cocoapods-framework/config'
7
+ require 'cocoapods-framework/util'
8
+ require 'cocoapods-framework/xbuilder'
9
+ require 'cocoapods-framework/frameworker'
10
+ require 'cocoapods-framework/muti_frameworker'
11
+ #这个放在最后一个
12
+ require 'cocoapods-framework/command'
13
+
14
+ module CBin
15
+ class XCFramework
16
+ class XCBuilder
17
+ include Pod
18
+ include Pod::Config::Mixin
19
+ def initialize(spec,spec_sources)
20
+ @spec = spec
21
+ @spec_sources = spec_sources.split(',') unless spec_sources.nil?
22
+ @name = "#{@spec.name}.podspec"
23
+ @source = nil
24
+ @subspecs = nil
25
+ @configuration = 'Release'
26
+ @use_modular_headers = true
27
+ @force = true
28
+ @use_static_library = true
29
+ @enable_bitcode = false
30
+
31
+ target_dir = "#{Dir.pwd}/#{@spec.name}-#{@spec.version}"
32
+ UI.puts "build initialize...#{spec} target_dir:#{target_dir}"
33
+ UI.puts "spec_sources:#{spec_sources}"
34
+ UI.puts "spec_sources:#{@spec_sources}"
35
+ end
36
+
37
+ def build
38
+ UI.section("Building static xcframework #{@spec}") do
39
+ config.static_library_enable = @use_static_library # 一定要配置 true,否则调用xcframework生成命令无效
40
+ frameworker = Frameworker.new(@name, @source, @spec_sources, @subspecs, @configuration, @force, @use_modular_headers, @enable_bitcode)
41
+ frameworker.run
42
+ # 拷贝
43
+ cp_to_source_dir
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def framework_folder_path
50
+ target_dir = "#{Dir.pwd}/#{@spec.name}-#{@spec.version}"
51
+ return target_dir
52
+ end
53
+
54
+ def framework_name
55
+ framework_name = "#{@spec.name}.xcframework"
56
+ return framework_name
57
+ end
58
+
59
+ def framework_file_path
60
+ target_dir = File.join(framework_folder_path,framework_name)
61
+ return target_dir
62
+ end
63
+
64
+ def cp_to_source_dir
65
+
66
+ target_dir = File.join(CBin::Config::Builder.instance.zip_dir,framework_name)
67
+ FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
68
+
69
+ zip_dir = CBin::Config::Builder.instance.zip_dir
70
+ FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir)
71
+
72
+ UI.puts "Compressing #{framework_file_path} into #{target_dir}"
73
+ `cp -fa #{framework_file_path} #{target_dir} && rm -rf #{framework_folder_path}` # xcframework文件拷贝 & 删除源文件
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,5 @@
1
+ require 'cocoapods-bb-bin/helpers/sources_helper'
2
+ require 'cocoapods-bb-bin/helpers/spec_creator'
3
+ require 'cocoapods-bb-bin/helpers/spec_files_helper'
4
+ require 'cocoapods-bb-bin/helpers/spec_source_creator'
5
+ require 'cocoapods-bb-bin/helpers/build_utils'