Class: Xcodeproj::Helper::TargetDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/xcodeproj/helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, target1_name, target2_name) ⇒ TargetDiff



6
7
8
9
10
11
12
13
14
# File 'lib/xcodeproj/helper.rb', line 6

def initialize(project, target1_name, target2_name)
  @project = project
  unless @target1 = @project.targets.find { |target| target.name == target1_name }
    raise ArgumentError, "Target 1 by name `#{target1_name}' not found in the project."
  end
  unless @target2 = @project.targets.find { |target| target.name == target2_name }
    raise ArgumentError, "Target 1 by name `#{target2_name}' not found in the project."
  end
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



4
5
6
# File 'lib/xcodeproj/helper.rb', line 4

def project
  @project
end

#target1Object (readonly)

Returns the value of attribute target1.



4
5
6
# File 'lib/xcodeproj/helper.rb', line 4

def target1
  @target1
end

#target2Object (readonly)

Returns the value of attribute target2.



4
5
6
# File 'lib/xcodeproj/helper.rb', line 4

def target2
  @target2
end

Instance Method Details

#new_source_build_filesArray<PBXBuildFile>



20
21
22
23
24
25
26
27
# File 'lib/xcodeproj/helper.rb', line 20

def new_source_build_files
  new = @target2.source_build_phase.files.reject do |target2_build_file|
    @target1.source_build_phase.files.any? do |target1_build_file|
      target1_build_file.file_ref.path == target2_build_file.file_ref.path
    end
  end
  new.sort_by { |build_file| build_file.file_ref.path }
end