>PBXLegacyTarget

PBXLegacyTarget

Represents a legacy target which uses an external build tool.

Apparently it can't have any build phase but the attribute can be present.

Inherits from:

Xcodeproj::Project::Object::AbstractTarget

Attributes

build_working_directory

build_arguments_string

pass_build_settings_in_environment

build_tool_path

build_phases

name

product_name

comments

build_configuration_list

dependencies

Helpers

sdk

platform_name

deployment_target

build_configurations

build_settings

Build Phases Helpers

frameworks_build_phases

copy_files_build_phases

shell_script_build_phases

add_dependency

new_copy_files_build_phase

new_shell_script_build_phase

AbstractObject Hooks

pretty_print

AbstractObject

isa

initialize

initialize_defaults

uuid

project

remove_from_project

display_name

to_s

Reference counting

referrers

add_referrer

remove_referrer

remove_reference

Object methods

==

<=>

inspect

xcodeproj format attributes

build_working_directory

Signature

build_working_directory #=> String 

Returns

String E.g "Dir"

Source

364 attribute :build_working_directory, String

Source Files

lib/xcodeproj/project/object/native_target.rb:364

spec/project/object/native_target_spec.rb

build_arguments_string

Signature

build_arguments_string #=> String 

Returns

String E.g "$(ACTION)"

Source

368 attribute :build_arguments_string, String

Source Files

lib/xcodeproj/project/object/native_target.rb:368

spec/project/object/native_target_spec.rb

pass_build_settings_in_environment

Signature

pass_build_settings_in_environment #=> String 

Returns

String E.g "1"

Source

372 attribute :pass_build_settings_in_environment, String

Source Files

lib/xcodeproj/project/object/native_target.rb:372

spec/project/object/native_target_spec.rb

build_tool_path

Signature

build_tool_path #=> String 

Returns

String E.g "/usr/bin/make"

Source

376 attribute :build_tool_path, String

Source Files

lib/xcodeproj/project/object/native_target.rb:376

spec/project/object/native_target_spec.rb

build_phases

Signature

build_phases #=> PBXBuildRule 

Returns

PBXBuildRule The build phases of the target.

Source

384 has_many :build_phases, AbstractBuildPhase

Source Files

lib/xcodeproj/project/object/native_target.rb:384

spec/project/object/native_target_spec.rb

nameinherited

Signature

name #=> String 

Returns

String The name of the Target.

Source

11 attribute :name, String

Source Files

lib/xcodeproj/project/object/native_target.rb:11

spec/project/object/native_target_spec.rb

product_nameinherited

Signature

product_name #=> String 

Returns

String The name of the build product.

Source

15 attribute :product_name, String

Source Files

lib/xcodeproj/project/object/native_target.rb:15

spec/project/object/native_target_spec.rb

commentsinherited

Signature

comments #=> String 

Returns

String Comments associated with this target. This is apparently no longer used by Xcode.

Source

21 attribute :comments, String

Source Files

lib/xcodeproj/project/object/native_target.rb:21

spec/project/object/native_target_spec.rb

build_configuration_listinherited

Signature

build_configuration_list #=> XCConfigurationList 

Returns

XCConfigurationList

The list of the build configurations of the target. This list commonly include two configurations Debug and Release.

Source

27 has_one :build_configuration_list, XCConfigurationList

Source Files

lib/xcodeproj/project/object/native_target.rb:27

spec/project/object/native_target_spec.rb

dependenciesinherited

Signature

dependencies #=> PBXNativeTarget 

Returns

PBXNativeTarget The targets necessary to build this target.

Source

31 has_many :dependencies, PBXTargetDependency

Source Files

lib/xcodeproj/project/object/native_target.rb:31

spec/project/object/native_target_spec.rb

sdkinherited

Signature

sdk #=> String 

Returns

String The SDK that the target should use.

Source

41 def sdk
42   build_configurations.first.build_settings['SDKROOT'] \
43     || project.build_configurations.first.build_settings['SDKROOT']
44 end

Source Files

lib/xcodeproj/project/object/native_target.rb:41

spec/project/object/native_target_spec.rb

platform_nameinherited

