Class: Xcodeproj::Project::Object::PBXProject

Inherits:
AbstractObject show all
Defined in:
lib/xcodeproj/project/object/root_object.rb

Overview

This class represents the root object of a project document.

Attributes collapse

Attributes inherited from AbstractObject

#isa, #project, #uuid

Attributes collapse

Methods inherited from AbstractObject

#<=>, #==, #display_name, #inspect, isa, #nested_object_for_hash, #pretty_print, #remove_from_project, #sort, #sort_recursively, #to_hash

Instance Attribute Details

#attributesHash{String => String}

Note:

The hash might contain the following keys:

  • ‘CLASSPREFIX`

  • ‘LastUpgradeCheck`

  • ‘ORGANIZATIONNAME`

Returns attributes the attributes of the target.

Returns:

  • (Hash{String => String})

    attributes the attributes of the target.



23
24
25
# File 'lib/xcodeproj/project/object/root_object.rb', line 23

attribute :attributes, Hash,
'LastSwiftUpdateCheck' => Constants::LAST_SWIFT_UPGRADE_CHECK,
'LastUpgradeCheck' => Constants::LAST_UPGRADE_CHECK

#build_configuration_listXCConfigurationList

Returns the configuration list of the project.

Returns:



29
# File 'lib/xcodeproj/project/object/root_object.rb', line 29

has_one :build_configuration_list, XCConfigurationList

#compatibility_versionString

Returns the compatibility version of the project.

Returns:

  • (String)

    the compatibility version of the project.



33
# File 'lib/xcodeproj/project/object/root_object.rb', line 33

attribute :compatibility_version, String, 'Xcode 3.2'

#development_regionString

Returns the development region of the project.

Returns:

  • (String)

    the development region of the project.



37
# File 'lib/xcodeproj/project/object/root_object.rb', line 37

attribute :development_region, String, 'en'

#has_scanned_for_encodingsString

Returns whether the project has scanned for encodings.

Returns:

  • (String)

    whether the project has scanned for encodings.



41
# File 'lib/xcodeproj/project/object/root_object.rb', line 41

attribute :has_scanned_for_encodings, String, '0'

#known_regionsArray<String>

Returns the list of known regions.

Returns:

  • (Array<String>)

    the list of known regions.



45
# File 'lib/xcodeproj/project/object/root_object.rb', line 45

attribute :known_regions, Array, %w(en Base)

#main_groupPBXGroup

Returns the main group of the project. The one displayed by Xcode in the Project Navigator.

Returns:

  • (PBXGroup)

    the main group of the project. The one displayed by Xcode in the Project Navigator.



50
# File 'lib/xcodeproj/project/object/root_object.rb', line 50

has_one :main_group, PBXGroup

#product_ref_groupPBXGroup

Returns the group containing the references to products of the project.

Returns:

  • (PBXGroup)

    the group containing the references to products of the project.



55
# File 'lib/xcodeproj/project/object/root_object.rb', line 55

has_one :product_ref_group, PBXGroup

#project_dir_pathString

Returns the directory of the project.

Returns:

  • (String)

    the directory of the project.



59
# File 'lib/xcodeproj/project/object/root_object.rb', line 59

attribute :project_dir_path, String, ''

#project_referencesArray<ObjectDictionary> (readonly)

Returns any reference to other projects.

Returns:



71
72
73
# File 'lib/xcodeproj/project/object/root_object.rb', line 71

has_many_references_by_keys :project_references,
:project_ref   => PBXFileReference,
:product_group => PBXGroup

#project_rootString

Returns the root of the project.

Returns:

  • (String)

    the root of the project.



63
# File 'lib/xcodeproj/project/object/root_object.rb', line 63

attribute :project_root, String, ''

Instance Method Details

#ascii_plist_annotationObject



79
80
81
# File 'lib/xcodeproj/project/object/root_object.rb', line 79

def ascii_plist_annotation
  ' Project object '
end

#nameObject



75
76
77
# File 'lib/xcodeproj/project/object/root_object.rb', line 75

def name
  project.path.basename('.xcodeproj').to_s
end

#package_referencesArray<XCRemoteSwiftPackageReference>

Returns the list of Swift package references.

Returns:



67
# File 'lib/xcodeproj/project/object/root_object.rb', line 67

has_many :package_references, XCRemoteSwiftPackageReference

#targetsObjectList<AbstractTarget>

Returns a list of all the targets in the project.

Returns:



12
# File 'lib/xcodeproj/project/object/root_object.rb', line 12

has_many :targets, AbstractTarget

#to_ascii_plistObject



91
92
93
94
95
96
# File 'lib/xcodeproj/project/object/root_object.rb', line 91

def to_ascii_plist
  plist = super
  plist.value.delete('projectReferences') if plist.value['projectReferences'].empty?
  plist.value.delete('packageReferences') if !plist.value['packageReferences'].nil? && plist.value['packageReferences'].empty?
  plist
end

#to_hash_as(method = :to_hash) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/xcodeproj/project/object/root_object.rb', line 83

def to_hash_as(method = :to_hash)
  hash_as = super
  if !hash_as['packageReferences'].nil? && hash_as['packageReferences'].empty?
    hash_as.delete('packageReferences') if !hash_as['packageReferences'].nil? && hash_as['packageReferences'].empty?
  end
  hash_as
end