plasmo_xcodeproj 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +19 -0
  3. data/README.md +95 -0
  4. data/bin/xcodeproj +10 -0
  5. data/lib/xcodeproj/command/config_dump.rb +91 -0
  6. data/lib/xcodeproj/command/project_diff.rb +56 -0
  7. data/lib/xcodeproj/command/show.rb +60 -0
  8. data/lib/xcodeproj/command/sort.rb +44 -0
  9. data/lib/xcodeproj/command/target_diff.rb +43 -0
  10. data/lib/xcodeproj/command.rb +63 -0
  11. data/lib/xcodeproj/config/other_linker_flags_parser.rb +73 -0
  12. data/lib/xcodeproj/config.rb +386 -0
  13. data/lib/xcodeproj/constants.rb +465 -0
  14. data/lib/xcodeproj/differ.rb +239 -0
  15. data/lib/xcodeproj/gem_version.rb +5 -0
  16. data/lib/xcodeproj/helper.rb +30 -0
  17. data/lib/xcodeproj/plist.rb +94 -0
  18. data/lib/xcodeproj/project/case_converter.rb +90 -0
  19. data/lib/xcodeproj/project/object/build_configuration.rb +255 -0
  20. data/lib/xcodeproj/project/object/build_file.rb +84 -0
  21. data/lib/xcodeproj/project/object/build_phase.rb +369 -0
  22. data/lib/xcodeproj/project/object/build_rule.rb +109 -0
  23. data/lib/xcodeproj/project/object/configuration_list.rb +117 -0
  24. data/lib/xcodeproj/project/object/container_item_proxy.rb +116 -0
  25. data/lib/xcodeproj/project/object/file_reference.rb +338 -0
  26. data/lib/xcodeproj/project/object/group.rb +506 -0
  27. data/lib/xcodeproj/project/object/helpers/build_settings_array_settings_by_object_version.rb +72 -0
  28. data/lib/xcodeproj/project/object/helpers/file_references_factory.rb +245 -0
  29. data/lib/xcodeproj/project/object/helpers/groupable_helper.rb +260 -0
  30. data/lib/xcodeproj/project/object/native_target.rb +751 -0
  31. data/lib/xcodeproj/project/object/reference_proxy.rb +86 -0
  32. data/lib/xcodeproj/project/object/root_object.rb +100 -0
  33. data/lib/xcodeproj/project/object/swift_package_product_dependency.rb +29 -0
  34. data/lib/xcodeproj/project/object/swift_package_remote_reference.rb +33 -0
  35. data/lib/xcodeproj/project/object/target_dependency.rb +94 -0
  36. data/lib/xcodeproj/project/object.rb +534 -0
  37. data/lib/xcodeproj/project/object_attributes.rb +522 -0
  38. data/lib/xcodeproj/project/object_dictionary.rb +210 -0
  39. data/lib/xcodeproj/project/object_list.rb +223 -0
  40. data/lib/xcodeproj/project/project_helper.rb +341 -0
  41. data/lib/xcodeproj/project/uuid_generator.rb +132 -0
  42. data/lib/xcodeproj/project.rb +874 -0
  43. data/lib/xcodeproj/scheme/abstract_scheme_action.rb +100 -0
  44. data/lib/xcodeproj/scheme/analyze_action.rb +19 -0
  45. data/lib/xcodeproj/scheme/archive_action.rb +59 -0
  46. data/lib/xcodeproj/scheme/build_action.rb +298 -0
  47. data/lib/xcodeproj/scheme/buildable_product_runnable.rb +55 -0
  48. data/lib/xcodeproj/scheme/buildable_reference.rb +129 -0
  49. data/lib/xcodeproj/scheme/command_line_arguments.rb +162 -0
  50. data/lib/xcodeproj/scheme/environment_variables.rb +170 -0
  51. data/lib/xcodeproj/scheme/execution_action.rb +86 -0
  52. data/lib/xcodeproj/scheme/launch_action.rb +179 -0
  53. data/lib/xcodeproj/scheme/location_scenario_reference.rb +49 -0
  54. data/lib/xcodeproj/scheme/macro_expansion.rb +34 -0
  55. data/lib/xcodeproj/scheme/profile_action.rb +57 -0
  56. data/lib/xcodeproj/scheme/remote_runnable.rb +92 -0
  57. data/lib/xcodeproj/scheme/send_email_action_content.rb +84 -0
  58. data/lib/xcodeproj/scheme/shell_script_action_content.rb +77 -0
  59. data/lib/xcodeproj/scheme/test_action.rb +394 -0
  60. data/lib/xcodeproj/scheme/xml_element_wrapper.rb +82 -0
  61. data/lib/xcodeproj/scheme.rb +375 -0
  62. data/lib/xcodeproj/user_interface.rb +22 -0
  63. data/lib/xcodeproj/workspace/file_reference.rb +79 -0
  64. data/lib/xcodeproj/workspace/group_reference.rb +67 -0
  65. data/lib/xcodeproj/workspace/reference.rb +40 -0
  66. data/lib/xcodeproj/workspace.rb +277 -0
  67. data/lib/xcodeproj/xcodebuild_helper.rb +108 -0
  68. data/lib/xcodeproj.rb +29 -0
  69. metadata +208 -0
