phoenx 0.3.2 → 0.3.3

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.
@@ -1,18 +1,13 @@
1
1
  module Phoenx
2
2
 
3
3
  class Scheme
4
-
5
4
  attr_accessor :name
6
-
7
5
  attr_accessor :archive_configuration
8
6
  attr_accessor :launch_configuration
9
7
 
10
8
  def initialize(name, block)
11
-
12
9
  @name = name
13
-
14
10
  self.instance_eval(&block)
15
-
16
11
  end
17
12
 
18
13
  end
@@ -1,7 +1,6 @@
1
1
  module Phoenx
2
2
 
3
3
  class AbstractTarget
4
-
5
4
  attr_accessor :name
6
5
  attr_accessor :resources
7
6
  attr_accessor :excluded_resources
@@ -16,11 +15,9 @@ module Phoenx
16
15
  attr_accessor :support_files
17
16
  attr_accessor :excluded_support_files
18
17
  attr_reader :dependencies
19
-
20
18
  attr_reader :config_files
21
19
 
22
20
  def initialize
23
-
24
21
  @dependencies = []
25
22
  @config_files = {}
26
23
  @frameworks = []
@@ -35,23 +32,18 @@ module Phoenx
35
32
  @excluded_sources = []
36
33
  @support_files = []
37
34
  @excluded_support_files = []
38
-
39
35
  end
40
36
 
41
37
  def dependency(target_name, embed = true, path = nil)
42
-
43
38
  dependencies << Dependency.new(target_name, embed, path)
44
-
45
39
  end
46
40
 
47
41
  end
48
42
 
49
43
  class TestableTarget < AbstractTarget
50
-
51
44
  attr_reader :test_targets
52
45
  attr_reader :schemes
53
46
  attr_accessor :version
54
-
55
47
  attr_accessor :platform
56
48
  attr_reader :target_type
57
49
  attr_accessor :sub_projects
@@ -67,7 +59,6 @@ module Phoenx
67
59
  public
68
60
 
69
61
  def initialize(name, type, platform, version)
70
-
71
62
  super()
72
63
  @test_targets = []
73
64
  @schemes = []
@@ -82,24 +73,17 @@ module Phoenx
82
73
  @excluded_project_headers = []
83
74
  @public_headers = []
84
75
  @excluded_public_headers = []
85
-
86
76
  yield(self)
87
-
88
77
  end
89
78
 
90
79
  def test_target(name, &block)
91
-
92
80
  target = Phoenx::TestTarget.new &block
93
81
  target.name = name
94
-
95
82
  @test_targets << target
96
-
97
83
  end
98
84
 
99
85
  def scheme(name, &block)
100
-
101
86
  @schemes << Phoenx::Scheme.new(name, block)
102
-
103
87
  end
104
88
 
105
89
  end
@@ -109,11 +93,8 @@ module Phoenx
109
93
  public
110
94
 
111
95
  def initialize
112
-
113
96
  super
114
-
115
97
  yield(self)
116
-
117
98
  end
118
99
 
119
100
  end
@@ -1,32 +1,29 @@
1
1
  module Phoenx
2
2
 
3
3
  class Workspace
4
-
5
4
  attr_accessor :name
6
5
  attr_reader :main_project_name
7
6
  attr_reader :main_project_path
8
7
  attr_reader :projects
8
+ attr_reader :generated_projects
9
9
 
10
10
  def initialize
11
-
12
11
  @main_project = {}
13
12
  @projects = {}
14
-
13
+ @generated_projects = {}
15
14
  yield(self)
16
-
17
15
  end
18
16
 
19
- def project(name, path = nil)
20
-
17
+ def project(name, path = nil, generate = true)
21
18
  @projects[name] = path
22
-
19
+ if generate
20
+ @generated_projects[name] = path
21
+ end
23
22
  end
24
23
 
25
24
  def main_project(name, path = nil)
26
-
27
25
  @main_project_name = name
28
26
  @main_project_path = path
29
-
30
27
  end
31
28
 
32
29
  end
@@ -1,5 +1,5 @@
1
1
  module Phoenx
2
2
 
