Class: Xcake::Xcode::Project

Inherits:
Xcodeproj::Project
  • Object
show all
Defined in:
lib/xcake/xcode/project.rb

Instance Method Summary collapse

Instance Method Details

#attributesHash

Returns the attributes of the project.

Returns:

  • (Hash)

    the attributes of the project



9
10
11
# File 'lib/xcake/xcode/project.rb', line 9

def attributes
  root_object.attributes
end

#class_prefixString

Returns the class name for the project.

Returns:

  • (String)

    the class name for the project



15
16
17
# File 'lib/xcake/xcode/project.rb', line 15

def class_prefix
  attributes['CLASSPREFIX']
end

#class_prefix=(class_prefix) ⇒ String

Sets the class prefix for the project

Parameters:

Returns:

  • (String)

    the class name for the project



25
26
27
# File 'lib/xcake/xcode/project.rb', line 25

def class_prefix=(class_prefix)
  attributes['CLASSPREFIX'] = class_prefix
end

#ensure_parent_path(group, node) ⇒ Object



167
168
169
170
# File 'lib/xcake/xcode/project.rb', line 167

def ensure_parent_path(group, node)
  group.path = node.component
  ensure_parent_path(group.parent, node.parent) unless node.parent.nil?
end

#find_unit_test_target_for_target(target) ⇒ Target

Finds a unit test target for a xcode target

Parameters:

  • target (Target)

    target to find a xcode target for.

Returns:

  • (Target)

    unit test target



179
180
181
182
183
# File 'lib/xcake/xcode/project.rb', line 179

def find_unit_test_target_for_target(target)
  targets.find do |t|
    t.name == "#{target.name}Tests"
  end
end

#new_configuration(_configuration) ⇒ Configurarion

Creates a new xcode configuration from the configuration DSL

Parameters:

  • configuration (Configurarion)

    configuration DSL to create target from

Returns:

  • (Configurarion)

    new xcode configuration



113
114
115
# File 'lib/xcake/xcode/project.rb', line 113

def new_configuration(_configuration)
  new(Xcodeproj::Project::Object::XCBuildConfiguration)
end

#new_file_reference(path) ⇒ PBXFileReference

Creates a new xcode file reference from the node

=> path of the file reference from the source root

Parameters:

Returns:

  • (PBXFileReference)

    new xcode file refrence



160
161
162
163
164
165
# File 'lib/xcake/xcode/project.rb', line 160

def new_file_reference(path)
  path_object = Pathname.new(path)
  group = main_group.find_subpath(path_object.dirname.to_s, true)
  group[path_object.basename.to_s] ||
    group.new_reference(path_object.to_s)
end

#new_group(node) ⇒ Group

Creates a new xcode group from the node

TODO: Simplify this method figure out more reliable rules for group generation - maybe part of the new file installer in 0.7.

As well as variant groups and other types of groups.

Parameters:

  • node (Node)

    configuration DSL to create target from

Returns:

  • (Group)

    new xcode group



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/xcake/xcode/project.rb', line 130

def new_group(node)

  return main_group unless node

  if node.component.include?(".lproj")

    group = main_group.find_subpath(node.parent.path, true) unless group

    variant_group = group.project.new(PBXVariantGroup)
    variant_group.set_source_tree(:group)
    group.children << variant_group

    group = variant_group
  else
    group = main_group.find_subpath(node.path, true) unless group
  end

  #TODO: Does this work with this new system
  ensure_parent_path(group, node)

  group
end

#new_target(target) ⇒ Target

Creates a new xcode target from the target DSL

Parameters:

  • target (Target)

    target DSL to create target from

Returns:

  • (Target)

    new xcode target



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/xcake/xcode/project.rb', line 85

def new_target(target)
  native_target = new(Xcodeproj::Project::Object::PBXNativeTarget)
  native_target.name = target.name
  native_target.product_name = target.name

  case target.type
  when Symbol
    native_target.product_type = Xcodeproj::Constants::PRODUCT_TYPE_UTI[target.type]
  when String
    native_target.product_type = target.type
  end

  native_target.build_configuration_list = new(Xcodeproj::Project::Object::XCConfigurationList)

  product = products_group.new_product_ref_for_target(native_target.product_name, native_target.product_type)
  native_target.product_reference = product

  targets << native_target
  native_target
end

#object_versionObject



51
52
53
# File 'lib/xcake/xcode/project.rb', line 51

def object_version
  Xcodeproj::Constants::DEFAULT_OBJECT_VERSION.to_s
end

#organizationString

Returns the organization for the project.

Returns:

  • (String)

    the organization for the project



31
32
33
# File 'lib/xcake/xcode/project.rb', line 31

def organization
  attributes['ORGANIZATIONNAME']
end

#organization=(organization) ⇒ SchemeList

Sets the organization for the project

Parameters:

Returns:

  • (SchemeList)

    the organization for the project



41
42
43
# File 'lib/xcake/xcode/project.rb', line 41

def organization=(organization)
  attributes['ORGANIZATIONNAME'] = organization
end

#recreate_user_schemesObject



55
56
57
58
# File 'lib/xcake/xcode/project.rb', line 55

def recreate_user_schemes(*)
  scheme_list.recreate_schemes
  scheme_list.save(path)
end

#scheme_listSchemeList

Returns the scheme list.

Returns:



47
48
49
# File 'lib/xcake/xcode/project.rb', line 47

def scheme_list
  @scheme_list ||= SchemeList.new(self)
end

#setup_for_xcakeObject

Configures the Project for use with Xcake. This makes sure we have sensible defaults and it as clean as possible.



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/xcake/xcode/project.rb', line 64

def setup_for_xcake
  root_object.remove_referrer(self) if root_object
  root_object = new(Project::Object::PBXProject)
  root_object.add_referrer(self)

  config_list = new(XCConfigurationList)
  root_object.build_configuration_list = config_list

  root_object.main_group = new(PBXGroup)
  root_object.product_ref_group = root_object.main_group.new_group('Products')

  @root_object = root_object
end