class Xcodeproj::Project::Object::AbstractBuildPhase
@abstract
This class is abstract and it doesn’t appear in the project document.
Public Instance Methods
Adds a new build file, initialized with the given file reference, to the phase.
@param [PBXFileReference] file_ref
The file reference that should be added to the build phase.
@return [PBXBuildFile] the build file generated.
# File lib/xcodeproj/project/object/build_phase.rb, line 93 def add_file_reference(file_ref, avoid_duplicates = false) if avoid_duplicates && existing = build_file(file_ref) existing else build_file = project.new(PBXBuildFile) build_file.file_ref = file_ref files << build_file build_file end end
# File lib/xcodeproj/project/object/build_phase.rb, line 145 def ascii_plist_annotation " #{display_name} " end
@return [PBXBuildFile] the first build file associated with the given
file reference if one exists.
# File lib/xcodeproj/project/object/build_phase.rb, line 71 def build_file(file_ref) (file_ref.referrers & files).first end
Removes all the build files from the phase and clears their relationship to the file reference.
@return [void]
# File lib/xcodeproj/project/object/build_phase.rb, line 134 def clear files.objects.each do |bf| remove_build_file(bf) end end
Xcodeproj::Project::Object::AbstractObject#display_name
# File lib/xcodeproj/project/object/build_phase.rb, line 141 def display_name super.gsub(/BuildPhase$/, '') end
@return [Array<String>] The display name of the build files.
# File lib/xcodeproj/project/object/build_phase.rb, line 64 def file_display_names files.map(&:display_name) end
@return [Array<PBXFileReference>] the list of all the files
referenced by this build phase.
# File lib/xcodeproj/project/object/build_phase.rb, line 58 def files_references files.map(&:file_ref) end
Returns whether a build file for the given file reference exists.
@param [PBXFileReference] file_ref
@return [Bool] whether the reference is already present.
# File lib/xcodeproj/project/object/build_phase.rb, line 81 def include?(file_ref) !build_file(file_ref).nil? end
Removes a build file from the phase and clears its relationship to the file reference.
@param [PBXBuildFile] build_file
the file to remove
@return [void]
# File lib/xcodeproj/project/object/build_phase.rb, line 124 def remove_build_file(build_file) build_file.file_ref = nil build_file.remove_from_project end
Removes the build file associated with the given file reference from the phase.
@param [PBXFileReference] file_ref
The file to remove
@return [void]
# File lib/xcodeproj/project/object/build_phase.rb, line 112 def remove_file_reference(file_ref) build_file = files.find { |bf| bf.file_ref == file_ref } remove_build_file(build_file) if build_file end
Sorts the build files of the phase according to the display name or the path.
@param [Hash] _options
Not used.
@return [void]
# File lib/xcodeproj/project/object/build_phase.rb, line 157 def sort(_options = nil) files.sort! do |x, y| result = File.basename(x.display_name.downcase, '.*') <=> File.basename(y.display_name.downcase, '.*') if result.zero? result = File.extname(x.display_name.downcase) <=> File.extname(y.display_name.downcase) if result.zero? && x.file_ref.respond_to?(:full_path) && y.file_ref.respond_to?(:full_path) result = x.file_ref.full_path.to_s.downcase <=> y.file_ref.full_path.to_s.downcase end end result end end