3
- VERSION = "0.3.2".freeze unless defined? Phoenx::VERSION
3
+ VERSION = "0.3.3".freeze unless defined? Phoenx::VERSION
4
4
 
5
5
  end
@@ -5,58 +5,38 @@ module Phoenx
5
5
  :project
6
6
 
7
7
  def initialize(project)
8
-
9
8
  @project = project
10
-
11
9
  end
12
10
 
13
11
  def extract_target_settings
14
-
15
12
  @project.targets.each do |target|
16
-
17
13
  FileUtils::mkdir_p 'xcconfig/' + target.name
18
-
19
14
  target.build_configuration_list.build_configurations.each do |config|
20
-
21
15
  extract_settings(config, 'xcconfig/' + target.name + '/')
22
-
23
16
  end
24
-
25
17
  end
26
-
27
18
  end
28
19
 
29
20
  def extract_project_settings
30
-
31
21
  FileUtils::mkdir_p 'xcconfig'
32
-
33
22
  @project.build_configuration_list.build_configurations.each do |config|
34
-
35
23
  extract_settings(config, 'xcconfig/')
36
-
37
24
  end
38
-
39
25
  end
40
26
 
41
27
  def extract_settings(config, to_folder)
42
-
43
28
  build_settings = config.build_settings.map { |key,values|
44
29
  key + ' = ' + (values.is_a?(String) ? values : values.join(' '))
45
30
  }
46
-
47
31
  build_settings.sort!
48
-
49
32
  open(to_folder + config.name + '.xcconfig', 'w') { |file|
50
33
  build_settings.each { |setting| file.puts(setting) }
51
34
  }
52
-
53
35
  end
54
36
 
55
37
  def extract
56
-
57
38
  self.extract_target_settings
58
39
  self.extract_project_settings
59
-
60
40
  end
61
41
 
62
42
  end
@@ -6,115 +6,71 @@ module Phoenx
6
6
  :project
7
7
 
8
8
  def initialize(project_spec)
9
-
10
9
  @project_spec = project_spec
11
-
12
10
  end
13
11
 
14
12
  def build
15
-
16
13
  @project_spec.pre_install_scripts.each do |pre_script|
17
-
18
14
  abort "Missing pre install script ".red + pre_script.bold unless File.exists?(pre_script)
19
15
  puts `./#{pre_script}`
20
-
21
16
  end
22
-
23
17
  # Build Project
24
-
25
18
  @project = Xcodeproj::Project::new(@project_spec.project_file_name)
26
-
27
19
  self.generate_configurations
28
20
  self.add_config_files
29
21
  self.add_support_files
30
22
  self.build_targets
31
-
32
23
  @project.main_group.sort_recursively
33
-
34
24
  if @project_spec.deterministic_project
35
25
  @project.predictabilize_uuids
36
26
  end
37
-
38
27
  @project.save(@project_spec.project_file_name)
39
-
40
28
  @project_spec.post_install_scripts.each do |post_script|
41
-
42
29
  abort "Missing post install script ".red + post_script.bold unless File.exists?(post_script)
43
30
  puts `./#{post_script}`
44
-
45
31
  end
46
-
47
32
  end
48
33
 
49
34
  def build_targets
50
-
51
35
  @project_spec.targets.each do |target|
52
-
53
36
  if target.target_type == :application
54
-
55
37
  builder = ApplicationTargetBuilder.new @project, target, @project_spec
56
38
  builder.build
57
-
58
39
  elsif target.target_type == :framework
59
-
60
40
  builder = FrameworkTargetBuilder.new @project, target, @project_spec
61
41
  builder.build
62
-
63
42
  end
64
-
65
43
  end
66
-
67
44
  end
68
45
 
69
46
  def generate_configurations
70
-
71
47
  @project_spec.configurations.each do |config|
72
-
73
48
  @project.add_build_configuration(config.name, config.parent)
74
-
75
49
  end
76
-
77
50
  end
78
51
 
79
52
  def add_config_files
80
-
81
53
  Phoenx::add_groups_for_files(@project,@project_spec.config_files.values)
82
-
83
54
  @project_spec.config_files.keys.each do |config|
