cocoapods-packagerthk 0.0.1

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,245 @@
1
+ module Pod
2
+ class Command
3
+ class Packagethk < Command
4
+ private
5
+
6
+ def build_static_sandbox(dynamic)
7
+ static_sandbox_root = if dynamic
8
+ Pathname.new(config.sandbox_root + '/Static')
9
+ else
10
+ Pathname.new(config.sandbox_root)
11
+ end
12
+ Sandbox.new(static_sandbox_root)
13
+ end
14
+
15
+ def install_pod(platform_name, sandbox)
16
+ podfile = podfile_from_spec(
17
+ @path,
18
+ @spec.name,
19
+ platform_name,
20
+ @spec.deployment_target(platform_name),
21
+ @subspecs,
22
+ @spec_sources
23
+ )
24
+
25
+ static_installer = Installer.new(sandbox, podfile)
26
+ static_installer.install!
27
+
28
+ unless static_installer.nil?
29
+ static_installer.pods_project.targets.each do |target|
30
+ target.build_configurations.each do |config|
31
+ config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
32
+ config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
33
+ config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
34
+ end
35
+ end
36
+ static_installer.pods_project.save
37
+ end
38
+
39
+ static_installer
40
+ end
41
+
42
+ def podfile_from_spec(path, spec_name, platform_name, deployment_target, subspecs, sources)
43
+ options = {}
44
+ if path
45
+ if @local
46
+ options[:path] = path
47
+ else
48
+ options[:podspec] = path
49
+ end
50
+ end
51
+ options[:subspecs] = subspecs if subspecs
52
+ Pod::Podfile.new do
53
+ sources.each { |s| source s }
54
+ platform(platform_name, deployment_target)
55
+ pod(spec_name, options)
56
+
57
+ install!('cocoapods',
58
+ :integrate_targets => false,
59
+ :deterministic_uuids => false)
60
+
61
+ target('packager') do
62
+ inherit! :complete
63
+ end
64
+ end
65
+ end
66
+
67
+ def binary_only?(spec)
68
+ deps = spec.dependencies.map { |dep| spec_with_name(dep.name) }
69
+ [spec, *deps].each do |specification|
70
+ %w(vendored_frameworks vendored_libraries).each do |attrib|
71
+ if specification.attributes_hash[attrib]
72
+ return true
73
+ end
74
+ end
75
+ end
76
+
77
+ false
78
+ end
79
+
80
+ def spec_with_name(name)
81
+ return if name.nil?
82
+
83
+ set = Pod::Config.instance.sources_manager.search(Dependency.new(name))
84
+ return nil if set.nil?
85
+
86
+ set.specification.root
87
+ end
88
+
89
+ def spec_with_path(path)
90
+ return if path.nil?
91
+ path = Pathname.new(path)
92
+ path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
93
+ return unless path.exist?
94
+
95
+ @path = path.expand_path
96
+
97
+ if @path.directory?
98
+ help! @path + ': is a directory.'
99
+ return
100
+ end
101
+
102
+ unless ['.podspec', '.json'].include? @path.extname
103
+ help! @path + ': is not a podspec.'
104
+ return
105
+ end
106
+
107
+ Specification.from_file(@path)
108
+ end
109
+
110
+ #----------------------
111
+ # Dynamic Project Setup
112
+ #----------------------
113
+
114
+ def build_dynamic_sandbox(_static_sandbox, _static_installer)
115
+ dynamic_sandbox_root = Pathname.new(config.sandbox_root + '/Dynamic')
116
+ dynamic_sandbox = Sandbox.new(dynamic_sandbox_root)
117
+
118
+ dynamic_sandbox
119
+ end
120
+
121
+ # @param [Pod::Sandbox] dynamic_sandbox
122
+ #
123
+ # @param [Pod::Sandbox] static_sandbox
124
+ #
125
+ # @param [Pod::Installer] static_installer
126
+ #
127
+ # @param [Pod::Platform] platform
128
+ #
129
+ def install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
130
+ # 1 Create a dynamic target for only the spec pod.
131
+ dynamic_target = build_dynamic_target(dynamic_sandbox, static_installer, platform)
132
+
133
+ # 2. Build a new xcodeproj in the dynamic_sandbox with only the spec pod as a target.
134
+ project = prepare_pods_project(dynamic_sandbox, dynamic_target.name, static_installer)
135
+
136
+ # 3. Copy the source directory for the dynamic framework from the static sandbox.
137
+ copy_dynamic_target(static_sandbox, dynamic_target, dynamic_sandbox)
138
+
139
+ # 4. Create the file references.
140
+ install_file_references(dynamic_sandbox, [dynamic_target], project)
141
+
142
+ # 5. Install the target.
143
+ install_library(dynamic_sandbox, dynamic_target, project)
144
+
145
+ # 6. Write the actual .xcodeproj to the dynamic sandbox.
146
+ write_pod_project(project, dynamic_sandbox)
147
+ end
148
+
149
+ # @param [Pod::Installer] static_installer
150
+ #
151
+ # @return [Pod::PodTarget]
152
+ #
153
+ def build_dynamic_target(dynamic_sandbox, static_installer, platform)
154
+ spec_targets = static_installer.pod_targets.select do |target|
155
+ target.name == @spec.name
156
+ end
157
+ static_target = spec_targets[0]
158
+
159
+ file_accessors = create_file_accessors(static_target, dynamic_sandbox)
160
+
161
+ archs = []
162
+ dynamic_target = Pod::PodTarget.new(dynamic_sandbox, true, static_target.user_build_configurations, archs, platform, static_target.specs, static_target.target_definitions, file_accessors)
163
+ dynamic_target
164
+ end
165
+
166
+ # @param [Pod::Sandbox] dynamic_sandbox
167
+ #
168
+ # @param [String] spec_name
169
+ #
170
+ # @param [Pod::Installer] installer
171
+ #
172
+ def prepare_pods_project(dynamic_sandbox, spec_name, installer)
173
+ # Create a new pods project
174
+ pods_project = Pod::Project.new(dynamic_sandbox.project_path)
175
+
176
+ # Update build configurations
177
+ installer.analysis_result.all_user_build_configurations.each do |name, type|
178
+ pods_project.add_build_configuration(name, type)
179
+ end
180
+
181
+ # Add the pod group for only the dynamic framework
182
+ local = dynamic_sandbox.local?(spec_name)
183
+ path = dynamic_sandbox.pod_dir(spec_name)
184
+ was_absolute = dynamic_sandbox.local_path_was_absolute?(spec_name)
185
+ pods_project.add_pod_group(spec_name, path, local, was_absolute)
186
+ pods_project
187
+ end
188
+
189
+ def copy_dynamic_target(static_sandbox, _dynamic_target, dynamic_sandbox)
190
+ command = "cp -a #{static_sandbox.root}/#{@spec.name} #{dynamic_sandbox.root}"
191
+ `#{command}`
192
+ end
193
+
194
+ def create_file_accessors(target, dynamic_sandbox)
195
+ pod_root = dynamic_sandbox.pod_dir(target.root_spec.name)
196
+
197
+ path_list = Sandbox::PathList.new(pod_root)
198
+ target.specs.map do |spec|
199
+ Sandbox::FileAccessor.new(path_list, spec.consumer(target.platform))
200
+ end
201
+ end
202
+
203
+ def install_file_references(dynamic_sandbox, pod_targets, pods_project)
204
+ installer = Pod::Installer::Xcode::PodsProjectGenerator::FileReferencesInstaller.new(dynamic_sandbox, pod_targets, pods_project)
205
+ installer.install!
206
+ end
207
+
208
+ def install_library(dynamic_sandbox, dynamic_target, project)
209
+ return if dynamic_target.target_definitions.flat_map(&:dependencies).empty?
210
+ target_installer = Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.new(dynamic_sandbox, project, dynamic_target)
211
+ result = target_installer.install!
212
+ native_target = result.native_target
213
+
214
+ # Installs System Frameworks
215
+ if dynamic_target.should_build?
216
+ dynamic_target.file_accessors.each do |file_accessor|
217
+ file_accessor.spec_consumer.frameworks.each do |framework|
218
+ native_target.add_system_framework(framework)
219
+ end
220
+ file_accessor.spec_consumer.libraries.each do |library|
221
+ native_target.add_system_library(library)
222
+ end
223
+ end
224
+ end
225
+ end
226
+
227
+ def write_pod_project(dynamic_project, dynamic_sandbox)
228
+ UI.message "- Writing Xcode project file to #{UI.path dynamic_sandbox.project_path}" do
229
+ dynamic_project.pods.remove_from_project if dynamic_project.pods.empty?
230
+ dynamic_project.development_pods.remove_from_project if dynamic_project.development_pods.empty?
231
+ dynamic_project.sort(:groups_position => :below)
232
+ dynamic_project.recreate_user_schemes(false)
233
+
234
+ # Edit search paths so that we can find our dependency headers
235
+ dynamic_project.targets.first.build_configuration_list.build_configurations.each do |config|
236
+ config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
237
+ config.build_settings['USER_HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
238
+ config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
239
+ end
240
+ dynamic_project.save
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
@@ -0,0 +1,158 @@
1
+ module Pod
2
+ class SpecBuilder
3
+ def initialize(spec, source, embedded, dynamic, generate_spec)
4
+ @spec = spec
5
+ @source = source.nil? ? '{ :path => \'.\' }' : source
6
+ @embedded = embedded
7
+ @dynamic = dynamic
8
+ @is_generate_spec = generate_spec
9
+ @generate_spec = ""
10
+ end
11
+
12
+ def framework_path
13
+ if @embedded
14
+ @spec.name + '.embeddedframework' + '/' + @spec.name + '.framework'
15
+ else
16
+ @spec.name + '.framework'
17
+ end
18
+ end
19
+
20
+ def spec_platform(platform)
21
+ fwk_base = platform.name.to_s + '/' + framework_path
22
+ spec = <<RB
23
+ s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
24
+ s.#{platform.name}.vendored_framework = '#{fwk_base}'
25
+ RB
26
+
27
+ %w(frameworks weak_frameworks libraries requires_arc xcconfig).each do |attribute|
28
+ attributes_hash = @spec.attributes_hash[platform.name.to_s]
29
+ next if attributes_hash.nil?
30
+ value = attributes_hash[attribute]
31
+ next if value.nil?
32
+
33
+ value = "'#{value}'" if value.class == String
34
+ spec += " s.#{platform.name}.#{attribute} = #{value}\n"
35
+ end
36
+ spec
37
+
38
+
39
+ end
40
+
41
+ def spec_sources_pattern(generate_spec)
42
+ # 添加Source Pattern
43
+ spec = <<RB
44
+
45
+ if ENV['IS_SOURCE'] || ENV["\#{s.name}_SOURCE"]
46
+ s.source = { :git => '#{@spec.attributes_hash['source']['git']}', :commit => "#{@spec.attributes_hash['source']['commit']}" }
47
+ RB
48
+
49
+ %w(source_files public_header_files resources frameworks resource_bundles dependencies).each do |attribute|
50
+ value = @spec.attributes_hash[attribute]
51
+ next if value.nil?
52
+ if attribute == 'dependencies'
53
+ value.each { |key,hashvalue|
54
+ if hashvalue.empty?
55
+ spec += " s.dependency \'#{key}\'\n"
56
+ else
57
+ spec += " s.dependency \'#{key}\', \'#{hashvalue[0]}\'\n"
58
+ end
59
+ }
60
+ else
61
+ value = value.dump if value.class == String
62
+ spec += " s.#{attribute} = #{value}\n"
63
+ end
64
+ end
65
+ #添加subspec (递归添加)
66
+ @generate_spec = spec
67
+ @spec.subspecs.each do |subspec|
68
+ spec_sources_pattern_subpsec(subspec)
69
+ end
70
+ spec = @generate_spec
71
+
72
+ # 添加Framwork Pattern
73
+ spec += <<RB
74
+ else
75
+ s.source = { :git => 'git@repo.we.com:iosfeaturelibraries/frameworkrepo.git', :commit => 'xxx'}
76
+ s.source_files = "\#{s.name}-\#{s.version}/ios/\#{s.name}.framework/Headers/*.h"
77
+ s.public_header_files = "\#{s.name}-\#{s.version}/ios/\#{s.name}.framework/Headers/*.h"
78
+ s.ios.vendored_framework = "\#{s.name}-\#{s.version}/ios/\#{s.name}.framework"
79
+ end
80
+ RB
81
+ # cur_work_dir = Dir::getwd
82
+ # Dir.chdir('/Users/joe.cheng/cocoapods-debug')
83
+ # File.open('debug' + '.podspec', 'w') { |file| file.write(spec) }
84
+ # Dir.chdir(cur_work_dir)
85
+ spec
86
+ end
87
+
88
+ def spec_sources_pattern_subpsec(subspec)
89
+ name = subspec.attributes_hash['name']
90
+ level = subspec.name.split('/').count
91
+ curSpec = "s" * (level - 1)
92
+ space = " " * (level - 2)
93
+ nextSpec = curSpec + "s"
94
+ @generate_spec += space
95
+ @generate_spec += " #{curSpec}.subspec \'#{name}\' do |#{nextSpec}|\n"
96
+
97
+ %w(source_files public_header_files resources frameworks resource_bundles dependencies).each do |attribute|
98
+ value = subspec.attributes_hash[attribute]
99
+ next if value.nil?
100
+ @generate_spec += space
101
+ if attribute == 'dependencies'
102
+ value.each { |key,hashvalue|
103
+ if hashvalue.empty?
104
+ @generate_spec += " #{nextSpec}.dependency \'#{key}\'\n"
105
+ else
106
+ @generate_spec += " #{nextSpec}.dependency \'#{key}\', \'#{hashvalue[0]}\'\n"
107
+ end
108
+ }
109
+ else
110
+ value = value.dump if value.class == String
111
+ @generate_spec += " #{nextSpec}.#{attribute} = #{value}\n"
112
+ end
113
+ end
114
+
115
+ if subspec.subspecs.empty?
116
+ @generate_spec += space
117
+ @generate_spec += " end\n"
118
+ else
119
+ #添加subspec
120
+ subspec.subspecs.each do |subsubspec|
121
+ spec_sources_pattern_subpsec(subsubspec)
122
+ end
123
+ @generate_spec += " end\n"
124
+ end
125
+ end
126
+
127
+ def spec_metadata
128
+ spec = spec_header
129
+ spec
130
+ end
131
+
132
+ def spec_close
133
+ "end\n"
134
+ end
135
+
136
+ private
137
+
138
+ def spec_header
139
+ spec = "Pod::Spec.new do |s|\n"
140
+
141
+ %w(name version summary license authors homepage description social_media_url
142
+ docset_url documentation_url screenshots frameworks weak_frameworks libraries requires_arc
143
+ deployment_target xcconfig).each do |attribute|
144
+ value = @spec.attributes_hash[attribute]
145
+ next if value.nil?
146
+ value = value.dump if value.class == String
147
+ spec += " s.#{attribute} = #{value}\n"
148
+ end
149
+ if @is_generate_spec
150
+ source = spec_sources_pattern(true)
151
+ spec += "#{source}"
152
+ else
153
+ spec += " s.source = #{@source}\n\n"
154
+ end
155
+ spec
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,42 @@
1
+ module Symbols
2
+ def symbols_from_library(library)
3
+ syms = `nm -defined-only -extern-only #{library}`.split("\n")
4
+ result = classes_from_symbols(syms)
5
+ result += constants_from_symbols(syms)
6
+
7
+ result.select do |e|
8
+ case e
9
+ when 'llvm.cmdline', 'llvm.embedded.module', '__clang_at_available_requires_core_foundation_framework'
10
+ false
11
+ else
12
+ true
13
+ end
14
+ end
15
+ end
16
+
17
+ module_function :symbols_from_library
18
+
19
+ private
20
+
21
+ def classes_from_symbols(syms)
22
+ classes = syms.select { |klass| klass[/OBJC_CLASS_\$_/] }
23
+ classes = classes.uniq
24
+ classes.map! { |klass| klass.gsub(/^.*\$_/, '') }
25
+ end
26
+
27
+ def constants_from_symbols(syms)
28
+ consts = syms.select { |const| const[/ S /] }
29
+ consts = consts.select { |const| const !~ /OBJC|\.eh/ }
30
+ consts = consts.uniq
31
+ consts = consts.map! { |const| const.gsub(/^.* _/, '') }
32
+
33
+ other_consts = syms.select { |const| const[/ T /] }
34
+ other_consts = other_consts.uniq
35
+ other_consts = other_consts.map! { |const| const.gsub(/^.* _/, '') }
36
+
37
+ consts + other_consts
38
+ end
39
+
40
+ module_function :classes_from_symbols
41
+ module_function :constants_from_symbols
42
+ end
@@ -0,0 +1,15 @@
1
+ module Pod
2
+ module UserInterface
3
+ module BuildFailedReport
4
+ class << self
5
+ def report(command, output)
6
+ <<-EOF
7
+ Build command failed: #{command}
8
+ Output:
9
+ #{output.map { |line| " #{line}" }.join}
10
+ EOF
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Pod
2
+ module Packagerthk
3
+ VERSION = '1.0.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'pod/command/packagethk'
2
+ require 'cocoapods-packagerthk/user_interface/build_failed_report'
3
+ require 'cocoapods-packagerthk/builder'
4
+ require 'cocoapods-packagerthk/framework'
5
+ require 'cocoapods-packagerthk/mangle'
6
+ require 'cocoapods-packagerthk/pod_utils'
7
+ require 'cocoapods-packagerthk/spec_builder'
8
+ require 'cocoapods-packagerthk/symbols'
@@ -0,0 +1,198 @@
1
+ require 'tmpdir'
2
+ module Pod
3
+ class Command
4
+ class Packagethk < Command
5
+ self.summary = 'Package a podspec into a static library.'
6
+ self.arguments = [
7
+ CLAide::Argument.new('NAME', true),
8
+ CLAide::Argument.new('SOURCE', false)
9
+ ]
10
+
11
+ def self.options
12
+ [
13
+ ['--force', 'Overwrite existing files.'],
14
+ ['--no-mangle', 'Do not mangle symbols of depedendant Pods.'],
15
+ ['--embedded', 'Generate embedded frameworks.'],
16
+ ['--library', 'Generate static libraries.'],
17
+ ['--dynamic', 'Generate dynamic framework.'],
18
+ ['--local', 'Use local state rather than published versions.'],
19
+ ['--bundle-identifier', 'Bundle identifier for dynamic framework'],
20
+ ['--exclude-deps', 'Exclude symbols from dependencies.'],
21
+ ['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
22
+ ['--subspecs', 'Only include the given subspecs'],
23
+ ['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependent ' \
24
+ 'pods from (defaults to https://github.com/CocoaPods/Specs.git)'],
25
+ ['--generate-spec', 'Generate spec file.']
26
+ ]
27
+ end
28
+
29
+ def initialize(argv)
30
+ @embedded = argv.flag?('embedded')
31
+ @library = argv.flag?('library')
32
+ @dynamic = argv.flag?('dynamic')
33
+ @local = argv.flag?('local', false)
34
+ @package_type = if @embedded
35
+ :static_framework
36
+ elsif @dynamic
37
+ :dynamic_framework
38
+ elsif @library
39
+ :static_library
40
+ else
41
+ :static_framework
42
+ end
43
+ @force = argv.flag?('force')
44
+ @mangle = argv.flag?('mangle', true)
45
+ @bundle_identifier = argv.option('bundle-identifier', nil)
46
+ @exclude_deps = argv.flag?('exclude-deps', false)
47
+ @name = argv.shift_argument
48
+ @source = argv.shift_argument
49
+ @spec_sources = argv.option('spec-sources', 'https://github.com/CocoaPods/Specs.git').split(',')
50
+
51
+ subspecs = argv.option('subspecs')
52
+ @subspecs = subspecs.split(',') unless subspecs.nil?
53
+
54
+ @config = argv.option('configuration', 'Release')
55
+
56
+ @source_dir = Dir.pwd
57
+ @is_spec_from_path = false
58
+ @spec = spec_with_path(@name)
59
+ @is_spec_from_path = true if @spec
60
+ @spec ||= spec_with_name(@name)
61
+ @generate_spec = argv.flag?('generate-spec',false)
62
+ super
63
+ end
64
+
65
+ def validate!
66
+ super
67
+ help! 'A podspec name or path is required.' unless @spec
68
+ help! 'podspec has binary-only depedencies, mangling not possible.' if @mangle && binary_only?(@spec)
69
+ help! '--bundle-identifier option can only be used for dynamic frameworks' if @bundle_identifier && !@dynamic
70
+ help! '--exclude-deps option can only be used for static libraries' if @exclude_deps && @dynamic
71
+ help! '--local option can only be used when a local `.podspec` path is given.' if @local && !@is_spec_from_path
72
+ end
73
+
74
+ def run
75
+ if @spec.nil?
76
+ help! "Unable to find a podspec with path or name `#{@name}`."
77
+ return
78
+ end
79
+
80
+ target_dir, work_dir = create_working_directory
81
+ # puts work_dir
82
+ return if target_dir.nil?
83
+ build_package
84
+ # 文件迁移FileUtils
85
+ puts "move files..."
86
+
87
+
88
+ `rm -rf mv #{work_dir}/build/`
89
+
90
+ exist = File::exists?("#{work_dir}/ios/#{@spec.name}.framework/Versions/A/Resources")
91
+ if exist
92
+ puts "move Resources..."
93
+ `rm -rf mv #{work_dir}/ios/#{@spec.name}.framework/Resources`
94
+ `mv #{work_dir}/ios/#{@spec.name}.framework/Versions/A/Resources #{work_dir}/ios/#{@spec.name}.framework/`
95
+ end
96
+ `rm -rf mv #{work_dir}/ios/#{@spec.name}.framework/Headers`
97
+ `rm -rf mv #{work_dir}/ios/#{@spec.name}.framework/#{@spec.name}`
98
+ `mv #{work_dir}/ios/#{@spec.name}.framework/Versions/A/Headers #{work_dir}/ios/#{@spec.name}.framework/`
99
+ `mv #{work_dir}/ios/#{@spec.name}.framework/Versions/A/#{@spec.name} #{work_dir}/ios/#{@spec.name}.framework/`
100
+ `rm -rf #{work_dir}/ios/#{@spec.name}.framework/Versions`
101
+ `mv "#{work_dir}" "#{target_dir}"`
102
+ Dir.chdir(@source_dir)
103
+ end
104
+
105
+ private
106
+
107
+ def build_in_sandbox(platform)
108
+ config.installation_root = Pathname.new(Dir.pwd)
109
+ config.sandbox_root = 'Pods'
110
+
111
+ static_sandbox = build_static_sandbox(@dynamic)
112
+ static_installer = install_pod(platform.name, static_sandbox)
113
+
114
+ if @dynamic
115
+ dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer)
116
+ install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
117
+ end
118
+
119
+ begin
120
+ perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
121
+ ensure # in case the build fails; see Builder#xcodebuild.
122
+ Pathname.new(config.sandbox_root).rmtree
123
+ FileUtils.rm_f('Podfile.lock')
124
+ end
125
+ end
126
+
127
+ def build_package
128
+ builder = SpecBuilder.new(@spec, @source, @embedded, @dynamic, @generate_spec)
129
+ newspec = builder.spec_metadata
130
+
131
+ @spec.available_platforms.each do |platform|
132
+ build_in_sandbox(platform)
133
+
134
+ if @generate_spec == false
135
+ newspec += builder.spec_platform(platform)
136
+ end
137
+ end
138
+
139
+ newspec += builder.spec_close
140
+ File.open(@spec.name + '.podspec', 'w') { |file| file.write(newspec) }
141
+ end
142
+
143
+ def create_target_directory
144
+ target_dir = "#{@source_dir}/#{@spec.name}-#{@spec.version}"
145
+ if File.exist? target_dir
146
+ if @force
147
+ Pathname.new(target_dir).rmtree
148
+ else
149
+ UI.puts "Target directory '#{target_dir}' already exists."
150
+ return nil
151
+ end
152
+ end
153
+ target_dir
154
+ end
155
+
156
+ def create_working_directory
157
+ target_dir = create_target_directory
158
+ return if target_dir.nil?
159
+
160
+ work_dir = Dir.tmpdir + '/cocoapods-' + Array.new(8) { rand(36).to_s(36) }.join
161
+ Pathname.new(work_dir).mkdir
162
+ Dir.chdir(work_dir)
163
+
164
+ [target_dir, work_dir]
165
+ end
166
+
167
+ def perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
168
+ static_sandbox_root = config.sandbox_root.to_s
169
+
170
+ if @dynamic
171
+ static_sandbox_root = "#{static_sandbox_root}/#{static_sandbox.root.to_s.split('/').last}"
172
+ dynamic_sandbox_root = "#{config.sandbox_root}/#{dynamic_sandbox.root.to_s.split('/').last}"
173
+ end
174
+
175
+ builder = Pod::Builder.new(
176
+ platform,
177
+ static_installer,
178
+ @source_dir,
179
+ static_sandbox_root,
180
+ dynamic_sandbox_root,
181
+ static_sandbox.public_headers.root,
182
+ @spec,
183
+ @embedded,
184
+ @mangle,
185
+ @dynamic,
186
+ @config,
187
+ @bundle_identifier,
188
+ @exclude_deps
189
+ )
190
+
191
+ builder.build(@package_type)
192
+
193
+ return unless @embedded
194
+ builder.link_embedded_resources
195
+ end
196
+ end
197
+ end
198
+ end