Class: Xcodeproj::Project::Object::PBXFileReference

Inherits:
Object
  • Object
show all
Defined in:
lib/synx/pbx_file_reference.rb

Instance Method Summary collapse

Instance Method Details

#change_build_settings_referenceObject

Fixes things like pch, info.plist references being changed



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/synx/pbx_file_reference.rb', line 48

def change_build_settings_reference
  @setting_keys_changed = []
  return unless basename =~ /\.(pch|plist)$/
  
  project.targets.each do |t|
    t.each_build_settings do |bs|
      ["INFOPLIST_FILE", "GCC_PREFIX_HEADER"].each do |setting_key|
        setting_value = bs[setting_key]
        if setting_value == real_path.relative_path_from(project.root_pathname).to_s
          bs[setting_key] = hierarchy_path[1..-1]
          @setting_keys_changed << setting_key
        end
      end if bs
    end
  end

  @setting_keys_changed.uniq!
end

#outputObject



27
28
29
30
31
32
33
# File 'lib/synx/pbx_file_reference.rb', line 27

def output
  build_settings_ammended = "(build settings ammended: #{@setting_keys_changed.join(", ")})" if @setting_keys_changed.count > 0
  removed_from_groups = "(had multiple parent groups, removed from groups: #{@removed_from_groups.join(", ")})" if @removed_from_groups.count > 0
  str_output = "#{basename} #{build_settings_ammended} #{removed_from_groups}"
  str_output = str_output.yellow if removed_from_groups || build_settings_ammended
  Synx::Tabber.puts str_output
end

#sync(group) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/synx/pbx_file_reference.rb', line 8

def sync(group)
  if should_sync?
    if should_move?
      FileUtils.mv(real_path.to_s, group.work_pathname.to_s)
      # TODO: move out to abstract_object
      self.source_tree = "<group>"
      self.path = real_path.basename.to_s
    else
      # Don't move this file around -- it's not even inside the structure. Just fix the relative reference
      self.path = real_path.relative_path_from((project.work_pathname_to_pathname(group.work_pathname))).to_s
    end
    change_build_settings_reference

    output
  else
    Synx::Tabber.puts "skipped #{basename}".red
  end
end