84
-
85
55
  file_name = @project_spec.config_files[config]
86
-
87
56
  unless file_name == nil
88
-
89
57
  g = @project.main_group.find_subpath(File.dirname(file_name), false)
90
-
91
58
  file = g.find_file_by_path(File.basename(file_name))
92
-
93
59
  unless file != nil
94
-
95
60
  file = g.new_reference(File.basename(file_name))
96
-
97
61
  end
98
-
99
62
  configuration = @project.build_configuration_list[config]
100
-
101
63
  unless configuration
102
64
  abort "Config file assigned to invalid configuration '#{config}'' ".red + file_name.bold
103
65
  end
104
-
105
66
  configuration.base_configuration_reference = file
106
-
107
67
  end
108
-
109
68
  end
110
-
111
69
  end
112
70
 
113
71
  def add_support_files
114
-
115
72
  files = Phoenx.merge_files_array(@project_spec.support_files, @project_spec.excluded_support_files)
116
73
  Phoenx.get_or_add_files(@project, files)
117
-
118
74
  end
119
75
 
120
76
  end
@@ -9,272 +9,165 @@ module Phoenx
9
9
  attr_reader :framework_files
10
10
 
11
11
  def initialize(project, target_spec, project_spec)
12
-
13
12
  @project = project
14
13
  @target_spec = target_spec
15
14
  @project_spec = project_spec
16
15
  @framework_files = []
17
-
18
16
  end
19
17
 
20
18
  def add_support_files
21
-
22
19
  files = Phoenx.merge_files_array(@target_spec.support_files, @target_spec.excluded_support_files)
23
20
  Phoenx.get_or_add_files(@project, files)
24
-
25
21
  end
26
22
 
27
23
  def add_frameworks_and_libraries
28
-
29
24
  # Add Framework dependencies
30
-
31
25
  frameworks_group = @project.main_group.find_subpath(FRAMEWORKS_ROOT, true)
32
26
  Phoenx.add_groups_for_files(@project,@target_spec.frameworks)
33
-
34
27
  frameworks = Phoenx.merge_files_array(@target_spec.frameworks)
35
-
36
28
  frameworks.each do |framework|
37
-
38
29
  file = Phoenx.get_or_add_file(@project,framework)
39
30
  @framework_files << file
40
-
41
31
  self.target.frameworks_build_phases.add_file_reference(file)
42
-
43
32
  end
44
-
45
33
  Phoenx.add_groups_for_files(@project, @target_spec.libraries)
46
34
  libraries = Phoenx.merge_files_array(@target_spec.libraries)
47
-
48
35
  libraries.each do |framework|
49
-
50
36
  file = Phoenx.get_or_add_file(@project,framework)
51
37
  self.target.frameworks_build_phases.add_file_reference(file)
52
-
53
38
  end
54
-
55
39
  end
56
40
 
57
41
  def add_build_phase_scripts
58
-
59
42
  @target_spec.pre_build_scripts.each do |script|
60
-
61
43
  phase = self.target.new_shell_script_build_phase(script[:name])
62
44
  phase.shell_script = script[:script]
63
-
64
45
  self.target.build_phases.move(phase, 0)
65
-
66
46
  end
67
-
68
47
  @target_spec.post_build_scripts.each do |script|
69
-
70
48
  phase = self.target.new_shell_script_build_phase(script[:name])
71
49
  phase.shell_script = script[:script]
72
-
73
50
  self.target.build_phases.move(phase, self.target.build_phases.count - 1)
74
-
75
51
  end
76
-
77
52
  end
78
53
 
79
54
  def add_system_dependencies
80
-
81
55
  # Add Framework dependencies
82
-
83
56
  @target_spec.system_frameworks.each do |framework|
84
-
85
57
  self.target.add_system_framework(framework)
86
-
87
58
  end
88
-
89
59
  @target_spec.system_libraries.each do |library|
90
-
91
60
  self.target.add_system_library(library)
92
-
93
61
  end
94
-
95
62
  end
96
63
 
97
64
  def add_resources
98
-
99
65
  # Add Resource files
100
66
  resources = Phoenx.merge_files_array(@target_spec.resources, @target_spec.excluded_resources)