@@ -0,0 +1,210 @@
1
+ module Xcodeproj
2
+ class Project
3
+ # This class represents relationships to other objects stored in a
4
+ # Dictionary.
5
+ #
6
+ # It works in conjunction with the {AbstractObject} class to ensure that
7
+ # the project is not serialized with unreachable objects by updating the
8
+ # with reference count on modifications.
9
+ #
10
+ # @note To provide full support as the other classes the dictionary should:
11
+ #
12
+ # Give the following attribute:
13
+ #
14
+ # has_many_references_by_keys :project_references, {
15
+ # :project_ref => PBXFileReference,
16
+ # :product_group => PBXGroup
17
+ # }
18
+ #
19
+ # This should be possible:
20
+ #
21
+ # #=> Note the API:
22
+ # root_object.project_references.project_ref = file
23
+ #
24
+ # #=> This should raise:
25
+ # root_object.project_references.product_group = file
26
+ #
27
+ # I.e. generate setters and getters from the specification hash.
28
+ #
29
+ # Also the interface is a dirty hybrid between the
30
+ # {AbstractObjectAttribute} and the {ObjectList}.
31
+ #
32
+ # @note Concerning the mutations methods it is safe to call only those
33
+ # which are overridden to inform objects reference count. Ideally all
34
+ # the hash methods should be covered, but this is not done yet.
35
+ # Moreover it is a moving target because the methods of array
36
+ # usually are implemented in C.
37
+ #
38
+ # @todo This class should use a {Hash} as a backing store instead of
39
+ # inheriting from it. This would prevent the usage of methods which
40
+ # don't notify the objects.
41
+ #
42
+ class ObjectDictionary < Hash
43
+ # @param [Object::AbstractObjectAttribute] attribute @see #attribute
44
+ # @param [Object] owner @see #owner
45
+ #
46
+ def initialize(attribute, owner)
47
+ @attribute = attribute
48
+ @owner = owner
49
+ end
50
+
51
+ # @return [Object::AbstractObjectAttribute] The attribute that generated
52
+ # the list.
53
+ #
54
+ attr_reader :attribute
55
+
56
+ # @return [Object] The object that owns the list.
57
+ #
58
+ attr_reader :owner
59
+
60
+ # @return [Array<Symbol>] The list of the allowed keys.
61
+ #
62
+ def allowed_keys
63
+ attribute.classes_by_key.keys
64
+ end
65
+
66
+ # @return [String] A string suitable for debugging.
67
+ #
68
+ def inspect
69
+ "<ObjectDictionary attribute:`#{@attribute.name}` " \
70
+ "owner:`#{@owner.display_name}` values:#{super.inspect}>"
71
+ end
72
+
73
+ # @!group Notification enabled methods
74
+ #------------------------------------------------------------------------#
75
+
76
+ # Associates an object to the given key and updates its references count.
77
+ #
78
+ # @param [String] key
79
+ # The key.
80
+ #
81
+ # @param [AbstractObject] object
82
+ # The object to add to the dictionary.
83
+ #
84
+ # @return [AbstractObject] The given object.
85
+ #
86
+ def []=(key, object)
87
+ key = normalize_key(key)
88
+ if object
89
+ perform_additions_operations(object, key)
90
+ else
91
+ perform_deletion_operations(self[key])
92
+ end
93
+ super(key, object)
94
+ end
95
+
96
+ # Removes the given key from the dictionary and informs the object that
97
+ # is not longer referenced by the owner.
98
+ #
99
+ # @param [String] key
100
+ # The key.
101
+ #
102
+ def delete(key)
103
+ key = normalize_key(key)
104
+ object = self[key]
105
+ perform_deletion_operations(object)
106
+ super
107
+ end
108
+
109
+ # @!group AbstractObject Methods
110
+ #-----------------------------------------------------------------------#
111
+
112
+ # @return [Hash<String => String>] The plist representation of the
113
+ # dictionary where the objects are replaced by their UUIDs.
114
+ #
115
+ def to_hash
116
+ result = {}
117
+ each do |key, obj|
118
+ if obj
119
+ plist_key = Object::CaseConverter.convert_to_plist(key, nil)
120
+ result[plist_key] = Nanaimo::String.new(obj.uuid, obj.ascii_plist_annotation)
121
+ end
122
+ end
123
+ result
124
+ end
125
+
126
+ def to_ascii_plist
127
+ to_hash
128
+ end
129
+
130
+ # @return [Hash<String => String>] Returns a cascade representation of
131
+ # the object without UUIDs.
132
+ #
133
+ def to_tree_hash
134
+ result = {}
135
+ each do |key, obj|
136
+ if obj
137
+ plist_key = Object::CaseConverter.convert_to_plist(key, nil)
138
+ result[plist_key] = obj.to_tree_hash
139
+ end
140
+ end
141
+ result
142
+ end
143
+
144
+ # Removes all the references to a given object.
145
+ #
146
+ def remove_reference(object)
147
+ each { |key, obj| self[key] = nil if obj == object }
148
+ end
149
+
150
+ # Informs the objects contained in the dictionary that another object is
151
+ # referencing them.
152
+ #
153
+ def add_referrer(referrer)
154
+ values.each { |obj| obj.add_referrer(referrer) }
155
+ end
156
+
157
+ # Informs the objects contained in the dictionary that another object
158
+ # stopped referencing them.
159
+ #
160
+ def remove_referrer(referrer)
161
+ values.each { |obj| obj.remove_referrer(referrer) }
162
+ end
163
+
164
+ private
165
+
166
+ # @!group Private helpers
167
+ #------------------------------------------------------------------------#
168
+
169
+ # @return [Symbol] Normalizes a key to a symbol converting the camel case
170
+ # format with underscores.
171
+ #
172
+ # @param [String, Symbol] key
173
+ # The key to normalize.
174
+ #
175
+ def normalize_key(key)
176
+ if key.is_a?(String)
177
+ key = Object::CaseConverter.convert_to_ruby(key)
178
+ end
179
+
180
+ unless allowed_keys.include?(key)
181
+ raise "[Xcodeproj] Unsupported key `#{key}` (allowed " \
182
+ "`#{allowed_keys}`) for `#{inspect}`"
183
+ end
184
+ key
185
+ end
186
+
187
+ # Informs an object that it was added to the dictionary. In practice it
188
+ # adds the owner of the list as referrer to the objects. It also
189
+ # validates the value.
190
+ #
191
+ # @return [void]
192
+ #
193
+ def perform_additions_operations(object, key)
194
+ owner.mark_project_as_dirty!
195
+ object.add_referrer(owner)
196
+ attribute.validate_value_for_key(object, key)
197
+ end
198
+
199
+ # Informs an object that it was removed from to the dictionary, so it can
200
+ # remove it from its referrers and take the appropriate actions.
201
+ #
202
+ # @return [void]
203
+ #
204
+ def perform_deletion_operations(objects)
205
+ owner.mark_project_as_dirty!
206
+ objects.remove_referrer(owner)
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,223 @@
1
+ module Xcodeproj
2
+ class Project
3
+ # This class represents an ordered relationship to many objects.
4
+ #
5
+ # It works in conjunction with the {AbstractObject} class to ensure that
6
+ # the project is not serialized with unreachable objects by updating the
7
+ # with reference count on modifications.
8
+ #
9
+ # @note Concerning the mutations methods it is safe to call only those
10
+ # which are overridden to inform objects reference count. Ideally all
11
+ # the array methods should be covered, but this is not done yet.
12
+ # Moreover it is a moving target because the methods of array
13
+ # usually are implemented in C
14
+ #
15
+ # @todo Cover all the mutations methods of the {Array} class.
16
+ #
17
+ class ObjectList < Array
18
+ # {Xcodeproj} clients are not expected to create instances of
19
+ # {ObjectList}, it is always initialized empty and automatically by the
20
+ # synthesized methods generated by {AbstractObject.has_many}.
21
+ #
22
+ def initialize(attribute, owner)
23
+ @attribute = attribute
24
+ @owner = owner
25
+ end
26
+
27
+ # @return [Array<Class>] the attribute that generated the list.
28
+ #
29
+ attr_reader :attribute
30
+
31
+ # @return [Array<Class>] the object that owns the list.
32
+ #
33
+ attr_reader :owner
34
+
35
+ # @return [Array<String>]
36
+ # the UUIDs of all the objects referenced by this list.
37
+ #
38
+ def uuids
39
+ map(&:uuid)
40
+ end
41
+
42
+ # @return [Array<AbstractObject>]
43
+ # a new array generated with the objects contained in the list.
44
+ #
45
+ def objects
46
+ to_a
47
+ end
48
+
49
+ public
50
+
51
+ # @!group Notification enabled methods
52
+ #------------------------------------------------------------------------#
53
+
54
+ # TODO: the overridden methods are incomplete.
55
+
56
+ # Adds an array of objects to list and updates their references count.
57
+ #
58
+ # @param [Array<AbstractObject, ObjectDictionary>] objects
59
+ # an array of objects to add to the list.
60
+ #
61
+ # @return [void]
62
+ #
63
+ def +(other)
64
+ perform_additions_operations(other)
65
+ super
66
+ end
67
+
68
+ # Appends an object to list the and updates its references count.
69
+ #
70
+ # @param [AbstractObject, ObjectDictionary] object
71
+ # The object to add to the list.
72
+ #
73
+ # @return [void]
74
+ #
75
+ def <<(object)
76
+ perform_additions_operations(object)
77
+ super
78
+ end
79
+
80
+ # Adds an object to the given index of the list the and updates its
81
+ # references count.
82
+ #
83
+ # @param [AbstractObject, ObjectDictionary] object
84
+ # The object to add to the list.
85
+ #
86
+ # @return [void]
87
+ #
88
+ def insert(index, object)
89
+ perform_additions_operations(object)
90
+ super
91
+ end
92
+
93
+ # Prepends an object to the list and updates its references count.
94
+ #
95
+ # @param [AbstractObject, ObjectDictionary] object
96
+ # The object to add to the list.
97
+ #
98
+ # @return [void]
99
+ #
100
+ def unshift(object)
101
+ perform_additions_operations(object)
102
+ super
103
+ end
104
+
105
+ # Removes an object to list and updates its references count.
106
+ #
107
+ # @param [AbstractObject, ObjectDictionary] object
108
+ # the object to delete from the list.
109
+ #
110
+ # @return [AbstractObject, ObjectDictionary, Nil] the object if found.
111
+ #
112
+ def delete(object)
113
+ perform_deletion_operations(object)
114
+ super
115
+ end
116
+
117
+ # Removes the object at the given index from the list and updates its
118
+ # references count.
119
+ #
120
+ # @param [Fixnum] from
121
+ # The index of the object.
122
+ #
123
+ # @return [AbstractObject, ObjectDictionary, Nil] the object if found.
124
+ #
125
+ def delete_at(index)
126
+ object = at(index)
127
+ perform_deletion_operations(object)
128
+ super
129
+ end
130
+
131
+ # Removes all the objects contained in the list and updates their
132
+ # reference counts.
133
+ #
134
+ # @return [void]
135
+ #
136
+ def clear
137
+ objects.each do |object|
138
+ perform_deletion_operations(object)
139
+ end
140
+ super
141
+ end
142
+
143
+ # Moves the given object to the given index.
144
+ #
145
+ # @param [AbstractObject, ObjectDictionary] object
146
+ # The object to move.
147
+ #
148
+ # @param [Fixnum] to
149
+ # The new index for the object.
150
+ #
151
+ # @return [void]
152
+ #
153
+ def move(object, new_index)
154
+ return if index(object) == new_index
155
+ if obj = delete(object)
156
+ insert(new_index, obj)
157
+ else
158
+ raise "Attempt to move object `#{object}` not present in the list `#{inspect}`"
159
+ end
160
+ end
161
+
162
+ # Moves the object at the given index to the given position.
163
+ #
164
+ # @param [Fixnum] from
165
+ # The current index of the object.
166
+ #
167
+ # @param [Fixnum] to
168
+ # The new index for the object.
169
+ #
170
+ # @return [void]
171
+ #
172
+ def move_from(current_index, new_index)
173
+ return if current_index == new_index
174
+ if obj = delete_at(current_index)
175
+ insert(new_index, obj)
176
+ else
177
+ raise "Attempt to move object from index `#{current_index}` which is beyond bounds of the list `#{inspect}`"
178
+ end
179
+ end
180
+
181
+ def sort!
182
+ return super if owner.project.dirty?
183
+ previous = to_a
184
+ super
185
+ owner.mark_project_as_dirty! unless previous == to_a
186
+ self
187
+ end
188
+
189
+ private
190
+
191
+ # @!group Notification Methods
192
+ #------------------------------------------------------------------------#
193
+
194
+ # Informs an object that it was added to the list. In practice it adds
195
+ # the owner of the list as referrer to the objects. It also validates the
196
+ # value.
197
+ #
198
+ # @return [void]
199
+ #
200
+ def perform_additions_operations(objects)
201
+ objects = [objects] unless objects.is_a?(Array)
202
+ objects.each do |obj|
203
+ owner.mark_project_as_dirty!
204
+ obj.add_referrer(owner)
205
+ attribute.validate_value(obj) unless obj.is_a?(ObjectDictionary)
206
+ end
207
+ end
208
+
209
+ # Informs an object that it was removed from to the list, so it can
210
+ # remove its owner from its referrers and take the appropriate actions.
211
+ #
212
+ # @return [void]
213
+ #
214
+ def perform_deletion_operations(objects)
215
+ objects = [objects] unless objects.is_a?(Array)
216
+ objects.each do |obj|
217
+ owner.mark_project_as_dirty!
218
+ obj.remove_referrer(owner) unless obj.is_a?(ObjectDictionary)
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end