Signature

platform_name #=> Symbol 

Returns

Symbol The name of the platform of the target.

Source

48 def platform_name
49   if    sdk.include? 'iphoneos' then :ios
50   elsif sdk.include? 'macosx'   then :osx
51   end
52 end

Source Files

lib/xcodeproj/project/object/native_target.rb:48

spec/project/object/native_target_spec.rb

deployment_targetinherited

Signature

deployment_target #=> String 

Returns

String

The deployment target of the target according to its platform.

Source

57 def deployment_target
58   if platform_name == :ios
59     build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] ||
60       project.build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
61   else
62     build_configurations.first.build_settings['MACOSX_DEPLOYMENT_TARGET'] ||
63       project.build_configurations.first.build_settings['MACOSX_DEPLOYMENT_TARGET']
64   end
65 end

Source Files

lib/xcodeproj/project/object/native_target.rb:57

spec/project/object/native_target_spec.rb

build_configurationsinherited

Signature

build_configurations #=> ObjectList<XCBuildConfiguration> 

Returns

ObjectList

The build configurations of the target.

Source

70 def build_configurations
71   build_configuration_list.build_configurations
72 end

Source Files

lib/xcodeproj/project/object/native_target.rb:70

spec/project/object/native_target_spec.rb

build_settingsinherited

Signature

build_settings(build_configuration_name) #=> Hash 

Parameters

String build_configuration_name

The name of a build configuration.

Returns

Hash

The build settings of the build configuration with the given name.

Source

81 def build_settings(build_configuration_name)
82   build_configuration_list.build_settings(build_configuration_name)
83 end

Source Files

lib/xcodeproj/project/object/native_target.rb:81

spec/project/object/native_target_spec.rb

frameworks_build_phasesinherited

Signature

frameworks_build_phases #=> PBXFrameworksBuildPhase 

Returns

PBXFrameworksBuildPhase The copy files build phases of the target.

Source

90 def frameworks_build_phases
91   build_phases.find { |bp| bp.class == PBXFrameworksBuildPhase }
92 end

Source Files

lib/xcodeproj/project/object/native_target.rb:90

spec/project/object/native_target_spec.rb

copy_files_build_phasesinherited

Signature

copy_files_build_phases #=> Array<PBXCopyFilesBuildPhase> 

Returns

Array The copy files build phases of the target.

Source

97 def copy_files_build_phases
98   build_phases.select { |bp| bp.class == PBXCopyFilesBuildPhase }
99 end

Source Files

lib/xcodeproj/project/object/native_target.rb:97

spec/project/object/native_target_spec.rb

shell_script_build_phasesinherited

Signature

shell_script_build_phases #=> Array<PBXShellScriptBuildPhase> 

Returns

Array The copy files build phases of the target.

Source

104 def shell_script_build_phases
105   build_phases.select { |bp| bp.class == PBXShellScriptBuildPhase }
106 end

Source Files

lib/xcodeproj/project/object/native_target.rb:104

spec/project/object/native_target_spec.rb

add_dependencyinherited

Signature

add_dependency(target) #=> void 

Parameters

AbstractTarget target

The target which should be added to the dependencies list of the receiver.

Returns

void

Source

116 def add_dependency(target)
117   container_proxy = project.new(Xcodeproj::Project::PBXContainerItemProxy)
118   container_proxy.container_portal = project.root_object.uuid
119   container_proxy.proxy_type = '1'
120   container_proxy.remote_global_id_string = target.uuid
121   container_proxy.remote_info = target.name
122 
123   dependency = project.new(Xcodeproj::Project::PBXTargetDependency)
124   dependency.target = target
125   dependency.target_proxy = container_proxy
126 
127   dependencies << dependency
128 end

Source Files

lib/xcodeproj/project/object/native_target.rb:116

spec/project/object/native_target_spec.rb

new_copy_files_build_phaseinherited

Signature

new_copy_files_build_phase(name = nil) #=> PBXCopyFilesBuildPhase 

Parameters

String name

An optional name for the phase.

Returns

PBXCopyFilesBuildPhase The new phase.

Source