101
-
102
67
  unless !@target_spec.resources || @target_spec.resources.empty? || !resources.empty?
103
68
  puts "No resources found".yellow
104
69
  end
105
-
106
70
  Phoenx.add_groups_for_files(@project, resources)
107
-
108
71
  resources.each do |source|
109
-
110
72
  file = nil
111
-
112
73
  if Phoenx.is_bundle?(source)
113
-
114
74
  parts = source.split("/")
115
-
116
75
  group = @project.main_group
117
-
118
76
  parts.each do |part|
119
-
120
77
  if Phoenx.is_bundle?(part)
121
-
122
78
  file = group.find_file_by_path(part)
123
-
124
79
  unless file != nil
125
-
126
80
  file = group.new_file(part)
127
81
  self.target.resources_build_phase.add_file_reference(file)
128
-
129
82
  end
130
-
131
83
  break
132
-
133
84
  else
134
-
135
85
  group = group.find_subpath(part, false)
136
-
137
86
  end
138
-
139
87
  end
140
-
141
88
  elsif Phoenx.is_translation_folder?(source)
142
-
143
89
  parts = source.split("/")
144
90
  translation_folder_index = parts.index { |part| Phoenx.is_translation_folder?(part) }
145
-
146
91
  parent_path = parts[0..translation_folder_index - 1].join('/')
147
92
  parent_group = @project.main_group.find_subpath(parent_path)
148
-
149
93
  variant_group = parent_group[File.basename(source)]
150
94
  if variant_group == nil
151
95
  variant_group = parent_group.new_variant_group(File.basename(source))
152
96
  self.target.resources_build_phase.add_file_reference(variant_group)
153
97
  end
154
-
155
98
  variant_group.new_file(parts[translation_folder_index..parts.count].join('/'))
156
-
157
99
  else
158
-
159
100
  group = @project.main_group.find_subpath(File.dirname(source), false)
160
-
161
101
  unless group == nil
162
-
163
102
  file = group.find_file_by_path(File.basename(source))
164
-
165
103
  unless file != nil
166
-
167
104
  file = group.new_file(File.basename(source))
168
105
  self.target.resources_build_phase.add_file_reference(file)
169
-
170
106
  end
171
-
172
107
  end
173
-
174
-
175
108
  end
176
-
177
109
  end
178
-
179
110
  end
180
111
 
181
112
  def add_sources
182
-
183
113
  # Add Source files
184
114
  sources = Phoenx.merge_files_array(@target_spec.sources, @target_spec.excluded_sources)
185
-
186
115
  unless !@target_spec.sources || @target_spec.sources.empty? || !sources.empty?
187
116
  puts "No sources found".yellow
188
117
  end
189
-
190
118
  Phoenx.add_groups_for_files(@project, sources)
191
-
192
119
  sources.each do |source|
193
-
194
120
  file = Phoenx.get_or_add_file(@project,source)
195
-
196
121
  # Add to Compile sources phase
197
-
198
122
  unless File.extname(source) == ".h" || File.extname(source) == ".pch"
199
-
200
123
  self.target.add_file_references([file])
201
-
202
124
  end
203
-
204
125
  end
205
-
206
126
  end
207
127
 
208
128
  def add_headers(header_files, excluded_header_files, attributes)
209
-
210
129
  headers = Phoenx.merge_files_array(header_files, excluded_header_files)
211
-
212
130
  unless !header_files || header_files.empty? || !headers.empty?
213
131
  puts "No #{attributes["ATTRIBUTES"].first} headers found".yellow
214
132
  end
215
-
216
133
  Phoenx.add_groups_for_files(@project, headers)
217
-
218
134
  headers.each do |header|
219
-
220
135
  file = Phoenx.get_or_add_file(@project,header)
221
-
222
136
  build_file = self.target.headers_build_phase.add_file_reference(file, true)
223
137
  build_file.settings = attributes
224
-
225
138
  end
226
-
227
139
  end
228
140
 
229
141
  def add_public_headers
230
-
231
142
  self.add_headers(@target_spec.public_headers, @target_spec.excluded_public_headers, ATTRIBUTES_PUBLIC_HEADERS)
