lib/cocoaseeds/core.rb
def configure_phase
      self.project.targets.each do |target|
        begin
          phase = target.sources_build_phase
          # support resources phase
          resource_phase = target.resources_build_phase
          next unless phase
        rescue NoMethodError
          next
        end

        # remove zombie build files
        phase.files_references.each do |file|
          begin
            file.real_path
          rescue
            phase.files.each do |build_file|
              phase.files.delete(build_file) if build_file.file_ref == file
            end
          end
        end

        resource_phase.files_references.each do |file|
          begin
            file.real_path
          rescue 
            resource_phase.files.each do |build_file|
              resource_phase.files.delete(build_file) if build_file.file_ref == file
            end
          end
        end


        removings = [] # name of seeds going to be removed from the target
        addings = [] # name of seeds going to be added to the target

        self.targets.keys.sort.each do |seed_name|
          target_names = self.targets[seed_name]
          if not target_names.include?(target.name)
            removings << seed_name if not removings.include?(seed_name)
          else
            addings << seed_name if not addings.include?(seed_name)
          end
        end

        self.file_references.each do |file|
          removings.each do |seed_names|
            next if not seed_names.include?(file.parent.name)
            phase.files.each do |build_file|
              phase.files.delete(build_file) if build_file.file_ref == file
            end
            resource_phase.files.each do |build_file|
              resource_phase.files.delete(build_file) if build_file.file_ref == file
            end
          end

          addings.each do |seed_names|
            next if file.name.end_with? ".h"
            next if not seed_names.include?(file.parent.name)
            uuid = Xcodeproj::uuid_with_name "#{target.name}:#{file.name}"
            # Treat a file as resource file unless confirm it can be compiled.
            if self.valid_source_file?(file)
              phase.add_file_reference_with_uuid(file, uuid, true)
            else
              resource_phase.add_file_reference_with_uuid(file, uuid, true)
            end

          end
        end
      end
    end
def configure_phase
      self.project.targets.each do |target|
        begin
          phase = target.sources_build_phase
          # support resources phase
          resource_phase = target.resources_build_phase
          next unless phase
        rescue NoMethodError
          next
        end

        # remove zombie build files
        phase.files_references.each do |file|
          begin
            file.real_path
          rescue
            phase.files.each do |build_file|
              phase.files.delete(build_file) if build_file.file_ref == file
            end
          end
        end

        resource_phase.files_references.each do |file|
          begin
            file.real_path
          rescue 
            resource_phase.files.each do |build_file|
              resource_phase.files.delete(build_file) if build_file.file_ref == file
            end
          end
        end


        removings = [] # name of seeds going to be removed from the target
        addings = [] # name of seeds going to be added to the target

        self.targets.keys.sort.each do |seed_name|
          target_names = self.targets[seed_name]
          if not target_names.include?(target.name)
            removings << seed_name if not removings.include?(seed_name)
          else
            addings << seed_name if not addings.include?(seed_name)
          end
        end

        self.file_references.each do |file|
          removings.each do |seed_names|
            next if not seed_names.include?(file.parent.name)
            phase.files.each do |build_file|
              phase.files.delete(build_file) if build_file.file_ref == file
            end
            resource_phase.files.each do |build_file|
              resource_phase.files.delete(build_file) if build_file.file_ref == file
            end
          end

          addings.each do |seed_names|
            next if file.name.end_with? ".h"
            next if not seed_names.include?(file.parent.name)
            uuid = Xcodeproj::uuid_with_name "#{target.name}:#{file.name}"
            # Treat a file as resource file unless confirm it can be compiled.
            if self.valid_source_file?(file)
              phase.add_file_reference_with_uuid(file, uuid, true)
            else
              resource_phase.add_file_reference_with_uuid(file, uuid, true)
            end

          end
        end
      end
    end
Adds file references to the 'Sources Build Phase'.

 @!visibility private