cocoapods-imy-hycan-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 (66) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +44 -0
  4. data/lib/cocoapods-imy-bin.rb +2 -0
  5. data/lib/cocoapods-imy-bin/command.rb +2 -0
  6. data/lib/cocoapods-imy-bin/command/bin.rb +61 -0
  7. data/lib/cocoapods-imy-bin/command/bin/archive.rb +229 -0
  8. data/lib/cocoapods-imy-bin/command/bin/auto.rb +199 -0
  9. data/lib/cocoapods-imy-bin/command/bin/code.rb +479 -0
  10. data/lib/cocoapods-imy-bin/command/bin/dup.rb +78 -0
  11. data/lib/cocoapods-imy-bin/command/bin/imy.rb +46 -0
  12. data/lib/cocoapods-imy-bin/command/bin/init.rb +69 -0
  13. data/lib/cocoapods-imy-bin/command/bin/initHotKey.rb +70 -0
  14. data/lib/cocoapods-imy-bin/command/bin/install.rb +48 -0
  15. data/lib/cocoapods-imy-bin/command/bin/lib/lint.rb +69 -0
  16. data/lib/cocoapods-imy-bin/command/bin/repo/update.rb +43 -0
  17. data/lib/cocoapods-imy-bin/command/bin/spec/create.rb +73 -0
  18. data/lib/cocoapods-imy-bin/command/bin/spec/push.rb +114 -0
  19. data/lib/cocoapods-imy-bin/command/bin/update.rb +154 -0
  20. data/lib/cocoapods-imy-bin/config/config.rb +137 -0
  21. data/lib/cocoapods-imy-bin/config/config_asker.rb +57 -0
  22. data/lib/cocoapods-imy-bin/config/config_builder.rb +216 -0
  23. data/lib/cocoapods-imy-bin/config/config_hot_key.rb +103 -0
  24. data/lib/cocoapods-imy-bin/config/config_hot_key_asker.rb +57 -0
  25. data/lib/cocoapods-imy-bin/gem_version.rb +10 -0
  26. data/lib/cocoapods-imy-bin/helpers.rb +5 -0
  27. data/lib/cocoapods-imy-bin/helpers/Info.plist +0 -0
  28. data/lib/cocoapods-imy-bin/helpers/build_helper.rb +158 -0
  29. data/lib/cocoapods-imy-bin/helpers/build_utils.rb +63 -0
  30. data/lib/cocoapods-imy-bin/helpers/framework.rb +85 -0
  31. data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +444 -0
  32. data/lib/cocoapods-imy-bin/helpers/library.rb +54 -0
  33. data/lib/cocoapods-imy-bin/helpers/library_builder.rb +90 -0
  34. data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +36 -0
  35. data/lib/cocoapods-imy-bin/helpers/spec_creator.rb +170 -0
  36. data/lib/cocoapods-imy-bin/helpers/spec_files_helper.rb +77 -0
  37. data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +228 -0
  38. data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +89 -0
  39. data/lib/cocoapods-imy-bin/native.rb +23 -0
  40. data/lib/cocoapods-imy-bin/native/acknowledgements.rb +27 -0
  41. data/lib/cocoapods-imy-bin/native/analyzer.rb +55 -0
  42. data/lib/cocoapods-imy-bin/native/file_accessor.rb +28 -0
  43. data/lib/cocoapods-imy-bin/native/installation_options.rb +25 -0
  44. data/lib/cocoapods-imy-bin/native/installer.rb +135 -0
  45. data/lib/cocoapods-imy-bin/native/linter.rb +26 -0
  46. data/lib/cocoapods-imy-bin/native/path_source.rb +33 -0
  47. data/lib/cocoapods-imy-bin/native/pod_source_installer.rb +19 -0
  48. data/lib/cocoapods-imy-bin/native/pod_target_installer.rb +94 -0
  49. data/lib/cocoapods-imy-bin/native/podfile.rb +91 -0
  50. data/lib/cocoapods-imy-bin/native/podfile_env.rb +37 -0
  51. data/lib/cocoapods-imy-bin/native/podfile_generator.rb +199 -0
  52. data/lib/cocoapods-imy-bin/native/podspec_finder.rb +25 -0
  53. data/lib/cocoapods-imy-bin/native/resolver.rb +230 -0
  54. data/lib/cocoapods-imy-bin/native/sandbox_analyzer.rb +34 -0
  55. data/lib/cocoapods-imy-bin/native/source.rb +35 -0
  56. data/lib/cocoapods-imy-bin/native/sources_manager.rb +20 -0
  57. data/lib/cocoapods-imy-bin/native/specification.rb +31 -0
  58. data/lib/cocoapods-imy-bin/native/target_validator.rb +41 -0
  59. data/lib/cocoapods-imy-bin/native/validator.rb +40 -0
  60. data/lib/cocoapods-imy-bin/source_provider_hook.rb +66 -0
  61. data/lib/cocoapods/imy/hycan/bin.rb +12 -0
  62. data/lib/cocoapods/imy/hycan/bin/version.rb +9 -0
  63. data/lib/cocoapods_plugin.rb +3 -0
  64. data/spec/command/bin_spec.rb +12 -0
  65. data/spec/spec_helper.rb +50 -0
  66. metadata +180 -0