232
-
233
143
  end
234
144
 
235
145
  def add_private_headers
236
-
237
146
  self.add_headers(@target_spec.private_headers, @target_spec.excluded_private_headers, ATTRIBUTES_PRIVATE_HEADERS)
238
-
239
147
  end
240
148
 
241
149
  def add_project_headers
242
-
243
150
  self.add_headers(@target_spec.project_headers, @target_spec.excluded_project_headers, ATTRIBUTES_PROJECT_HEADERS)
244
-
245
151
  end
246
152
 
247
153
  def add_config_files
248
-
249
154
  # Add configuration group
250
-
251
155
  Phoenx.add_groups_for_files(@project, @target_spec.config_files.values)
252
-
253
156
  @target_spec.config_files.each do |config,file_name|
254
-
255
157
  unless file_name == nil
256
-
257
158
  file = Phoenx.get_or_add_file(@project,file_name)
258
-
259
159
  configuration = self.target.build_configuration_list[config]
260
-
261
160
  unless configuration
262
161
  abort "Config file assigned to invalid configuration '#{config}' ".red + file_name.bold
263
162
  end
264
-
265
163
  configuration.base_configuration_reference = file
266
-
267
164
  end
268
-
269
165
  end
270
-
271
166
  end
272
167
 
273
168
  def configure_target
274
-
275
169
  Phoenx.set_target_build_settings_defaults(self.target)
276
170
  Phoenx.set_project_build_settings_defaults(@project)
277
-
278
171
  end
279
172
 
280
173
  def build
@@ -282,9 +175,7 @@ module Phoenx
282
175
  end
283
176
 
284
177
  def target
285
-
286
178
  return nil
287
-
288
179
  end
289
180
 
290
181
  end
@@ -294,112 +185,71 @@ module Phoenx
294
185
  :test_target
295
186
 
296
187
  def generate_target_scheme
297
-
298
188
  # Generate main scheme
299
-
300
189
  scheme = Xcodeproj::XCScheme.new
301
190
  scheme.configure_with_targets(self.target, @test_target)
302
191
  scheme.test_action.code_coverage_enabled = true
303
192
  scheme.add_build_target(self.target, true)
304
-
305
193
  scheme.save_as(@project_spec.project_file_name, @target_spec.name, false)
306
-
307
194
  end
308
195
 
309
196
  def sort_build_phases
310
-
311
197
  self.target.build_phases.objects.each do |phase|
312
-
313
198
  phase.sort
314
-
315
199
  end
316
-
317
200
  end
318
201
 
319
202
  def add_sub_projects
320
-
321
203
  frameworks_group = @project.main_group.find_subpath(FRAMEWORKS_ROOT,false)
322
-
323
204
  @target_spec.dependencies.each do |dp|
324
-
325
205
  proj = nil
326
-
327
206
  if dp.path == nil
328
-
329
207
  proj = @project
330
208
  else
331
-
332
209
  abort "Missing dependency ".red + dp.path.bold unless File.exists?(dp.path)
333
-
334
210
  file_ref = frameworks_group.find_file_by_path(dp.path)
335
-
336
211
  unless file_ref != nil
337
-
338
212
  frameworks_group.new_file(dp.path)
339
-
340
213
  end
341
-
342
214
  proj = Xcodeproj::Project::open(dp.path)
343
-
344
215
  end
345
-
346
216
  target = Phoenx.target_for_name(proj,dp.target_name)
347
-
348
217
  abort "Missing target for dependency '#{dp.path}' ".red + dp.target_name.bold unless target
349
-
350
218
  self.target.add_dependency(target)
351
-
352
219
  end
353
-
354
220
  end
355
221
 
356
222
  def add_schemes
357
-
358
223
  @target_spec.schemes.each do |s|
359
-
360
224
  scheme = Xcodeproj::XCScheme.new
361
225
  scheme.configure_with_targets(self.target, @test_target)
362
226
  scheme.test_action.code_coverage_enabled = true
363
227
  scheme.add_build_target(self.target, true)
364
228
  scheme.add_test_target(@test_target)