137 def new_copy_files_build_phase(name = nil)
138   phase = project.new(PBXCopyFilesBuildPhase)
139   phase.name = name
140   build_phases << phase
141   phase
142 end

Source Files

lib/xcodeproj/project/object/native_target.rb:137

spec/project/object/native_target_spec.rb

new_shell_script_build_phaseinherited

Signature

new_shell_script_build_phase(name = nil) #=> PBXShellScriptBuildPhase 

Parameters

String name

An optional name for the phase.

Returns

PBXShellScriptBuildPhase The new phase.

Source

150 def new_shell_script_build_phase(name = nil)
151   phase = project.new(PBXShellScriptBuildPhase)
152   phase.name = name
153   build_phases << phase
154   phase
155 end

Source Files

lib/xcodeproj/project/object/native_target.rb:150

spec/project/object/native_target_spec.rb

pretty_printinherited

Signature

pretty_print #=> Hash{String => Hash} 

Returns

Hash{String => Hash}

A hash suitable to display the object to the user.

Source

166 def pretty_print
167   {
168     display_name => {
169       'Build Phases' => build_phases.map(&:pretty_print),
170       'Build Configurations' => build_configurations.map(&:pretty_print)
171     }
172   }
173 end

Source Files

lib/xcodeproj/project/object/native_target.rb:166

spec/project/object/native_target_spec.rb

isaclass methodinherited

Signature

isa #=> String 

Returns

String The ISA of the class.

Signature

isa #=> String 

Returns

String The object's class name.

Source

42 def self.isa
43   @isa ||= name.split('::').last
44 end

Source Files

lib/xcodeproj/project/object.rb:42

spec/project/object_spec.rb

initializeinherited

Signature

initialize(project, uuid) #=> AbstractObject 

Parameters

Project project

The project that will host the object.

String uuid

The UUID of the new object.

Returns

AbstractObject A new instance of AbstractObject

Source

64 def initialize(project, uuid)
65   @project, @uuid = project, uuid
66   @isa = self.class.isa
67   @referrers = []
68   raise "[Xcodeproj] Attempt to initialize an abstract class." unless @isa.match(/^(PBX|XC)/)
69 end

Source Files

lib/xcodeproj/project/object.rb:64

spec/project/object_spec.rb

initialize_defaultsinherited

Signature

initialize_defaults #=> void 

Returns

void

Source

81 def initialize_defaults
82   simple_attributes.each { |a| a.set_default(self) }
83 end

Source Files

lib/xcodeproj/project/object.rb:81

spec/project/object_spec.rb

uuidattribute readerinherited

Signature

uuid #=> String 

Returns

String The object universally unique identifier.

Source Files

lib/xcodeproj/project/object.rb:87

spec/project/object_spec.rb

projectattribute readerinherited

Signature

project #=> Project 

Returns

Project The project that owns the object.

Source Files

lib/xcodeproj/project/object.rb:91

spec/project/object_spec.rb

remove_from_projectinherited

Signature

remove_from_project #=> void 

Returns

void

Source

101 def remove_from_project
102   @project.objects_by_uuid.delete(uuid)
103   @referrers.each { |referrer| referrer.remove_reference(self) }
104   raise "[Xcodeproj] BUG: #{self} should have no referrers instead the following objects are still referencing it #{referrers}" unless referrers.count == 0
105 end

Source Files

lib/xcodeproj/project/object.rb:101

spec/project/object_spec.rb

display_nameinherited

Signature

display_name #=> String 

Returns

String A name for the object.

Aliases

Xcodeproj::Project::Object::AbstractObject#to_s

Source

115 def display_name
116   declared_name = name if self.respond_to?(:name)
117   if declared_name && !declared_name.empty?
118     declared_name
119   else
120     isa.gsub(/^(PBX|XC)/, '')
121   end
122 end

Source Files

lib/xcodeproj/project/object.rb:115

spec/project/object_spec.rb

to_sinherited

Signature

to_s #=> String 

Returns

String A name for the object.

Source

124 def display_name
125   declared_name = name if self.respond_to?(:name)
126   if declared_name && !declared_name.empty?
127     declared_name
128   else
129     isa.gsub(/^(PBX|XC)/, '')
130   end
131 end

