Class: Xcodeproj::Project::Object::PBXNativeTarget
- Inherits:
-
AbstractTarget
- Object
- AbstractObject
- AbstractTarget
- Xcodeproj::Project::Object::PBXNativeTarget
- Defined in:
- lib/xcodeproj/project/object/native_target.rb
Overview
Represents a target handled by Xcode.
Attributes collapse
-
#product_install_path ⇒ String
The install path of the product.
-
#product_reference ⇒ PBXFileReference
The reference to the product file.
-
#product_type ⇒ String
The build product type identifier.
Attributes inherited from AbstractTarget
#build_configuration_list, #comments, #name, #product_name
Attributes inherited from AbstractObject
Attributes collapse
-
#build_phases ⇒ ObjectList<AbstractBuildPhase>
The build phases of the target.
-
#build_rules ⇒ PBXBuildRule
The build rules of this target.
Helpers collapse
-
#add_file_references(file_references, compiler_flags = {}) ⇒ Array<PBXBuildFile>
Adds source files to the target.
-
#add_resources(resource_file_references) ⇒ void
Adds resource files to the resources build phase of the target.
-
#frameworks_build_phase ⇒ PBXFrameworksBuildPhase
Finds or creates the frameworks build phase of the target.
-
#headers_build_phase ⇒ PBXHeadersBuildPhase
Finds or creates the headers build phase of the target.
-
#resources_build_phase ⇒ PBXResourcesBuildPhase
Finds or creates the resources build phase of the target.
-
#source_build_phase ⇒ PBXSourcesBuildPhase
Finds or creates the source build phase of the target.
-
#symbol_type ⇒ Symbol
The type of the target expressed as a symbol.
AbstractObject Hooks collapse
-
#sort(_options = nil) ⇒ Object
Sorts the to many attributes of the object according to the display name.
Methods inherited from AbstractTarget
#add_build_configuration, #add_dependency, #add_system_framework, #add_system_library, #build_configurations, #build_settings, #common_resolved_build_setting, #copy_files_build_phases, #dependencies, #dependency_for_target, #deployment_target, #frameworks_build_phases, #new_copy_files_build_phase, #new_shell_script_build_phase, #platform_name, #pretty_print, #resolved_build_setting, #sdk, #sdk_version, #shell_script_build_phases
Methods inherited from AbstractObject
#<=>, #==, #display_name, #inspect, isa, #pretty_print, #remove_from_project, #sort_recursively, #to_hash
Instance Attribute Details
#product_install_path ⇒ String
Returns the install path of the product.
384 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 384 attribute :product_install_path, String |
#product_reference ⇒ PBXFileReference
Returns the reference to the product file.
380 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 380 has_one :product_reference, PBXFileReference |
#product_type ⇒ String
Returns the build product type identifier.
376 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 376 attribute :product_type, String |
Instance Method Details
#add_file_references(file_references, compiler_flags = {}) ⇒ Array<PBXBuildFile>
Adds source files to the target.
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 421 def add_file_references(file_references, compiler_flags = {}) file_references.map do |file| extension = File.extname(file.path).downcase header_extensions = Constants::HEADER_FILES_EXTENSIONS is_header_phase = header_extensions.include?(extension) phase = is_header_phase ? headers_build_phase : source_build_phase unless build_file = phase.build_file(file) build_file = project.new(PBXBuildFile) build_file.file_ref = file phase.files << build_file end if compiler_flags && !compiler_flags.empty? && !is_header_phase (build_file.settings ||= {}).merge!('COMPILER_FLAGS' => compiler_flags) do |_, old, new| [old, new].compact.join(' ') end end yield build_file if block_given? build_file end end |
#add_resources(resource_file_references) ⇒ void
This method returns an undefined value.
Adds resource files to the resources build phase of the target.
453 454 455 456 457 458 459 460 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 453 def add_resources(resource_file_references) resource_file_references.each do |file| next if resources_build_phase.include?(file) build_file = project.new(PBXBuildFile) build_file.file_ref = file resources_build_phase.files << build_file end end |
#build_phases ⇒ ObjectList<AbstractBuildPhase>
Apparently only PBXCopyFilesBuildPhase and PBXShellScriptBuildPhase can appear multiple times in a target.
Returns the build phases of the target.
393 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 393 has_many :build_phases, AbstractBuildPhase |
#build_rules ⇒ PBXBuildRule
Returns the build rules of this target.
372 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 372 has_many :build_rules, PBXBuildRule |
#frameworks_build_phase ⇒ PBXFrameworksBuildPhase
A target should have only one frameworks build phase.
Finds or creates the frameworks build phase of the target.
488 489 490 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 488 def frameworks_build_phase find_or_create_build_phase_by_class(PBXFrameworksBuildPhase) end |
#headers_build_phase ⇒ PBXHeadersBuildPhase
A target should have only one headers build phase.
Finds or creates the headers build phase of the target.
468 469 470 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 468 def headers_build_phase find_or_create_build_phase_by_class(PBXHeadersBuildPhase) end |
#resources_build_phase ⇒ PBXResourcesBuildPhase
A target should have only one resources build phase.
Finds or creates the resources build phase of the target.
498 499 500 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 498 def resources_build_phase find_or_create_build_phase_by_class(PBXResourcesBuildPhase) end |
#sort(_options = nil) ⇒ Object
Sorts the to many attributes of the object according to the display name.
Build phases are not sorted as they order is relevant.
532 533 534 535 536 537 538 539 540 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 532 def sort( = nil) attributes_to_sort = to_many_attributes.reject { |attr| attr.name == :build_phases } attributes_to_sort.each do |attrb| list = attrb.get_value(self) list.sort! do |x, y| x.display_name <=> y.display_name end end end |
#source_build_phase ⇒ PBXSourcesBuildPhase
A target should have only one source build phase.
Finds or creates the source build phase of the target.
478 479 480 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 478 def source_build_phase find_or_create_build_phase_by_class(PBXSourcesBuildPhase) end |
#symbol_type ⇒ Symbol
Returns The type of the target expressed as a symbol.
402 403 404 405 406 |
# File 'lib/xcodeproj/project/object/native_target.rb', line 402 def symbol_type pair = Constants::PRODUCT_TYPE_UTI.find { |_key, value| value == product_type } return nil if pair.nil? pair.first end |