365
-
366
229
  archive_configuration = self.target.build_configuration_list[s.archive_configuration]
367
230
  unless archive_configuration
368
231
  abort "Invalid archive configuration assigned for scheme '#{s.name}' ".red + s.archive_configuration.bold
369
232
  end
370
-
371
233
  launch_configuration = self.target.build_configuration_list[s.launch_configuration]
372
234
  unless launch_configuration
373
235
  abort "Invalid launch configuration assigned for scheme '#{s.name}' ".red + s.launch_configuration.bold
374
236
  end
375
-
376
237
  scheme.archive_action.build_configuration = archive_configuration
377
238
  scheme.launch_action.build_configuration = launch_configuration
378
-
379
239
  scheme.save_as(@project_spec.project_file_name, s.name, false)
380
-
381
240
  end
382
-
383
241
  end
384
242
 
385
243
  def add_test_targets
386
-
387
244
  @target_spec.test_targets.each do |test_target_spec|
388
-
389
245
  builder = TestTargetBuilder.new(@target, @project, test_target_spec, @project_spec, @target_spec, self.framework_files)
390
246
  builder.build
391
-
392
247
  @test_target = builder.target
393
-
394
248
  end
395
-
396
249
  end
397
250
 
398
251
  def build
399
-
400
-
401
252
  puts ">> Target ".green + @target_spec.name.bold unless @project_spec.targets.length == 1
402
-
403
253
  self.add_sources
404
254
  Phoenx::Target::HeaderBuilder.new(@project, @target, @target_spec).build
405
255
  self.add_resources
@@ -408,192 +258,132 @@ module Phoenx
408
258
  self.add_system_dependencies
409
259
  self.add_frameworks_and_libraries
410
260
  self.add_build_phase_scripts
411
-
412
261
  self.add_test_targets
413
262
  self.generate_target_scheme
414
263
  self.add_schemes
415
264
  self.add_support_files
416
265
  self.sort_build_phases
417
266
  self.configure_target
418
-
419
267
  end
420
268
 
421
269
  end
422
270
 
423
271
  class ApplicationTargetBuilder < TestableTargetBuilder
424
-
425
272
  :target
426
273
  :copy_frameworks
427
274
 
428
275
  def add_sub_projects
429
-
430
276
  super
431
-
432
277
  frameworks_group = @project.main_group.find_subpath(FRAMEWORKS_ROOT,false)
433
-
434
278
  @target_spec.dependencies.each do |dp|
435
-
436
279
  file = nil
437
-
438
280
  if dp.embed == false
439
-
440
281
  next
441
-
442
282
  end
443
-
444
283
  if dp.path == nil
445
-
446
284
  # Copy internal references
447
-
448
285
  target = Phoenx.target_for_name(@project,dp.target_name)
449
-
450
286
  build_file = @copy_frameworks.add_file_reference(target.product_reference)
451
287
  build_file.settings = ATTRIBUTES_CODE_SIGN_ON_COPY
452
-
453
288
  else
454
-
455
289
  # Copy external products
456
-
457
290
  proj_file = frameworks_group.find_file_by_path(dp.path)
458
291
  proj = Xcodeproj::Project::open(dp.path)
459
-
460
292
  target = Phoenx.target_for_name(proj,dp.target_name)
461
-
462
293
  proj_file.file_reference_proxies.each do |e|
463
-
464
294
  if e.remote_ref.remote_global_id_string == target.product_reference.uuid
465
-
466
295
  build_file = @copy_frameworks.add_file_reference(e)
467
296
  build_file.settings = ATTRIBUTES_CODE_SIGN_ON_COPY
468
-
469
297
  end
470
-
471
298
  end
472
-
473
299
  end
474
-
475
-
476
-
477
300
  end
478
-
479
301
  end
480
302
 
481
303
  def build
482
-
483
304
  @target = @project.new_target(@target_spec.target_type, @target_spec.name, @target_spec.platform, @target_spec.version)
484
305
  @copy_frameworks = @target.new_copy_files_build_phase "Embed Frameworks"
485
306
  @copy_frameworks.symbol_dst_subfolder_spec = :frameworks
486
-
487
307
  super()