Source Files

lib/xcodeproj/project/object.rb:124

spec/project/object_spec.rb

referrersattribute readerinherited

Signature

referrers #=> Array<ObjectList> 

Returns

Array

The list of the objects that have a reference to this object.

Source Files

lib/xcodeproj/project/object.rb:133

spec/project/object_spec.rb

add_referrerinherited

Signature

add_referrer(referrer) #=> void 

Returns

void

Source

143 def add_referrer(referrer)
144   @referrers << referrer
145   @project.objects_by_uuid[uuid] = self
146 end

Source Files

lib/xcodeproj/project/object.rb:143

spec/project/object_spec.rb

remove_referrerinherited

Signature

remove_referrer(referrer) #=> void 

Returns

void

Source

156 def remove_referrer(referrer)
157   @referrers.delete(referrer)
158   if @referrers.count == 0
159     @project.objects_by_uuid.delete(uuid)
160   end
161 end

Source Files

lib/xcodeproj/project/object.rb:156

spec/project/object_spec.rb

remove_referenceinherited

Signature

remove_reference(object) #=> void 

Returns

void

Source

169 def remove_reference(object)
170   to_one_attributes.each do |attrb|
171     value = attrb.get_value(self)
172     attrb.set_value(self, nil) if value.equal?(object)
173   end
174 
175   to_many_attributes.each do |attrb|
176     list = attrb.get_value(self)
177     list.delete(object)
178   end
179 
180   references_by_keys_attributes.each do |attrb|
181     list = attrb.get_value(self)
182     list.each { |dictionary| dictionary.remove_reference(object) }
183   end
184 end

Source Files

lib/xcodeproj/project/object.rb:169

spec/project/object_spec.rb

configure_with_plistinherited

Signature

configure_with_plist(objects_by_uuid_plist) #=> void 

Returns

void

Source

202 def configure_with_plist(objects_by_uuid_plist)
203   object_plist = objects_by_uuid_plist[uuid].dup
204 
205   raise "[Xcodeproj] Attempt to initialize `#{isa}` from plist with different isa `#{object_plist}`" unless object_plist['isa'] == isa
206   object_plist.delete('isa')
207 
208   simple_attributes.each do |attrb|
209     attrb.set_value(self, object_plist[attrb.plist_name])
210     object_plist.delete(attrb.plist_name)
211   end
212 
213   to_one_attributes.each do |attrb|
214     ref_uuid = object_plist[attrb.plist_name]
215     if ref_uuid
216       ref = object_with_uuid(ref_uuid, objects_by_uuid_plist, attrb)
217       attrb.set_value(self, ref) if ref
218     end
219     object_plist.delete(attrb.plist_name)
220   end
221 
222   to_many_attributes.each do |attrb|
223     ref_uuids = object_plist[attrb.plist_name] || []
224     list = attrb.get_value(self)
225     ref_uuids.each do |uuid|
226       ref = object_with_uuid(uuid, objects_by_uuid_plist, attrb)
227       list << ref if ref
228     end
229     object_plist.delete(attrb.plist_name)
230   end
231 
232   references_by_keys_attributes.each do |attrb|
233     hashes = object_plist[attrb.plist_name] || {}
234     list = attrb.get_value(self)
235     hashes.each do |hash|
236       dictionary = ObjectDictionary.new(attrb, self)
237       hash.each do |key, uuid|
238         ref = object_with_uuid(uuid, objects_by_uuid_plist, attrb)
239         dictionary[key] = ref if ref
240       end
241       list << dictionary
242     end
243     object_plist.delete(attrb.plist_name)
244   end
245 
246   unless object_plist.empty?
247     raise "[!] Xcodeproj doesn't know about the following attributes " \
248           "#{object_plist.inspect} for the '#{isa}' isa.\n" \
249           "Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
250   end
251 end

Source Files

lib/xcodeproj/project/object.rb:202

spec/project/object_spec.rb

object_with_uuidinherited

Signature

object_with_uuid(uuid, objects_by_uuid_plist, attribute) #=> AbstractObject, Nil 

Parameters

String uuid

