cocoapods-hd 0.0.7 → 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.
@@ -0,0 +1,73 @@
1
+ require_relative "names"
2
+
3
+ module Pod
4
+ class PrebuildSandbox < Sandbox
5
+
6
+ # [String] standard_sandbox_path
7
+ def self.from_standard_sanbox_path(path)
8
+ prebuild_sandbox_path = Pathname.new(path).realpath + "_Prebuild"
9
+ self.new(prebuild_sandbox_path)
10
+ end
11
+
12
+ def self.from_standard_sandbox(sandbox)
13
+ self.from_standard_sanbox_path(sandbox.root)
14
+ end
15
+
16
+ def standard_sanbox_path
17
+ self.root.parent
18
+ end
19
+
20
+ def generate_framework_path
21
+ self.root + "GeneratedFrameworks"
22
+ end
23
+
24
+ # @param name [String] pass the target.name (may containing platform suffix)
25
+ # @return [Pathname] the folder containing the framework file.
26
+ def framework_folder_path_for_target_name(name)
27
+ self.generate_framework_path + name
28
+ end
29
+
30
+ def exsited_framework_target_names
31
+ exsited_framework_name_pairs.map { |pair| pair[0] }.uniq
32
+ end
33
+
34
+ def exsited_framework_pod_names
35
+ exsited_framework_name_pairs.map { |pair| pair[1] }.uniq
36
+ end
37
+
38
+ def existed_target_names_for_pod_name(pod_name)
39
+ exsited_framework_name_pairs.select { |pair| pair[1] == pod_name }.map { |pair| pair[0] }
40
+ end
41
+
42
+ def save_pod_name_for_target(target)
43
+ folder = framework_folder_path_for_target_name(target.name)
44
+ return unless folder.exist?
45
+ # flag_file_path: /Users/xingyong/Desktop/debug-binary/HDTestKit/Example/Pods/_Prebuild/GeneratedFrameworks/SVProgressHUD/SVProgressHUD.pod_name
46
+ flag_file_path = folder + "#{target.pod_name}.pod_name"
47
+
48
+ File.write(flag_file_path.to_s, "")
49
+ end
50
+
51
+ private
52
+
53
+ def pod_name_for_target_folder(target_folder_path)
54
+ name = Pathname.new(target_folder_path).children.find do |child|
55
+ child.to_s.end_with? ".pod_name"
56
+ end
57
+ name = name.basename(".pod_name").to_s unless name.nil?
58
+ name ||= Pathname.new(target_folder_path).basename.to_s # for compatibility with older version
59
+ end
60
+
61
+ # Array<[target_name, pod_name]>
62
+ def exsited_framework_name_pairs
63
+ return [] unless generate_framework_path.exist?
64
+ generate_framework_path.children().map do |framework_path|
65
+ if framework_path.directory? && (not framework_path.children.empty?)
66
+ [framework_path.basename.to_s, pod_name_for_target_folder(framework_path)]
67
+ else
68
+ nil
69
+ end
70
+ end.reject(&:nil?).uniq
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,49 @@
1
+
2
+ module Pod
3
+ class Prebuild
4
+
5
+ # Check the targets, for the current limitation of the plugin
6
+ #
7
+ # @param [Array<PodTarget>] prebuilt_targets
8
+ def self.check_one_pod_should_have_only_one_target(prebuilt_targets)
9
+
10
+ targets_have_different_platforms = prebuilt_targets.select {|t| t.pod_name != t.name }
11
+
12
+ if targets_have_different_platforms.count > 0
13
+ names = targets_have_different_platforms.map(&:pod_name)
14
+ raw_names = targets_have_different_platforms.map(&:name)
15
+ message = "Oops, you came across a limitation of cocoapods-binary.
16
+
17
+ The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
18
+ causing this problem:
19
+
20
+ 1. One pod integrates in 2 or more different platforms' targets. e.g.
21
+ ```
22
+ target 'iphoneApp' do
23
+ pod 'A', :binary => true
24
+ end
25
+ target 'watchApp' do
26
+ pod 'A'
27
+ end
28
+ ```
29
+
30
+ 2. Use different subspecs in multiple targets. e.g.
31
+ ```
32
+ target 'iphoneApp' do
33
+ pod 'A/core'
34
+ pod 'A/network'
35
+ end
36
+ target 'iphoneAppTest' do
37
+ pod 'A/core'
38
+ end
39
+ ```
40
+
41
+ Related pods: #{names}, target names: #{raw_names}
42
+ "
43
+ raise Informative, message
44
+ end
45
+ end
46
+
47
+
48
+ end
49
+ end
@@ -0,0 +1,226 @@
1
+ # encoding: UTF-8
2
+ require_relative 'helper/podfile_options'
3
+ require_relative 'tool/tool'
4
+
5
+ module Pod
6
+ class Podfile
7
+ module DSL
8
+
9
+ # Enable prebuiding for all pods
10
+ # it has a lower priority to other binary settings
11
+ def hd_all_binary!
12
+ DSL.is_all_binary = true
13
+ end
14
+
15
+ def hd_use_source_pods(pods)
16
+ DSL.source_pods = Array(pods)
17
+ end
18
+
19
+ # Enable bitcode for prebuilt frameworks
20
+ def enable_bitcode_for_prebuilt_frameworks!
21
+ DSL.bitcode_enabled = true
22
+ end
23
+
24
+ # Don't remove source code of prebuilt pods
25
+ # It may speed up the pod install if git didn't
26
+ # include the `Pods` folder
27
+ def keep_source_code_for_prebuilt_frameworks!
28
+ DSL.dont_remove_source_code = true
29
+ end
30
+
31
+ # Add custom xcodebuild option to the prebuilding action
32
+ #
33
+ # You may use this for your special demands. For example: the default archs in dSYMs
34
+ # of prebuilt frameworks is 'arm64 armv7 x86_64', and no 'i386' for 32bit simulator.
35
+ # It may generate a warning when building for a 32bit simulator. You may add following
36
+ # to your podfile
37
+ #
38
+ # ` set_custom_xcodebuild_options_for_prebuilt_frameworks :simulator => "ARCHS=$(ARCHS_STANDARD)" `
39
+ #
40
+ # Another example to disable the generating of dSYM file:
41
+ #
42
+ # ` set_custom_xcodebuild_options_for_prebuilt_frameworks "DEBUG_INFORMATION_FORMAT=dwarf"`
43
+ #
44
+ #
45
+ # @param [String or Hash] options
46
+ #
47
+ # If is a String, it will apply for device and simulator. Use it just like in the commandline.
48
+ # If is a Hash, it should be like this: { :device => "XXXXX", :simulator => "XXXXX" }
49
+ #
50
+ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
51
+ if options.kind_of? Hash
52
+ DSL.custom_build_options = [options[:device]] unless options[:device].nil?
53
+ DSL.custom_build_options_simulator = [options[:simulator]] unless options[:simulator].nil?
54
+ elsif options.kind_of? String
55
+ DSL.custom_build_options = [options]
56
+ DSL.custom_build_options_simulator = [options]
57
+ else
58
+ raise "Wrong type."
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ # 是否全部二进库
65
+ class_attr_accessor :is_all_binary
66
+ is_all_binary = false
67
+
68
+ class_attr_accessor :bitcode_enabled
69
+ bitcode_enabled = false
70
+
71
+ class_attr_accessor :dont_remove_source_code
72
+ dont_remove_source_code = false
73
+
74
+ class_attr_accessor :custom_build_options
75
+ class_attr_accessor :custom_build_options_simulator
76
+ self.custom_build_options = []
77
+ self.custom_build_options_simulator = []
78
+
79
+ # 用户指定源码集合
80
+ class_attr_accessor :source_pods
81
+ source_pods = []
82
+
83
+ end
84
+ end
85
+ end
86
+
87
+ def run_pod_install
88
+ podfile = Pathname.new('Podfile')
89
+ if !podfile.exist?
90
+ STDERR.puts "[!] Podfile file did not exist".red
91
+ exit
92
+ end
93
+ argvs = []
94
+ gen = Pod::Command::Install.new(CLAide::ARGV.new(argvs))
95
+ gen.validate!
96
+ gen.run
97
+ end
98
+
99
+ # Pod::HooksManager.register('cocoapods-hd', :post_install) do |installer_context|
100
+ #
101
+ # Pod::UI.puts "cocoapods-hd: post_install"
102
+ # if Pod.is_ignore_hook_install == nil || Pod.is_ignore_hook_install == true
103
+ # Pod::UI.puts "cocoapods-hd: hook post_install"
104
+ # next
105
+ # end
106
+ # # installer_context.pods_project -> Xcodeproj::Project
107
+ # installer_context.pods_project.targets.each do |target|
108
+ # target.build_configurations.each do |config|
109
+ # if config.name == 'Release'
110
+ # config.build_settings['ARCHS'] = "$(ARCHS_STANDARD)"
111
+ # end
112
+ # end
113
+ # end
114
+ # installer_context.pods_project.save
115
+ # Pod::UI.puts "cocoapods-hd: set build configurations"
116
+ # end
117
+ #
118
+ Pod::HooksManager.register('cocoapods-hd', :pre_install) do |installer_context|
119
+
120
+ require_relative 'helper/feature_switches'
121
+ require_relative 'resolver'
122
+
123
+ Pod::UI.puts "cocoapods-hd: pre_install"
124
+
125
+ if !Pod.is_prebuild_stage
126
+ Pod::UI.puts "cocoapods-hd: update repo"
127
+
128
+ sources_manager = Pod::Config.instance.sources_manager
129
+ argvs = [sources_manager.binary_source.name]
130
+ repo_update = Pod::Command::Repo::Update.new(CLAide::ARGV.new(argvs))
131
+ repo_update.validate!
132
+ repo_update.run
133
+ end
134
+
135
+ if Pod.is_ignore_hook_install == nil || Pod.is_ignore_hook_install == true
136
+ Pod::UI.puts "cocoapods-hd: hook pre_install"
137
+ next
138
+ end
139
+
140
+ if Pod.is_prebuild_stage
141
+ next
142
+ end
143
+
144
+ # [Check Environment]
145
+ # check user_framework is on
146
+ podfile = installer_context.podfile
147
+ podfile.target_definition_list.each do |target_definition|
148
+
149
+ next if target_definition.prebuild_framework_pod_names.empty?
150
+ if not target_definition.uses_frameworks?
151
+ STDERR.puts "[!] Cocoapods-hd requires `use_frameworks!`".red
152
+ exit
153
+ end
154
+ end
155
+
156
+ # -- step 1: prebuild framework ---
157
+ # Execute a sperated pod install, to generate targets for building framework,
158
+ # then compile them to framework files.
159
+ require_relative 'helper/prebuild_sandbox'
160
+ require_relative 'prebuild'
161
+
162
+ Pod::UI.puts "️🍎 Prebuild frameworks"
163
+
164
+ # Fetch original installer (which is running this pre-install hook) options,
165
+ # then pass them to our installer to perform update if needed
166
+ # Looks like this is the most appropriate way to figure out that something should be updated
167
+
168
+ update = nil
169
+ repo_update = nil
170
+
171
+ include ObjectSpace
172
+ ObjectSpace.each_object(Pod::Installer) { |installer|
173
+ update = installer.update
174
+ repo_update = installer.repo_update
175
+ }
176
+
177
+ # control features
178
+ Pod.is_prebuild_stage = true
179
+ Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets
180
+ Pod::Installer.force_disable_integration true # don't integrate targets
181
+ Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
182
+ Pod::Installer.disable_install_complete_message true # disable install complete message
183
+
184
+ # make another custom sandbox
185
+ standard_sandbox = installer_context.sandbox
186
+ prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
187
+
188
+ # get the podfile for prebuild
189
+ prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
190
+ prebuild_podfile.use_frameworks!(:linkage => :static)
191
+ # Pod::UI.puts "prebuild_podfile --------- : #{prebuild_podfile}"
192
+
193
+ # install
194
+ lockfile = installer_context.lockfile
195
+ # Pod::UI.puts "lockfile --------- : #{lockfile}"
196
+
197
+ binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
198
+ # Pod::UI.puts "binary_installer --------- : #{binary_installer}"
199
+
200
+ binary_installer.have_exact_prebuild_cache?
201
+ binary_installer.install!
202
+
203
+ # if binary_installer.have_exact_prebuild_cache? && !update
204
+ # binary_installer.install_when_cache_hit!
205
+ # else
206
+ # binary_installer.update = update
207
+ # binary_installer.repo_update = repo_update
208
+ # binary_installer.install!
209
+ # end
210
+
211
+ # reset the environment
212
+ Pod.is_prebuild_stage = false
213
+ Pod::Installer.force_disable_integration false
214
+ Pod::Podfile::DSL.enable_prebuild_patch false
215
+ Pod::Config.force_disable_write_lockfile false
216
+ Pod::Installer.disable_install_complete_message false
217
+ Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
218
+
219
+ # -- step 2: pod install ---
220
+ # install
221
+ Pod::UI.puts "\n"
222
+ Pod::UI.puts "🍓 Pod Install"
223
+ require_relative 'Integration'
224
+ # go on the normal install step ...
225
+ end
226
+
@@ -0,0 +1,333 @@
1
+ require_relative 'build/build_framework'
2
+ require_relative 'helper/passer'
3
+ require_relative 'helper/target_checker'
4
+ require_relative 'upload/upload_helper'
5
+
6
+ # patch prebuild ability
7
+ module Pod
8
+ class Installer
9
+
10
+ private
11
+
12
+ def local_manifest
13
+ if not @local_manifest_inited
14
+ @local_manifest_inited = true
15
+ raise "This method should be call before generate project" unless self.analysis_result == nil
16
+ @local_manifest = self.sandbox.manifest
17
+ end
18
+ @local_manifest
19
+ end
20
+
21
+ # @return [Analyzer::SpecsState]
22
+ def prebuild_pods_changes
23
+ return nil if local_manifest.nil?
24
+ if @prebuild_pods_changes.nil?
25
+ changes = local_manifest.detect_changes_with_podfile(podfile)
26
+ @prebuild_pods_changes = Analyzer::SpecsState.new(changes)
27
+ # save the chagnes info for later stage
28
+ Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
29
+ end
30
+ @prebuild_pods_changes
31
+ end
32
+
33
+ public
34
+
35
+ # check if need to prebuild
36
+ def have_exact_prebuild_cache?
37
+ # check if need build frameworks
38
+ return false if local_manifest == nil
39
+
40
+ changes = prebuild_pods_changes
41
+ added = changes.added
42
+ changed = changes.changed
43
+ unchanged = changes.unchanged
44
+ deleted = changes.deleted
45
+
46
+ exsited_framework_pod_names = sandbox.exsited_framework_pod_names
47
+ missing = unchanged.select do |pod_name|
48
+ not exsited_framework_pod_names.include?(pod_name)
49
+ end
50
+
51
+ needed = (added + changed + deleted + missing)
52
+ return needed.empty?
53
+ end
54
+
55
+ # The install method when have completed cache
56
+ def install_when_cache_hit!
57
+ # just print log
58
+ self.sandbox.exsited_framework_target_names.each do |name|
59
+ UI.puts "Using #{name}"
60
+ end
61
+ end
62
+
63
+ # Build the needed framework files
64
+ def prebuild_frameworks!
65
+
66
+ # build options
67
+ sandbox_path = sandbox.root
68
+ existed_framework_folder = sandbox.generate_framework_path
69
+ bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled
70
+
71
+ if local_manifest != nil
72
+
73
+ changes = prebuild_pods_changes
74
+ added = changes.added
75
+ changed = changes.changed
76
+ unchanged = changes.unchanged
77
+ deleted = changes.deleted
78
+
79
+ existed_framework_folder.mkdir unless existed_framework_folder.exist?
80
+ exsited_framework_pod_names = sandbox.exsited_framework_pod_names
81
+
82
+ # additions
83
+ missing = unchanged.select do |pod_name|
84
+ not exsited_framework_pod_names.include?(pod_name)
85
+ end
86
+
87
+ root_names_to_update = (added + changed + missing)
88
+
89
+ # transform names to targets
90
+ cache = []
91
+ targets = root_names_to_update.map do |pod_name|
92
+ tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
93
+ if tars.nil? || tars.empty?
94
+ raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil?
95
+ end
96
+ tars
97
+ end.flatten
98
+
99
+ # add the dendencies
100
+ dependency_targets = targets.map { |t| t.recursive_dependent_targets }.flatten.uniq || []
101
+ targets = (targets + dependency_targets).uniq
102
+ else
103
+ targets = self.pod_targets
104
+ end
105
+
106
+ # STDERR.puts "targets ------- : #{targets}".cyan
107
+ # 移除local target, ps: HDTestKit
108
+ # targets = targets.reject { |pod_target| sandbox.local?(pod_target.pod_name) }
109
+
110
+ unless Prebuild::Passer.target_names.nil?
111
+ targets = targets.select { |pod_target| Prebuild::Passer.target_names.include? pod_target.pod_name }
112
+ end
113
+
114
+ Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
115
+ Pod::Prebuild.remove_build_dir(sandbox_path)
116
+
117
+ targets.each do |target|
118
+
119
+ STDERR.puts "开始build: #{target.name} ,should_build: #{target.should_build?} "
120
+
121
+ # fix: 注释掉下面方法,否则Pod::Prebuild.build不执行
122
+ if !target.should_build?
123
+ # STDERR.puts "prebuilding: --------- #{target.label}"
124
+ next
125
+ end
126
+
127
+ output_path = sandbox.framework_folder_path_for_target_name(target.name)
128
+ output_path.mkpath unless output_path.exist?
129
+ STDERR.puts "output_path : ------ #{output_path}".yellow
130
+
131
+ Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
132
+
133
+ # save the resource paths for later installing
134
+ if !target.resource_paths.empty?
135
+ # fix: framework_path 添加 target.name
136
+ framework_path = output_path + target.framework_name
137
+ standard_sandbox_path = sandbox.standard_sanbox_path
138
+
139
+ resources = begin
140
+ if Pod::VERSION.start_with? "1.5"
141
+ target.resource_paths
142
+ else
143
+ # resource_paths is Hash{String=>Array<String>} on 1.6 and above
144
+ # (use AFNetworking to generate a demo data)
145
+ # https://github.com/leavez/cocoapods-binary/issues/50
146
+ target.resource_paths.values.flatten
147
+ end
148
+ end
149
+ raise "Wrong type: #{resources}" unless resources.kind_of? Array
150
+
151
+ path_objects = resources.map do |path|
152
+ object = Prebuild::Passer::ResourcePath.new
153
+ object.real_file_path = framework_path + File.basename(path)
154
+ STDERR.puts "framework_path------ #{framework_path}".yellow
155
+
156
+ object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s + "/_Prebuild") if path.start_with? '${PODS_ROOT}'
157
+ # object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
158
+ # object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
159
+ object
160
+ end
161
+ Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
162
+ end
163
+
164
+ end
165
+
166
+ # copy vendored libraries and frameworks
167
+ targets.each do |target|
168
+ root_path = self.sandbox.pod_dir(target.name)
169
+ target_folder = sandbox.framework_folder_path_for_target_name(target.name)
170
+
171
+ # If target shouldn't build, we copy all the original files
172
+ # This is for target with only .a and .h files
173
+
174
+ if not target.should_build?
175
+ Prebuild::Passer.target_names_to_skip_integration_framework << target.name
176
+ STDERR.puts "copy vendored libraries and frameworks ------ #{root_path}, #{target_folder}".yellow
177
+ FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
178
+ next
179
+ end
180
+
181
+ target.spec_consumers.each do |consumer|
182
+ file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
183
+ lib_paths = file_accessor.vendored_frameworks || []
184
+ lib_paths += file_accessor.vendored_libraries
185
+
186
+ # @TODO dSYM files
187
+ lib_paths.each do |lib_path|
188
+ relative = lib_path.relative_path_from(root_path)
189
+ destination = target_folder + relative
190
+ UI.puts "destination ------- #{destination}"
191
+ destination.dirname.mkpath unless destination.dirname.exist?
192
+ FileUtils.cp_r(lib_path, destination, :remove_destination => true)
193
+ end
194
+
195
+ # 将destination替换成target_folder,不需要全路径还原
196
+ # 需要将外部依赖的vendored_frameworks和vendored_libraries复制到target的同级目录中
197
+ lib_paths.each do |lib_path|
198
+ UI.puts "lib_path ----- #{lib_path}"
199
+ relative = lib_path.relative_path_from(root_path)
200
+ destination = target_folder + relative
201
+ destination.dirname.mkpath unless destination.dirname.exist?
202
+ FileUtils.cp_r(lib_path, target_folder, :remove_destination => true)
203
+ end
204
+
205
+ end
206
+ end
207
+
208
+ targets.each do |target|
209
+ target_name = target.name
210
+ module_name = target.product_module_name
211
+ hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}
212
+ # 将podspec.resource资源复制到framework里面 ps: SVProgerssHUD
213
+ path_objects = hash[target_name]
214
+ if path_objects != nil
215
+ path_objects.each do |object|
216
+ if object.target_file_path != nil
217
+ UI.puts "target_file_path --- #{object.target_file_path}"
218
+ UI.puts "real_file_path ------ #{object.real_file_path}"
219
+ FileUtils.cp_r(object.target_file_path, object.real_file_path, :remove_destination => true)
220
+ end
221
+ end
222
+ end
223
+
224
+ output_path = sandbox.framework_folder_path_for_target_name(target.name)
225
+ output_path.mkpath unless output_path.exist?
226
+
227
+ sandbox_root = Pathname(sandbox_path)
228
+ build_dir = sandbox_root.parent + 'build'
229
+
230
+ bundle_path = "#{build_dir}/Release-iphoneos/#{module_name}/*.bundle"
231
+ if Dir[bundle_path].any?
232
+ FileUtils.cp_r Dir.glob(bundle_path), output_path, verbose: true
233
+ end
234
+
235
+ originPath = Dir.pwd
236
+
237
+ Dir.chdir(output_path) {
238
+
239
+ zipTargetFramework = "#{target_name}.zip"
240
+ frameworkFileType = "#{output_path}/*.framework"
241
+ bundleFileType = "#{output_path}/*.bundle"
242
+ staticLibraryFileType = "#{output_path}/*.a"
243
+ zipFiles = ""
244
+ if Dir[bundleFileType].any?
245
+ zipFiles += " *.bundle "
246
+ end
247
+ if Dir[frameworkFileType].any?
248
+ zipFiles += " *.framework "
249
+ end
250
+ if Dir[staticLibraryFileType].any?
251
+ zipFiles += " *.a "
252
+ end
253
+ # puts "output_path: zipTargetFramework-------- #{output_path}, #{zipTargetFramework}, zipfile: #{zipFiles}"
254
+ `zip -r #{zipTargetFramework} #{zipFiles}`
255
+ %x[`cd #{originPath}`]
256
+ }
257
+
258
+ end
259
+ Pod::Prebuild.remove_build_dir(sandbox_path)
260
+
261
+ # 上传zip包和二进制repo
262
+ targets.each do |target|
263
+ root_spec = target.specs.select { |spec|
264
+ spec.root?
265
+ }.first
266
+
267
+ UI.puts "上传zip包和二进制repo ------- #{root_spec}"
268
+
269
+ if !root_spec.nil?
270
+ #output_path: ~/Example/Pods/_Prebuild/GeneratedFrameworks/MBProgressHUD
271
+ output_path = sandbox.framework_folder_path_for_target_name(target.name)
272
+ output_path.mkpath unless output_path.exist?
273
+ UI.puts "output_path ------- #{output_path}"
274
+
275
+ # 上传二进库的podspec
276
+ upload_binary(root_spec, output_path)
277
+ end
278
+
279
+ end
280
+
281
+ # save the pod_name for prebuild framwork in sandbox
282
+ targets.each do |target|
283
+ sandbox.save_pod_name_for_target target
284
+ end
285
+
286
+ # Remove useless files
287
+ # remove useless pods
288
+ all_needed_names = self.pod_targets.map(&:name).uniq
289
+ useless_target_names = sandbox.exsited_framework_target_names.reject do |name|
290
+ all_needed_names.include? name
291
+ end
292
+ useless_target_names.each do |name|
293
+ path = sandbox.framework_folder_path_for_target_name(name)
294
+ path.rmtree if path.exist?
295
+ end
296
+
297
+ if not Podfile::DSL.dont_remove_source_code
298
+ # only keep manifest.lock and framework folder in _Prebuild
299
+ to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
300
+ to_delete_files = sandbox_path.children.select do |file|
301
+ filename = File.basename(file)
302
+ not to_remain_files.include?(filename)
303
+ end
304
+ to_delete_files.each do |path|
305
+ path.rmtree if path.exist?
306
+ end
307
+ else
308
+ # just remove the tmp files
309
+ path = sandbox.root + 'Manifest.lock.tmp'
310
+ path.rmtree if path.exist?
311
+ end
312
+
313
+ end
314
+
315
+ # 上传二进库
316
+ def upload_binary(root_spec, output_path)
317
+ puts "开始上传 ------------------------------- "
318
+ upload_helper = CocoapodsHd::UploadHelper.new(root_spec, output_path)
319
+ upload_helper.spec_creator
320
+ upload_helper.upload
321
+ end
322
+
323
+ # patch the post install hook
324
+ old_method2 = instance_method(:run_plugins_post_install_hooks)
325
+ define_method(:run_plugins_post_install_hooks) do
326
+ old_method2.bind(self).()
327
+ if Pod::is_prebuild_stage
328
+ self.prebuild_frameworks!
329
+ end
330
+ end
331
+
332
+ end
333
+ end