@@ -0,0 +1,54 @@
1
+ # copy from https://github.com/CocoaPods/cocoapods-packager
2
+
3
+ module CBin
4
+ class Library
5
+ attr_reader :headers_path
6
+ attr_reader :resources_path
7
+ attr_reader :root_path
8
+ attr_reader :versions_path
9
+ attr_reader :name_path
10
+
11
+ def initialize(name, platform, version)
12
+ @name = name
13
+ @platform = platform
14
+ @version = version
15
+ end
16
+
17
+ def make
18
+ make_root
19
+ make_library
20
+ make_headers
21
+ make_resources
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_library
32
+ @name_path = CBin::Config::Builder.instance.library_name_version(@name,@version)
33
+ @fwk_path = @root_path + Pathname.new(@name_path)
34
+ @fwk_path.mkdir unless @fwk_path.exist?
35
+
36
+ @versions_path = @fwk_path
37
+ end
38
+
39
+ def make_headers
40
+ @headers_path = @versions_path + Pathname.new('Headers')
41
+ @headers_path.mkpath unless @headers_path.exist?
42
+ end
43
+
44
+ def make_resources
45
+ @resources_path = @versions_path + Pathname.new('Resources')
46
+ @resources_path.mkpath unless @resources_path.exist?
47
+ end
48
+
49
+ def make_root
50
+ @root_path = Pathname.new(@platform)
51
+ @root_path.mkpath unless @root_path.exist?
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,90 @@
1
+
2
+ # copy from https://github.com/CocoaPods/cocoapods-packager
3
+
4
+ require 'cocoapods-imy-bin/helpers/framework.rb'
5
+ require 'cocoapods-imy-bin/helpers/library.rb'
6
+
7
+ require 'English'
8
+
9
+ module CBin
10
+ class Library
11
+ class Builder
12
+ include Pod
13
+
14
+ def initialize(spec, file_accessor, platform, source_dir,framework_path)
15
+ @spec = spec
16
+ @source_dir = source_dir
17
+ @file_accessor = file_accessor
18
+ @platform = platform
19
+ @framework = framework_path
20
+ @source_files = "#{@source_dir}/#{library.name_path}"
21
+ @source_zip_file = "#{@source_files}.zip"
22
+ end
23
+
24
+ def build
25
+ UI.section("Building static library #{@spec}") do
26
+
27
+ clean_source_dir
28
+
29
+ copy_headers
30
+ copy_library
31
+ copy_resources
32
+
33
+ cp_to_source_dir
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def clean_source_dir
40
+ FileUtils.rm_rf(@source_files) if File.exist?(@source_files)
41
+ FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file)
42
+ end
43
+
44
+ def cp_to_source_dir
45
+ target_dir = library.versions_path
46
+ dest_file = "#{@source_dir}/#{library.name_path}"
47
+ FileUtils.rm_rf(dest_file) if File.exist?(dest_file)
48
+
49
+ `cp -fa #{target_dir} #{dest_file}/`
50
+ end
51
+
52
+ def copy_headers
53
+ FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path)
54
+ end
55
+
56
+ def copy_library
57
+ src_file = "#{framework.versions_path}/#{@spec.name}"
58
+ unless File.exist?(src_file)
59
+ raise Informative, "framework没有文件:#{src_file}"
60
+ end
61
+
62
+ dest_file = "#{library.versions_path}/#{@spec.name}"
63
+ rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a"
64
+ FileUtils.cp_r(src_file,dest_file)
65
+ File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file)
66
+ end
67
+
68
+ def copy_resources
69
+ FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path)
70
+ end
71
+
72
+
73
+ def framework
74
+ @framework ||= begin
75
+ framework = Framework.new(@spec.name, @platform.name.to_s)
76
+ framework.make
77
+ framework
78
+ end
79
+ end
80
+
81
+ def library
82
+ @library ||= begin
83
+ library = Library.new(@spec.name, @platform.name.to_s,@spec.version)
84
+ library.make
85
+ library
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,36 @@
1
+
2
+
3
+ require 'cocoapods-imy-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-imy-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-imy-bin/native/sources_manager.rb'
4
+ require 'cocoapods-imy-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,228 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-imy-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("# MARK: converted automatically by plugin cocoapods-imy-bin @slj \r\n")
41
+ f.write(spec.to_pretty_json)
42
+ end
43
+
44
+ @filename = file
45
+ end
46
+
47
+ def clear_spec_file
48
+ File.delete(filename) if File.exist?(filename)
49
+ end
50
+
51
+ def filename
52
+ @filename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json"
53
+ end
54
+
55
+ private
56
+
57
+ def create_from_code_spec
58
+ @spec = code_spec.dup
59
+ # vendored_frameworks | resources | source | source_files | public_header_files
60
+ # license | resource_bundles | vendored_libraries
61
+
62
+ # Project Linkin
63
+ # @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
64
+
65
+ # Resources
66
+ extnames = []
67
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
68
+ if code_spec_consumer.resources.any?
69
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
70
+ end
71
+ if extnames.any?
72
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
73
+ end
74
+
75
+ # Source Location
76
+ @spec.source = binary_source
77
+
78
+ # Source Code
79
+ # @spec.source_files = framework_contents('Headers/*')
80
+ # @spec.public_header_files = framework_contents('Headers/*')
81
+
82
+ # Unused for binary
83
+ spec_hash = @spec.to_hash
84
+ # spec_hash.delete('license')
85
+ spec_hash.delete('resource_bundles')
86
+ spec_hash.delete('exclude_files')
87
+ spec_hash.delete('preserve_paths')
88
+
89
+ spec_hash.delete('subspecs')
90
+ spec_hash.delete('default_subspecs')
91
+ spec_hash.delete('default_subspec')
92
+ spec_hash.delete('vendored_frameworks')
93
+ spec_hash.delete('vendored_framework')
94
+
95
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
96
+ # 如果是静态库的话,需要移除,否则就不移除
97
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
98
+ # 这里统一只对命名后缀 .a 文件做处理
99
+ # spec_hash.delete('vendored_libraries')
100
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
101
+ spec_hash.delete('vendored_libraries')
102
+
103
+ # vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
104
+ # if vendored_libraries.any?
105
+ # spec_hash['vendored_libraries'] = vendored_libraries
106
+ # end
107
+
108
+ # Filter platforms
109
+ platforms = spec_hash['platforms']
110
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
111
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
112
+
113
+ @spec = Pod::Specification.from_hash(spec_hash)
114
+
115
+ #把命令 prepare_command 移除掉,如ReactiveCocoa会执行修改重命令的脚步
116
+ @spec.prepare_command = "" if @spec.prepare_command
117
+ @spec.version = code_spec.version
118
+ @spec.source = binary_source
119
+ @spec.source_files = binary_source_files
120
+ @spec.public_header_files = binary_public_header_files
121
+ @spec.vendored_libraries = binary_vendored_libraries
122
+ @spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
123
+ @spec.description = <<-EOF
124
+ 「 converted automatically by plugin cocoapods-imy-bin @厦门美柚 - slj 」
125
+ #{@spec.description}
126
+ EOF
127
+ @spec
128
+ end
129
+
130
+ def create_framework_from_code_spec
131
+ @spec = code_spec.dup
132
+ # vendored_frameworks | resources | source | source_files | public_header_files
133
+ # license | resource_bundles | vendored_libraries
134
+
135
+ # Project Linkin
136
+ @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
137
+
138
+ # Resources
139
+ extnames = []
140
+ extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
141
+ if code_spec_consumer.resources.any?
142
+ extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
143
+ end
144
+ if extnames.any?
145
+ @spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
146
+ end
147
+
148
+ # Source Location
149
+ @spec.source = binary_source
150
+
151
+ # Source Code
152
+ # @spec.source_files = framework_contents('Headers/*')
153
+ # @spec.public_header_files = framework_contents('Headers/*')
154
+
155
+ # Unused for binary
156
+ spec_hash = @spec.to_hash
157
+ # spec_hash.delete('license')
158
+ spec_hash.delete('resource_bundles')
159
+ spec_hash.delete('exclude_files')
160
+ spec_hash.delete('preserve_paths')
161
+ # 这里不确定 vendored_libraries 指定的时动态/静态库
162
+ # 如果是静态库的话,需要移除,否则就不移除
163
+ # 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
164
+ # 这里统一只对命名后缀 .a 文件做处理
165
+ # spec_hash.delete('vendored_libraries')
166
+ # libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
167
+ vendored_libraries = spec_hash.delete('vendored_libraries')
168
+ vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
169
+ if vendored_libraries.any?
170
+ spec_hash['vendored_libraries'] = vendored_libraries
171
+ end
172
+
173
+ # Filter platforms
174
+ platforms = spec_hash['platforms']
175
+ selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
176
+ spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
177
+
178
+ @spec = Pod::Specification.from_hash(spec_hash)
179
+ @spec.description = <<-EOF
180
+ 「 converted automatically by plugin cocoapods-imy-bin @厦门美柚 - slj 」
181
+ #{@spec.description}
182
+ EOF
183
+ @spec
184
+ end
185
+
186
+
187
+ def binary_source
188
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
189
+ end
190
+
191
+ def code_spec_consumer(_platform = :ios)
192
+ code_spec.consumer(:ios)
193
+ end
194
+
195
+ def framework_contents(name)
196
+ ["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
197
+ end
198
+
199
+ def binary_source_files
200
+ { http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
201
+ end
202
+
203
+ def binary_source_files
204
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
205
+ end
206
+
207
+ def binary_public_header_files
208
+ "bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
209
+ end
210
+
211
+ def binary_vendored_libraries
212
+ "bin_#{code_spec.name}_#{code_spec.version}/*.a"
213
+ end
214
+
215
+ def binary_resources
216
+ "bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
217
+ end
218
+
219
+ end
220
+ end
221
+ end
222
+ #模板框架begin
223
+ # s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
224
+ # s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
225
+ # s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
226
+ #有图片资源的,要带上
227
+ #s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
228
+ #模板框架end