Class: Xcodeproj::Project::Object::PBXContainerItemProxy
- Inherits:
-
AbstractObject
- Object
- AbstractObject
- Xcodeproj::Project::Object::PBXContainerItemProxy
- Defined in:
- lib/xcodeproj/project/object/container_item_proxy.rb
Overview
This class references the other objects by UUID instead of creating proper relationships because the other objects might be part of another project. This implies that the references to other objects should not increase the retain count of the targets.
Apparently a proxy for another object which might belong another project contained in the same workspace of the project document.
This class is referenced by PBXTargetDependency for information about it usage see the specs of that class.
@todo: This class needs some work to support targets across workspaces,
as the container portal might not be initialized leading
xcodeproj to raise because ti can't find the UUID.
Attributes collapse
-
#container_portal ⇒ String
Apparently the UUID of the root object PBXProject of the project containing the represented object.
-
#proxy_type ⇒ String
The type of the proxy.
-
#remote_global_id_string ⇒ String
Apparently the UUID of the represented object.
-
#remote_info ⇒ String
Apparently the name of the object represented by the proxy.
Attributes inherited from AbstractObject
Attributes collapse
- #ascii_plist_annotation ⇒ Object
- #container_portal_annotation ⇒ Object
- #container_portal_object ⇒ Object
-
#proxied_object ⇒ AbstractObject
Get the proxied object.
-
#remote? ⇒ Bool
Checks whether the reference points to a remote project.
- #to_hash_as(method = :to_hash) ⇒ Object
Methods inherited from AbstractObject
#<=>, #==, #display_name, #inspect, isa, #nested_object_for_hash, #pretty_print, #remove_from_project, #sort, #sort_recursively, #to_ascii_plist, #to_hash
Instance Attribute Details
#container_portal ⇒ String
this is an attribute because a it is usually a reference to the root object or to a file reference to another project. The reference to the root object causes a retain cycle that could cause issues (e.g. in to_tree_hash). Usually those objects are retained by at least another object (the Xcodeproj::Project for the root object and a Xcodeproj::Project::Object::PBXGroup for the reference to another project) and so the referenced object should be serialized.
If this assumption is incorrect, there could be loss of information opening and saving an existing project.
This is the external reference that ‘contains’ other proxy items.
Returns apparently the UUID of the root object Xcodeproj::Project::Object::PBXProject of the project containing the represented object.
41 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 41 attribute :container_portal, String |
#proxy_type ⇒ String
@see Constants::PROXY_TYPE.values for valid values.
Returns the type of the proxy.
47 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 47 attribute :proxy_type, String |
#remote_global_id_string ⇒ String
If the object is in another project the UUID would not be present in the Xcodeproj::Project#objects_by_uuid hash. For this reason this is not an ‘has_one` attribute. It is assumes that if the object belongs to the project at least another object should be retaining it. This assumption is reasonable because this is a proxy class.
If this assumption is incorrect, there could be loss of information opening and saving an existing project.
Returns apparently the UUID of the represented object.
62 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 62 attribute :remote_global_id_string, String |
#remote_info ⇒ String
Returns apparently the name of the object represented by the proxy.
67 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 67 attribute :remote_info, String |
Instance Method Details
#ascii_plist_annotation ⇒ Object
110 111 112 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 110 def ascii_plist_annotation " #{isa} " end |
#container_portal_annotation ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 94 def container_portal_annotation if remote? " #{File.basename(project.objects_by_uuid[container_portal].real_path)} " else project.root_object.ascii_plist_annotation end end |
#container_portal_object ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 85 def container_portal_object if remote? container_portal_file_ref = project.objects_by_uuid[container_portal] Project.open(container_portal_file_ref.real_path) else project end end |
#proxied_object ⇒ AbstractObject
Get the proxied object
81 82 83 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 81 def proxied_object container_portal_object.objects_by_uuid[remote_global_id_string] end |
#remote? ⇒ Bool
Checks whether the reference points to a remote project.
73 74 75 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 73 def remote? project.root_object.uuid != container_portal end |
#to_hash_as(method = :to_hash) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/xcodeproj/project/object/container_item_proxy.rb', line 102 def to_hash_as(method = :to_hash) hash = super if method == :to_ascii_plist hash['containerPortal'] = Nanaimo::String.new(container_portal, container_portal_annotation) end hash end |