488
-
489
308
  self.framework_files.each do |file|
490
-
491
309
  build_file = @copy_frameworks.add_file_reference(file)
492
310
  build_file.settings = ATTRIBUTES_CODE_SIGN_ON_COPY
493
-
494
311
  end
495
312
  end
496
313
 
497
314
  def target
498
-
499
315
  return @target
500
-
501
316
  end
502
317
 
503
318
  end
504
319
 
505
320
  class FrameworkTargetBuilder < TestableTargetBuilder
506
-
507
321
  :target
508
322
 
509
323
  def build
510
-
511
324
  @target = @project.new_target(@target_spec.target_type, @target_spec.name, @target_spec.platform, @target_spec.version)
512
325
  super()
513
-
514
326
  end
515
327
 
516
328
  def target
517
-
518
329
  return @target
519
-
520
330
  end
521
331
 
522
332
  end
523
333
 
524
334
  class TestTargetBuilder < TargetBuilder
525
-
526
335
  :target
527
336
  :main_target
528
337
  :main_target_spec
529
338
  :main_target_frameworks_files
530
339
 
531
340
  def initialize(main_target, project, target_spec, project_spec, main_target_spec, main_target_frameworks_files)
532
-
533
341
  super(project, target_spec, project_spec)
534
342
  @main_target = main_target
535
343
  @main_target_spec = main_target_spec
536
344
  @main_target_frameworks_files = main_target_frameworks_files
537
-
538
345
  end
539
346
 
540
347
  def build
541
-
542
348
  @target = @project.new(Xcodeproj::Project::PBXNativeTarget)
543
349
  @project.targets << @target
544
350
  @target.name = @target_spec.name
545
351
  @target.product_name = @target_spec.name
546
352
  @target.product_type = Xcodeproj::Constants::PRODUCT_TYPE_UTI[:unit_test_bundle]
547
353
  @target.build_configuration_list = Xcodeproj::Project::ProjectHelper.configuration_list(@project, @main_target_spec.platform, @main_target_spec.version)
548
-
549
354
  product_ref = @project.products_group.new_reference(@target_spec.name + '.' + XCTEST_EXTENSION, :built_products)
550
355
  product_ref.include_in_index = '0'
551
356
  product_ref.set_explicit_file_type
552
357
  @target.product_reference = product_ref
553
-
554
358
  @target.build_phases << @project.new(Xcodeproj::Project::PBXSourcesBuildPhase)
555
359
  @target.build_phases << @project.new(Xcodeproj::Project::PBXFrameworksBuildPhase)
556
360
  @target.build_phases << @project.new(Xcodeproj::Project::PBXResourcesBuildPhase)
557
-
558
361
  self.add_sources
559
362
  self.add_config_files
560
363
  self.add_frameworks_and_libraries
561
364
  self.add_system_dependencies
562
-
563
365
  self.add_build_phase_scripts
564
366
  self.add_resources
565
367
  self.add_support_files
566
-
567
368
  copy_frameworks = @target.new_copy_files_build_phase "Embed Frameworks"
568
369
  copy_frameworks.symbol_dst_subfolder_spec = :frameworks
569
-
570
370
  frameworks_group = @project.main_group.find_subpath(FRAMEWORKS_ROOT, false)
571
-
572
371
  self.framework_files.each do |file|
573
-
574
372
  build_file = copy_frameworks.add_file_reference(file)
575
373
  build_file.settings = ATTRIBUTES_CODE_SIGN_ON_COPY
576
-
577
374
  end
578
-
579
375
  @main_target_frameworks_files.each do |file|
580
-
581
376
  build_file = copy_frameworks.add_file_reference(file)
582
377
  build_file.settings = ATTRIBUTES_CODE_SIGN_ON_COPY
583
-
584
378
  end
585
-
586
379
  # Add target dependency.
587
380
  @target.add_dependency(@main_target)
588
381
  @target.frameworks_build_phase.add_file_reference(@main_target.product_reference)
589
382
  self.configure_target
590
-
591
383
  end
592
384
 
593
385
  def target
594
-
595
386
  return @target
596
-
597
387
  end
598
388
 
599
389
  end