Class: Phoenx::TestableTargetBuilder

Inherits:
TargetBuilder show all
Defined in:
lib/phoenx/use_cases/generate_target.rb

Instance Attribute Summary

Attributes inherited from TargetBuilder

#framework_files, #project, #project_spec, #target_spec

Instance Method Summary collapse

Methods inherited from TargetBuilder

#add_build_phase_scripts, #add_config_files, #add_frameworks_and_libraries, #add_headers, #add_private_headers, #add_project_headers, #add_public_headers, #add_resources, #add_sources, #add_support_files, #add_system_dependencies, #configure_target, #initialize, #target

Constructor Details

This class inherits a constructor from Phoenx::TargetBuilder

Instance Method Details

#add_schemesObject



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/phoenx/use_cases/generate_target.rb', line 222

def add_schemes
	@target_spec.schemes.each do |s|
		scheme = Xcodeproj::XCScheme.new
		scheme.configure_with_targets(self.target, @test_target)
		scheme.test_action.code_coverage_enabled = true
		scheme.add_build_target(self.target, true)
		scheme.add_test_target(@test_target)
		archive_configuration = self.target.build_configuration_list[s.archive_configuration]
		unless archive_configuration
			abort "Invalid archive configuration assigned for scheme '#{s.name}' ".red + s.archive_configuration.bold
		end
		launch_configuration = self.target.build_configuration_list[s.launch_configuration]
		unless launch_configuration
			abort "Invalid launch configuration assigned for scheme '#{s.name}' ".red + s.launch_configuration.bold
		end
		scheme.archive_action.build_configuration = archive_configuration
		scheme.launch_action.build_configuration = launch_configuration
		scheme.save_as(@project_spec.project_file_name, s.name, false)
	end
end

#add_sub_projectsObject



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/phoenx/use_cases/generate_target.rb', line 202

def add_sub_projects
	frameworks_group = @project.main_group.find_subpath(FRAMEWORKS_ROOT,false)
	@target_spec.dependencies.each do |dp|
		proj = nil
		if dp.path == nil
			proj = @project
		else
			abort "Missing dependency ".red + dp.path.bold unless File.exists?(dp.path)
			file_ref = frameworks_group.find_file_by_path(dp.path)
			unless file_ref != nil
				frameworks_group.new_file(dp.path)
			end
			proj = Xcodeproj::Project::open(dp.path)
		end
		target = Phoenx.target_for_name(proj,dp.target_name)
		abort "Missing target for dependency '#{dp.path}' ".red + dp.target_name.bold unless target
		self.target.add_dependency(target)
	end
end

#add_test_targetsObject



243
244
245
246
247
248
249
# File 'lib/phoenx/use_cases/generate_target.rb', line 243

def add_test_targets
	@target_spec.test_targets.each do |test_target_spec|
		builder = TestTargetBuilder.new(@target, @project, test_target_spec, @project_spec, @target_spec, self.framework_files)
		builder.build
		@test_target = builder.target
	end	
end

#buildObject



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/phoenx/use_cases/generate_target.rb', line 251

def build
	puts ">> Target ".green + @target_spec.name.bold unless @project_spec.targets.length == 1
	self.add_sources
	Phoenx::Target::HeaderBuilder.new(@project, @target, @target_spec).build
	self.add_resources
	self.add_config_files
	self.add_sub_projects
	self.add_system_dependencies
	self.add_frameworks_and_libraries
	self.add_build_phase_scripts
	self.add_test_targets
	self.generate_target_scheme
	self.add_schemes
	self.add_support_files
	self.sort_build_phases
	self.configure_target
end

#generate_target_schemeObject



187
188
189
190
191
192
193
194
# File 'lib/phoenx/use_cases/generate_target.rb', line 187

def generate_target_scheme
	# Generate main scheme
	scheme = Xcodeproj::XCScheme.new
	scheme.configure_with_targets(self.target, @test_target)
	scheme.test_action.code_coverage_enabled = true
	scheme.add_build_target(self.target, true)
	scheme.save_as(@project_spec.project_file_name, @target_spec.name, false)	
end

#sort_build_phasesObject



196
197
198
199
200
# File 'lib/phoenx/use_cases/generate_target.rb', line 196

def sort_build_phases
	self.target.build_phases.objects.each do |phase|
		phase.sort
	end
end