The UUID of the object that should be initialized.

Hash{String=>String} objects_by_uuid_plist

The hash contained by objects key of the plist containing the information about the object that should be initialized.

AbstractObjectAttribute attribute

The attribute that requested the object. It is used only for exceptions.

Returns

AbstractObject The initialized object.

Nil

If the UUID could not be found in the objects hash. In this case a warning is printed to STDERR.

Source

274 def object_with_uuid(uuid, objects_by_uuid_plist, attribute)
275   unless object = project.objects_by_uuid[uuid] || project.new_from_plist(uuid, objects_by_uuid_plist)
276     UI.warn "`#{inspect}` attempted to initialize an object with " \
277       "an unknown UUID. `#{uuid}` for attribute: `#{attribute.name}`."\
278       " This can be the result of a merge and the unknown UUID is "    \
279       "being discarded."
280   end
281   object
282 rescue NameError
283   attributes = objects_by_uuid_plist[uuid]
284   raise "`#{isa}` attempted to initialize an object with unknown ISA "\
285         "`#{attributes['isa']}` from attributes: `#{attributes}`\n"   \
286         "Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
287 end

Source Files

lib/xcodeproj/project/object.rb:274

spec/project/object_spec.rb

to_hashinherited

Signature

to_hash #=> Hash 

Returns

Hash A hash representation of the project.

Source

299 def to_hash
300   plist = {}
301   plist['isa'] = isa
302 
303   simple_attributes.each do |attrb|
304     value = attrb.get_value(self)
305     plist[attrb.plist_name] = value if value
306   end
307 
308   to_one_attributes.each do |attrb|
309     obj = attrb.get_value(self)
310     plist[attrb.plist_name] = obj.uuid if obj
311   end
312 
313   to_many_attributes.each do |attrb|
314   list = attrb.get_value(self)
315     plist[attrb.plist_name] = list.uuids
316   end
317 
318   references_by_keys_attributes.each do |attrb|
319     list = attrb.get_value(self)
320     plist[attrb.plist_name] = list.map { |dictionary| dictionary.to_hash }
321   end
322 
323   plist
324 end

Source Files

lib/xcodeproj/project/object.rb:299

spec/project/object_spec.rb

to_tree_hashinherited

Signature

to_tree_hash #=> Hash 

Returns

Hash

A hash representation of the project different from the plist one.

Source

339 def to_tree_hash
340   hash = {}
341   hash['displayName'] = display_name
342   hash['isa'] = isa
343 
344   simple_attributes.each do |attrb|
345     value = attrb.get_value(self)
346     hash[attrb.plist_name] = value if value
347   end
348 
349   to_one_attributes.each do |attrb|
350     obj = attrb.get_value(self)
351     hash[attrb.plist_name] = obj.to_tree_hash if obj
352   end
353 
354   to_many_attributes.each do |attrb|
355     list = attrb.get_value(self)
356     hash[attrb.plist_name] = list.map { |obj| obj.to_tree_hash }
357   end
358 
359   references_by_keys_attributes.each do |attrb|
360     list = attrb.get_value(self)
361     hash[attrb.plist_name] = list.map { |dictionary| dictionary.to_tree_hash }
362   end
363 
364   hash
365 end

Source Files

lib/xcodeproj/project/object.rb:339

spec/project/object_spec.rb

==inherited

Signature

==(other) #=> undefined

Source

385 def ==(other)
386   other.is_a?(AbstractObject) && self.to_hash == other.to_hash
387 end

Source Files

lib/xcodeproj/project/object.rb:385

spec/project/object_spec.rb

<=>inherited

Signature

<=>(other) #=> undefined

Source

389 def <=>(other)
390   self.uuid <=> other.uuid
391 end

Source Files

lib/xcodeproj/project/object.rb:389

spec/project/object_spec.rb

inspectinherited

Signature

inspect #=> undefined

Source

393 def inspect
394   name_part = " name=#{self.name}" if respond_to?(:name)
395   "<#{self.class}#{name_part} UUID=#{uuid}>"
396 end

Source Files

lib/xcodeproj/project/object.rb:393

spec/project/object_spec.rb