Class: Xcodeproj::Project::Object::FileReferencesFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/xcodeproj/project/object/helpers/file_references_factory.rb

Class Method Summary collapse

Class Method Details

.new_bundle(group, product_basename) ⇒ PBXFileReference

Creates a file reference to a new bundle and adds it to the given group.



74
75
76
77
78
79
# File 'lib/xcodeproj/project/object/helpers/file_references_factory.rb', line 74

def new_bundle(group, product_basename)
  ref = new_reference(group, "#{product_basename}.bundle", :built_products)
  ref.include_in_index = '0'
  ref.set_explicit_file_type('wrapper.cfbundle')
  ref
end

.new_product_ref_for_target(group, product_basename, product_type) ⇒ PBXFileReference

Creates a file reference to a static library and adds it to the given group.



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/xcodeproj/project/object/helpers/file_references_factory.rb', line 50

def new_product_ref_for_target(group, product_basename, product_type)
  if product_type == :static_library
    prefix = 'lib'
  end
  extension = Constants::PRODUCT_UTI_EXTENSIONS[product_type]
  path = "#{prefix}#{product_basename}"
  path += ".#{extension}" if extension
  ref = new_reference(group, path, :built_products)
  ref.include_in_index = '0'
  ref.set_explicit_file_type
  ref
end

.new_reference(group, path, source_tree) ⇒ PBXFileReference, XCVersionGroup

Creates a new reference with the given path and adds it to the given group. The reference is configured according to the extension of the path.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/xcodeproj/project/object/helpers/file_references_factory.rb', line 25

def new_reference(group, path, source_tree)
  ref = case File.extname(path).downcase
        when '.xcdatamodeld'
          new_xcdatamodeld(group, path, source_tree)
        when '.xcodeproj'
          new_subproject(group, path, source_tree)
        else
          new_file_reference(group, path, source_tree)
        end

  configure_defaults_for_file_reference(ref)
  ref
end