xcodeproj 0.3.5 → 0.4.0.rc1
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.
- data/bin/xcodeproj +13 -0
- data/lib/xcodeproj.rb +13 -1
- data/lib/xcodeproj/command.rb +131 -0
- data/lib/xcodeproj/command/project_diff.rb +53 -0
- data/lib/xcodeproj/command/show.rb +35 -0
- data/lib/xcodeproj/command/target_diff.rb +43 -0
- data/lib/xcodeproj/config.rb +66 -38
- data/lib/xcodeproj/constants.rb +146 -0
- data/lib/xcodeproj/helper.rb +28 -0
- data/lib/xcodeproj/project.rb +462 -156
- data/lib/xcodeproj/project/object.rb +251 -138
- data/lib/xcodeproj/project/object/build_configuration.rb +27 -0
- data/lib/xcodeproj/project/object/build_file.rb +26 -0
- data/lib/xcodeproj/project/object/build_phase.rb +132 -61
- data/lib/xcodeproj/project/object/build_rule.rb +46 -0
- data/lib/xcodeproj/project/object/configuration_list.rb +47 -0
- data/lib/xcodeproj/project/object/container_item_proxy.rb +49 -0
- data/lib/xcodeproj/project/object/file_reference.rb +80 -48
- data/lib/xcodeproj/project/object/group.rb +213 -89
- data/lib/xcodeproj/project/object/native_target.rb +171 -114
- data/lib/xcodeproj/project/object/root_object.rb +66 -0
- data/lib/xcodeproj/project/object/target_dependency.rb +23 -0
- data/lib/xcodeproj/project/object_attributes.rb +382 -0
- data/lib/xcodeproj/project/object_list.rb +64 -118
- data/lib/xcodeproj/project/recursive_diff.rb +116 -0
- data/lib/xcodeproj/workspace.rb +56 -2
- metadata +38 -10
- data/lib/xcodeproj/project/association.rb +0 -54
- data/lib/xcodeproj/project/association/has_many.rb +0 -51
- data/lib/xcodeproj/project/association/has_one.rb +0 -39
- data/lib/xcodeproj/project/association/reflection.rb +0 -86
- data/lib/xcodeproj/project/object/configuration.rb +0 -97
@@ -2,122 +2,246 @@ module Xcodeproj
|
|
2
2
|
class Project
|
3
3
|
module Object
|
4
4
|
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
# This class represents a group. A group can contain other groups
|
6
|
+
# (PBXGroup) and file references (PBXFileReference).
|
7
|
+
#
|
8
|
+
class PBXGroup < AbstractObject
|
9
|
+
|
10
|
+
# @return [ObjectList<PBXGroup, PBXFileReference>]
|
11
|
+
# the objects contained by the group.
|
12
|
+
#
|
13
|
+
has_many :children, [PBXGroup, PBXFileReference]
|
14
|
+
|
15
|
+
# @return [String] the source tree to which this group is relative.
|
16
|
+
#
|
17
|
+
# Usually is group <group>.
|
18
|
+
#
|
19
|
+
attribute :source_tree, String, '<group>'
|
20
|
+
|
21
|
+
# @return [String] the path to a folder in the file system.
|
22
|
+
#
|
23
|
+
# This attribute is present for groups that are linked to a folder in
|
24
|
+
# the file system.
|
25
|
+
#
|
26
|
+
attribute :path, String
|
27
|
+
|
28
|
+
# @return [String] the name of the group.
|
29
|
+
#
|
30
|
+
# If path is specified this attribute is not present.
|
31
|
+
#
|
32
|
+
attribute :name, String
|
16
33
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
34
|
+
end
|
35
|
+
|
36
|
+
# The purpose of this subclass is not understood.
|
37
|
+
#
|
38
|
+
class PBXVariantGroup < PBXGroup
|
21
39
|
|
22
|
-
# Sorts groups before files and inside those sorts by name.
|
23
|
-
def <=>(other)
|
24
|
-
if self.is_a?(PBXGroup) && other.is_a?(PBXFileReference)
|
25
|
-
-1
|
26
|
-
elsif self.is_a?(PBXFileReference) && other.is_a?(PBXGroup)
|
27
|
-
1
|
28
|
-
else
|
29
|
-
self.name <=> other.name
|
30
|
-
end
|
31
|
-
end
|
32
40
|
end
|
33
41
|
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
has_many :children, :class => AbstractGroupEntry do |child|
|
41
|
-
# Associating the AbstractGroupEntry instance to this group through
|
42
|
-
# the inverse association will also remove it from the group it was
|
43
|
-
# in.
|
44
|
-
child.group = self
|
45
|
-
end
|
42
|
+
# A group that contains multiple files references to the different
|
43
|
+
# versions of a resource.
|
44
|
+
#
|
45
|
+
# Used to contain the different versions of a `xcdatamodel`.
|
46
|
+
#
|
47
|
+
class XCVersionGroup < PBXGroup
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
self.child_references ||= []
|
51
|
-
end
|
49
|
+
# @return [PBXFileReference] the reference to the current version.
|
50
|
+
#
|
51
|
+
has_one :current_version, PBXFileReference
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
# @return [String] the type of the versioned resource.
|
54
|
+
#
|
55
|
+
attribute :version_group_type, String, 'wrapper.xcdatamodel'
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
class PBXGroup < AbstractObject
|
56
60
|
|
57
|
-
|
58
|
-
|
61
|
+
## CONVENIENCE METHODS #################################################
|
62
|
+
|
63
|
+
# @!group Convenience methods
|
64
|
+
|
65
|
+
# @return [String] the name of the group taking into account the path
|
66
|
+
# or other factors if needed.
|
67
|
+
#
|
68
|
+
def display_name
|
69
|
+
if name
|
59
70
|
name
|
60
|
-
elsif
|
61
|
-
File.basename(
|
62
|
-
elsif main_group
|
71
|
+
elsif path
|
72
|
+
File.basename(path)
|
73
|
+
elsif self.equal?(project.main_group)
|
63
74
|
'Main Group'
|
64
75
|
end
|
65
76
|
end
|
66
77
|
|
78
|
+
# @return [Array<PBXFileReference>] the files references in the group
|
79
|
+
# children.
|
80
|
+
#
|
67
81
|
def files
|
68
|
-
children.
|
69
|
-
end
|
70
|
-
|
71
|
-
def create_file(path)
|
72
|
-
files.new("path" => path)
|
73
|
-
end
|
74
|
-
|
75
|
-
def create_files(paths)
|
76
|
-
paths.map { |path| create_file(path) }
|
77
|
-
end
|
78
|
-
|
79
|
-
def source_files
|
80
|
-
children.list_by_class(PBXFileReference) do |list|
|
81
|
-
list.let(:uuid_scope) do
|
82
|
-
files.reject { |file| file.build_files.empty? }.map(&:uuid)
|
83
|
-
end
|
84
|
-
end
|
82
|
+
children.select { |obj| obj.class == PBXFileReference }
|
85
83
|
end
|
86
84
|
|
85
|
+
# @return [Array<PBXGroup>] the groups in the group
|
86
|
+
# children.
|
87
|
+
#
|
87
88
|
def groups
|
88
|
-
children.
|
89
|
+
children.select { |obj| obj.class == PBXGroup }
|
89
90
|
end
|
90
91
|
|
91
|
-
|
92
|
-
|
92
|
+
# @return [Array<XCVersionGroup>] the version groups in the group
|
93
|
+
# children.
|
94
|
+
#
|
95
|
+
def version_groups
|
96
|
+
children.select { |obj| obj.class == XCVersionGroup }
|
97
|
+
end
|
98
|
+
|
99
|
+
# Creates a new file reference with the given path and adds it to the
|
100
|
+
# group or to an optional subpath.
|
101
|
+
#
|
102
|
+
# @note The subpath is created if needed, similar to the UNIX command `mkdir -p`
|
103
|
+
#
|
104
|
+
# @param [#to_s] path
|
105
|
+
# the file system path of the file.
|
106
|
+
#
|
107
|
+
# @param [String] sub_group_path
|
108
|
+
# an optional subgroup path indicating the groups separated by a `/`.
|
109
|
+
#
|
110
|
+
# @return [PBXFileReference] the new file reference.
|
111
|
+
#
|
112
|
+
def new_file(path, sub_group_path = nil)
|
113
|
+
file = project.new(PBXFileReference)
|
114
|
+
file.path = path.to_s
|
115
|
+
file.name = file.pathname.basename.to_s
|
116
|
+
file.update_last_known_file_type
|
117
|
+
|
118
|
+
target = find_subpath(sub_group_path, true)
|
119
|
+
target.children << file
|
120
|
+
file
|
121
|
+
end
|
122
|
+
|
123
|
+
# Creates a new group with the given name and adds it to the children
|
124
|
+
# of the group.
|
125
|
+
#
|
126
|
+
# @note (see #new_file)
|
127
|
+
#
|
128
|
+
# @param [#to_s] name
|
129
|
+
# the name of the new group.
|
130
|
+
#
|
131
|
+
# @param [String] sub_group_path (see #new_file)
|
132
|
+
#
|
133
|
+
# @return [PBXGroup] the new group.
|
134
|
+
#
|
135
|
+
def new_group(name, sub_group_path = nil)
|
136
|
+
group = project.new(PBXGroup)
|
137
|
+
group.name = name
|
138
|
+
|
139
|
+
target = find_subpath(sub_group_path, true)
|
140
|
+
target.children << group
|
141
|
+
group
|
93
142
|
end
|
94
143
|
|
95
|
-
|
96
|
-
|
144
|
+
# Creates a file reference to a static library and adds it to the
|
145
|
+
# children of the group.
|
146
|
+
#
|
147
|
+
# @note (see #new_file)
|
148
|
+
#
|
149
|
+
# @param [#to_s] product_name
|
150
|
+
# the name of the new static library.
|
151
|
+
#
|
152
|
+
# @param [String] sub_group_path (see #new_file)#
|
153
|
+
# @return [PBXFileReference] the new group.
|
154
|
+
#
|
155
|
+
def new_static_library(product_name, sub_group_path = nil)
|
156
|
+
file = new_file("lib#{product_name}.a", sub_group_path)
|
157
|
+
file.include_in_index = '0'
|
158
|
+
file.source_tree = 'BUILT_PRODUCTS_DIR'
|
159
|
+
file.explicit_file_type = file.last_known_file_type
|
160
|
+
file.last_known_file_type = nil
|
161
|
+
file
|
162
|
+
end
|
163
|
+
|
164
|
+
# Creates a new group to represent a `xcdatamodel` file.
|
165
|
+
#
|
166
|
+
# @return [XCVersionGroup] The new group.
|
167
|
+
#
|
168
|
+
def new_xcdatamodel_group(xcdatamodel_path)
|
169
|
+
g = @project.new(XCVersionGroup)
|
170
|
+
g.path = xcdatamodel_path
|
171
|
+
g.version_group_type = 'wrapper.xcdatamodel'
|
172
|
+
file = g.new_file(xcdatamodel_path.sub(/xcdatamodeld$/, 'xcdatamodel'))
|
173
|
+
g.current_version = file
|
174
|
+
g
|
175
|
+
end
|
176
|
+
|
177
|
+
# Traverses the children groups and finds the group with the given
|
178
|
+
# path, optionally, creating any needed group.
|
179
|
+
#
|
180
|
+
# @param path (see #find_subpath)
|
181
|
+
#
|
182
|
+
# @note (see #find_subpath)
|
183
|
+
#
|
184
|
+
def [](path)
|
185
|
+
find_subpath(path)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Traverses the children groups and finds the children with the given
|
189
|
+
# path, optionally, creating any needed group. If the given path is
|
190
|
+
# `nil` it returns itself.
|
191
|
+
#
|
192
|
+
# @param [String] path
|
193
|
+
# a string with the names of the groups separated by a '`/`'.
|
194
|
+
#
|
195
|
+
# @param [Boolean] should_create
|
196
|
+
# whether the path should be created.
|
197
|
+
#
|
198
|
+
# @note The path is matched against the {#display_name} of the groups.
|
199
|
+
#
|
200
|
+
# @example
|
201
|
+
# g = main_group['Frameworks']
|
202
|
+
# g.name #=> 'Frameworks'
|
203
|
+
#
|
204
|
+
# @return [PBXGroup] the group if found.
|
205
|
+
#
|
206
|
+
def find_subpath(path, should_create = false)
|
207
|
+
return self unless path
|
208
|
+
path = path.split('/') unless path.is_a?(Array)
|
209
|
+
child_name = path.shift
|
210
|
+
child = children.find{ |c| c.display_name == child_name }
|
211
|
+
child = new_group(child_name) if child.nil? && should_create
|
212
|
+
if path.empty?
|
213
|
+
child
|
214
|
+
else
|
215
|
+
child.find_subpath(path, should_create)
|
216
|
+
end
|
97
217
|
end
|
98
218
|
|
219
|
+
# Adds an object to the group.
|
220
|
+
#
|
221
|
+
# @return [ObjectList<AbstractObject>] the children list.
|
222
|
+
#
|
99
223
|
def <<(child)
|
100
224
|
children << child
|
101
225
|
end
|
102
|
-
end
|
103
226
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
227
|
+
# Sorts the children of the group by type and then by name.
|
228
|
+
#
|
229
|
+
# @return [void]
|
230
|
+
#
|
231
|
+
def sort_by_type
|
232
|
+
children.sort do |x, y|
|
233
|
+
if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)
|
234
|
+
-1
|
235
|
+
elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)
|
236
|
+
1
|
237
|
+
elsif x.respond_to?(:name) && y.respond_to?(:name)
|
238
|
+
x.name <=> y.name
|
239
|
+
else
|
240
|
+
0
|
241
|
+
end
|
242
|
+
end
|
118
243
|
end
|
119
|
-
end
|
120
|
-
|
244
|
+
end # PBXGroup
|
121
245
|
end
|
122
246
|
end
|
123
247
|
end
|
@@ -2,160 +2,217 @@ module Xcodeproj
|
|
2
2
|
class Project
|
3
3
|
module Object
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# Represents a target.
|
6
|
+
#
|
7
|
+
class PBXNativeTarget < AbstractObject
|
7
8
|
|
8
|
-
# [String]
|
9
|
-
|
10
|
-
|
11
|
-
# [String] the build product type identifier
|
12
|
-
attribute :product_type
|
13
|
-
|
14
|
-
has_many :build_phases
|
15
|
-
has_many :dependencies # TODO :class => ?
|
16
|
-
has_many :build_rules # TODO :class => ?
|
17
|
-
has_one :build_configuration_list, :class => XCConfigurationList
|
18
|
-
has_one :product, :uuid => :product_reference
|
19
|
-
|
20
|
-
def self.new_static_library(project, platform, name)
|
21
|
-
project.add_system_framework(platform == :ios ? 'Foundation' : 'Cocoa')
|
22
|
-
|
23
|
-
target = new(project, nil, 'productType' => STATIC_LIBRARY, 'productName' => name)
|
24
|
-
target.product.path = "lib#{name}.a"
|
9
|
+
# @return [String] The name of the Target.
|
10
|
+
#
|
11
|
+
attribute :name, String
|
25
12
|
|
26
|
-
|
27
|
-
|
13
|
+
# @return [XCConfigurationList] the list of the build configurations of
|
14
|
+
# the target. This list commonly include two configurations `Debug`
|
15
|
+
# and `Release`.
|
16
|
+
#
|
17
|
+
has_one :build_configuration_list, XCConfigurationList
|
28
18
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
# @return [PBXBuildRule] the build phases of the target.
|
20
|
+
#
|
21
|
+
# @note Apparently only PBXCopyFilesBuildPhase and
|
22
|
+
# PBXShellScriptBuildPhase can appear multiple times in a target.
|
23
|
+
#
|
24
|
+
has_many :build_phases, AbstractBuildPhase
|
35
25
|
|
36
|
-
|
37
|
-
|
26
|
+
# @return [PBXBuildRule] the build rules of this target.
|
27
|
+
#
|
28
|
+
has_many :build_rules, PBXBuildRule
|
38
29
|
|
39
|
-
#
|
40
|
-
#
|
41
|
-
|
42
|
-
super
|
43
|
-
self.name ||= product_name
|
44
|
-
self.build_rule_references ||= []
|
45
|
-
self.dependency_references ||= []
|
30
|
+
# @return [PBXNativeTarget] the targets necessary to build this target.
|
31
|
+
#
|
32
|
+
has_many :dependencies, PBXTargetDependency
|
46
33
|
|
47
|
-
|
48
|
-
|
34
|
+
# @return [String] the name of the build product.
|
35
|
+
#
|
36
|
+
attribute :product_name, String
|
49
37
|
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
# @return [String] the build product type identifier.
|
39
|
+
#
|
40
|
+
attribute :product_type, String, 'com.apple.product-type.library.static'
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
42
|
+
# @return [PBXFileReference] the reference to the product file.
|
43
|
+
#
|
44
|
+
has_one :product_reference, PBXFileReference
|
59
45
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
'defaultConfigurationName' => 'Release',
|
64
|
-
})
|
65
|
-
# TODO or should this happen in buildConfigurationList?
|
66
|
-
build_configuration_list.build_configurations.new_debug
|
67
|
-
build_configuration_list.build_configurations.new_release
|
68
|
-
end
|
46
|
+
# @return [String] the install path of the product.
|
47
|
+
#
|
48
|
+
attribute :product_install_path, String
|
69
49
|
|
70
|
-
|
71
|
-
self.product = @project.files.new_static_library(product_name)
|
72
|
-
end
|
73
|
-
end
|
50
|
+
## CONVENIENCE METHODS #################################################
|
74
51
|
|
75
|
-
|
76
|
-
def product=(product)
|
77
|
-
self._product = product
|
78
|
-
@project.products << product
|
79
|
-
end
|
52
|
+
# @!group Convenience methods
|
80
53
|
|
54
|
+
# @return [ObjectList<XCBuildConfiguration>] the build
|
55
|
+
# configurations of the target.
|
56
|
+
#
|
81
57
|
def build_configurations
|
82
58
|
build_configuration_list.build_configurations
|
83
59
|
end
|
84
60
|
|
61
|
+
# @return [Hash] the build settings of the build configuration with the
|
62
|
+
# given name.
|
63
|
+
#
|
64
|
+
# @param [String] build_configuration_name
|
65
|
+
# the name of a build configuration.
|
66
|
+
#
|
85
67
|
def build_settings(build_configuration_name)
|
86
68
|
build_configuration_list.build_settings(build_configuration_name)
|
87
69
|
end
|
88
70
|
|
89
|
-
|
90
|
-
|
71
|
+
# Adds source files to the target.
|
72
|
+
#
|
73
|
+
# @param [Array<PBXFileReference>] file_references
|
74
|
+
# The files references of the source files that should be added to
|
75
|
+
# the target.
|
76
|
+
#
|
77
|
+
# @param [Hash{String=>String}] compiler_flags
|
78
|
+
# The compiler flags for the source files.
|
79
|
+
#
|
80
|
+
# @return [void]
|
81
|
+
#
|
82
|
+
def add_file_references(file_references, compiler_flags = {})
|
83
|
+
file_references.each do |file|
|
84
|
+
build_file = project.new(PBXBuildFile)
|
85
|
+
build_file.file_ref = file
|
86
|
+
|
87
|
+
extension = File.extname(file.path)
|
88
|
+
header_extensions = Constants::HEADER_FILES_EXTENSIONS
|
89
|
+
if (header_extensions.include?(extension))
|
90
|
+
build_file.settings = { 'ATTRIBUTES' => ["Public"] }
|
91
|
+
phase = headers_build_phase
|
92
|
+
phase.files << build_file
|
93
|
+
else
|
94
|
+
build_file.settings = { 'COMPILER_FLAGS' => compiler_flags } if compiler_flags && !compiler_flags.empty?
|
95
|
+
source_build_phase.files << build_file
|
96
|
+
end
|
97
|
+
end
|
91
98
|
end
|
92
99
|
|
93
|
-
def copy_files_build_phases
|
94
|
-
build_phases.list_by_class(PBXCopyFilesBuildPhase)
|
95
|
-
end
|
96
100
|
|
97
|
-
|
98
|
-
|
101
|
+
# @!group Accessing build phases
|
102
|
+
|
103
|
+
# Finds or creates the headers build phase of the target.
|
104
|
+
#
|
105
|
+
# @note A target should have only one headers build phase.
|
106
|
+
#
|
107
|
+
# @return [PBXHeadersBuildPhase] the headers build phase.
|
108
|
+
#
|
109
|
+
def headers_build_phase
|
110
|
+
unless @headers_build_phase
|
111
|
+
headers_build_phase = build_phases.find { |bp| bp.class == PBXHeadersBuildPhase }
|
112
|
+
unless headers_build_phase
|
113
|
+
# Working around a bug in Xcode 4.2 betas, remove this once the
|
114
|
+
# Xcode bug is fixed:
|
115
|
+
# https://github.com/alloy/cocoapods/issues/13
|
116
|
+
# phase = copy_header_phase || headers_build_phases.first
|
117
|
+
headers_build_phase = project.new(PBXHeadersBuildPhase)
|
118
|
+
build_phases << headers_build_phase
|
119
|
+
end
|
120
|
+
@headers_build_phase = headers_build_phase
|
121
|
+
end
|
122
|
+
@headers_build_phase
|
99
123
|
end
|
100
124
|
|
101
|
-
|
102
|
-
|
125
|
+
# Finds or creates the source build phase of the target.
|
126
|
+
#
|
127
|
+
# @note A target should have only one source build phase.
|
128
|
+
#
|
129
|
+
# @return [PBXSourcesBuildPhase] the source build phase.
|
130
|
+
#
|
131
|
+
def source_build_phase
|
132
|
+
unless @source_build_phase
|
133
|
+
source_build_phase = build_phases.find { |bp| bp.class == PBXSourcesBuildPhase }
|
134
|
+
unless source_build_phase
|
135
|
+
source_build_phase = project.new(PBXSourcesBuildPhase)
|
136
|
+
build_phases << source_build_phase
|
137
|
+
end
|
138
|
+
@source_build_phase = source_build_phase
|
139
|
+
end
|
140
|
+
@source_build_phase
|
103
141
|
end
|
104
142
|
|
105
|
-
|
106
|
-
|
143
|
+
# Finds or creates the frameworks build phase of the target.
|
144
|
+
#
|
145
|
+
# @note A target should have only one frameworks build phase.
|
146
|
+
#
|
147
|
+
# @return [PBXFrameworksBuildPhase] the frameworks build phase.
|
148
|
+
#
|
149
|
+
def frameworks_build_phase
|
150
|
+
bp = build_phases.find { |bp| bp.class == PBXFrameworksBuildPhase }
|
151
|
+
unless bp
|
152
|
+
bp = project.new(PBXFrameworksBuildPhase)
|
153
|
+
build_phases << bp
|
154
|
+
end
|
155
|
+
bp
|
107
156
|
end
|
108
157
|
|
109
|
-
#
|
158
|
+
# Finds or creates the resources build phase of the target.
|
110
159
|
#
|
111
|
-
# @note
|
112
|
-
# It finds an existing file reference or creates a new one.
|
160
|
+
# @note A target should have only one resources build phase.
|
113
161
|
#
|
114
|
-
# @
|
115
|
-
# description of the source files to add.
|
162
|
+
# @return [PBXResourcesBuildPhase] the resources build phase.
|
116
163
|
#
|
117
|
-
|
164
|
+
def resources_build_phase
|
165
|
+
bp = build_phases.find { |bp| bp.class == PBXResourcesBuildPhase }
|
166
|
+
unless bp
|
167
|
+
bp = project.new(PBXResourcesBuildPhase)
|
168
|
+
build_phases << bp
|
169
|
+
end
|
170
|
+
bp
|
171
|
+
end
|
172
|
+
|
173
|
+
# @return [Array<PBXCopyFilesBuildPhase>]
|
174
|
+
# the copy files build phases of the target.
|
118
175
|
#
|
119
|
-
def
|
120
|
-
|
121
|
-
|
122
|
-
new_files = []
|
123
|
-
source_file_descriptions.each do |source_file_description|
|
124
|
-
path = source_file_description.path
|
125
|
-
copy_header_phase = source_file_description.copy_header_phase
|
126
|
-
compiler_flags = source_file_description.compiler_flags
|
176
|
+
def copy_files_build_phases
|
177
|
+
build_phases.select { |bp| bp.class == PBXCopyFilesBuildPhase }
|
178
|
+
end
|
127
179
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
# https://github.com/alloy/cocoapods/issues/13
|
134
|
-
#phase = copy_header_phase || headers_build_phases.first
|
135
|
-
phase = copy_header_phase || copy_files_build_phases.first
|
136
|
-
phase.build_files << build_file
|
137
|
-
else
|
138
|
-
build_file.settings = { 'COMPILER_FLAGS' => compiler_flags } if compiler_flags && !compiler_flags.empty?
|
139
|
-
source_build_phases.first.build_files << build_file
|
140
|
-
end
|
141
|
-
new_files << file
|
142
|
-
end
|
143
|
-
new_files
|
180
|
+
# @return [Array<PBXShellScriptBuildPhase>]
|
181
|
+
# the copy files build phases of the target.
|
182
|
+
#
|
183
|
+
def shell_script_build_phases
|
184
|
+
build_phases.select { |bp| bp.class == PBXShellScriptBuildPhase }
|
144
185
|
end
|
145
186
|
|
146
|
-
|
147
|
-
#
|
187
|
+
|
188
|
+
# @!group Creating build phases
|
189
|
+
|
190
|
+
# Creates a new copy files build phase.
|
148
191
|
#
|
149
|
-
#
|
150
|
-
#
|
192
|
+
# @param [String] name
|
193
|
+
# an optional name for the pahse.
|
151
194
|
#
|
152
|
-
#
|
153
|
-
# @return [String] Any compiler flag.
|
195
|
+
# @return [PBXCopyFilesBuildPhase] the new phase.
|
154
196
|
#
|
155
|
-
|
156
|
-
|
197
|
+
def new_copy_files_build_phase(name = nil)
|
198
|
+
phase = project.new(PBXCopyFilesBuildPhase)
|
199
|
+
phase.name = name
|
200
|
+
build_phases << phase
|
201
|
+
phase
|
202
|
+
end
|
203
|
+
|
204
|
+
# Creates a new shell script build phase.
|
205
|
+
#
|
206
|
+
# @param (see #new_copy_files_build_phase)
|
157
207
|
#
|
158
|
-
|
208
|
+
# @return [PBXShellScriptBuildPhase] the new phase.
|
209
|
+
#
|
210
|
+
def new_shell_script_build_phase(name = nil)
|
211
|
+
phase = project.new(PBXShellScriptBuildPhase)
|
212
|
+
phase.name = name
|
213
|
+
build_phases << phase
|
214
|
+
phase
|
215
|
+
end
|
159
216
|
end
|
160
217
|
end
|
161
218
|
end
|