@@ -323,45 +323,54 @@ public class BuildPhaseTarget: Target
323
323
public let buildPhases : [ BuildPhase ]
324
324
325
325
/// The canonical sources build phase in the target, if there is one. There should only be one in a target; if there is more than one, then a warning will be emitted and the project might not build as expected.
326
- public private ( set ) var sourcesBuildPhase : SourcesBuildPhase ? = nil
326
+ public let sourcesBuildPhase : SourcesBuildPhase ?
327
327
/// The canonical frameworks build phase in the target, if there is one. There should only be one in a target; if there is more than one, then a warning will be emitted and the project might not build as expected.
328
- public private ( set ) var frameworksBuildPhase : FrameworksBuildPhase ? = nil
328
+ public let frameworksBuildPhase : FrameworksBuildPhase ?
329
329
/// The canonical headers build phase in the target, if there is one. There should only be one in a target; if there is more than one, then a warning will be emitted and the project might not build as expected.
330
- public private ( set ) var headersBuildPhase : HeadersBuildPhase ? = nil
330
+ public let headersBuildPhase : HeadersBuildPhase ?
331
331
/// The canonical resources build phase in the target, if there is one. There should only be one in a target; if there is more than one, then a warning will be emitted and the project might not build as expected.
332
- public private ( set ) var resourcesBuildPhase : ResourcesBuildPhase ? = nil
332
+ public let resourcesBuildPhase : ResourcesBuildPhase ?
333
333
334
334
init ( _ model: SWBProtocol . BuildPhaseTarget , _ pifLoader: PIFLoader , signature: String ) {
335
335
buildPhases = model. buildPhases. map { BuildPhase . create ( $0, pifLoader) }
336
- super. init ( model, pifLoader, signature: signature)
337
-
338
336
// Populate the convenience build phase properties.
337
+ var warnings : [ String ] = [ ]
338
+ var sourcesBuildPhase : SourcesBuildPhase ? = nil
339
+ var frameworksBuildPhase : FrameworksBuildPhase ? = nil
340
+ var headersBuildPhase : HeadersBuildPhase ? = nil
341
+ var resourcesBuildPhase : ResourcesBuildPhase ? = nil
339
342
for buildPhase in self . buildPhases {
340
343
switch buildPhase {
341
- case let sourcesBuildPhase as SourcesBuildPhase :
342
- if self . sourcesBuildPhase != nil {
344
+ case let sourcesPhase as SourcesBuildPhase :
345
+ if sourcesBuildPhase != nil {
343
346
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
344
347
}
345
- self . sourcesBuildPhase = sourcesBuildPhase
346
- case let frameworksBuildPhase as FrameworksBuildPhase :
347
- if self . frameworksBuildPhase != nil {
348
+ sourcesBuildPhase = sourcesPhase
349
+ case let frameworksPhase as FrameworksBuildPhase :
350
+ if frameworksBuildPhase != nil {
348
351
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
349
352
}
350
- self . frameworksBuildPhase = frameworksBuildPhase
351
- case let headersBuildPhase as HeadersBuildPhase :
352
- if self . headersBuildPhase != nil {
353
+ frameworksBuildPhase = frameworksPhase
354
+ case let headersPhase as HeadersBuildPhase :
355
+ if headersBuildPhase != nil {
353
356
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
354
357
}
355
- self . headersBuildPhase = headersBuildPhase
356
- case let resourcesBuildPhase as ResourcesBuildPhase :
357
- if self . resourcesBuildPhase != nil {
358
+ headersBuildPhase = headersPhase
359
+ case let resourcesPhase as ResourcesBuildPhase :
360
+ if resourcesBuildPhase != nil {
358
361
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
359
362
}
360
- self . resourcesBuildPhase = resourcesBuildPhase
363
+ resourcesBuildPhase = resourcesPhase
361
364
default :
362
365
break
363
366
}
364
367
}
368
+ self . sourcesBuildPhase = sourcesBuildPhase
369
+ self . frameworksBuildPhase = frameworksBuildPhase
370
+ self . headersBuildPhase = headersBuildPhase
371
+ self . resourcesBuildPhase = resourcesBuildPhase
372
+ super. init ( model, pifLoader, signature: signature)
373
+ self . warnings. append ( contentsOf: warnings)
365
374
}
366
375
367
376
@_spi ( Testing) public override init ( fromDictionary pifDict: ProjectModelItemPIF , signature: String , withPIFLoader pifLoader: PIFLoader ) throws
@@ -382,37 +391,47 @@ public class BuildPhaseTarget: Target
382
391
}
383
392
}
384
393
385
- try super. init ( fromDictionary: pifDict, signature: signature, withPIFLoader: pifLoader)
386
-
387
394
// Populate the convenience build phase properties.
395
+ var warnings : [ String ] = [ ]
396
+ var sourcesBuildPhase : SourcesBuildPhase ? = nil
397
+ var frameworksBuildPhase : FrameworksBuildPhase ? = nil
398
+ var headersBuildPhase : HeadersBuildPhase ? = nil
399
+ var resourcesBuildPhase : ResourcesBuildPhase ? = nil
388
400
for buildPhase in self . buildPhases
389
401
{
390
402
switch buildPhase
391
403
{
392
- case let sourcesBuildPhase as SourcesBuildPhase :
393
- if self . sourcesBuildPhase != nil {
404
+ case let sourcesPhase as SourcesBuildPhase :
405
+ if sourcesBuildPhase != nil {
394
406
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
395
407
}
396
- self . sourcesBuildPhase = sourcesBuildPhase
397
- case let frameworksBuildPhase as FrameworksBuildPhase :
398
- if self . frameworksBuildPhase != nil {
408
+ sourcesBuildPhase = sourcesPhase
409
+ case let frameworksPhase as FrameworksBuildPhase :
410
+ if frameworksBuildPhase != nil {
399
411
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
400
412
}
401
- self . frameworksBuildPhase = frameworksBuildPhase
402
- case let headersBuildPhase as HeadersBuildPhase :
403
- if self . headersBuildPhase != nil {
413
+ frameworksBuildPhase = frameworksPhase
414
+ case let headersPhase as HeadersBuildPhase :
415
+ if headersBuildPhase != nil {
404
416
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
405
417
}
406
- self . headersBuildPhase = headersBuildPhase
407
- case let resourcesBuildPhase as ResourcesBuildPhase :
408
- if self . resourcesBuildPhase != nil {
418
+ headersBuildPhase = headersPhase
419
+ case let resourcesPhase as ResourcesBuildPhase :
420
+ if resourcesBuildPhase != nil {
409
421
warnings. append ( " target has multiple \( buildPhase. name) build phases, which may cause it to build incorrectly - all but one should be deleted " )
410
422
}
411
- self . resourcesBuildPhase = resourcesBuildPhase
423
+ resourcesBuildPhase = resourcesPhase
412
424
default :
413
425
break
414
426
}
415
427
}
428
+ self . sourcesBuildPhase = sourcesBuildPhase
429
+ self . frameworksBuildPhase = frameworksBuildPhase
430
+ self . headersBuildPhase = headersBuildPhase
431
+ self . resourcesBuildPhase = resourcesBuildPhase
432
+
433
+ try super. init ( fromDictionary: pifDict, signature: signature, withPIFLoader: pifLoader)
434
+ self . warnings. append ( contentsOf: warnings)
416
435
}
417
436
}
418
437
@@ -484,7 +503,10 @@ public final class StandardTarget: BuildPhaseTarget
484
503
/// The class prefix used in this target
485
504
public let classPrefix : String
486
505
487
- private( set) var provisioningSourceData : [ ProvisioningSourceData ]
506
+ private let _provisioningSourceData : UnsafeDelayedInitializationSendableWrapper < [ ProvisioningSourceData ] > = . init( )
507
+ var provisioningSourceData : [ ProvisioningSourceData ] {
508
+ _provisioningSourceData. value
509
+ }
488
510
489
511
init ( _ model: SWBProtocol . StandardTarget , _ pifLoader: PIFLoader , signature: String ) throws {
490
512
buildRules = model. buildRules. map { BuildRule ( $0, pifLoader) }
@@ -493,14 +515,15 @@ public final class StandardTarget: BuildPhaseTarget
493
515
isPackageTarget = model. isPackageTarget
494
516
performanceTestsBaselinesPath = model. performanceTestsBaselinesPath != nil ? Path ( model. performanceTestsBaselinesPath!) : nil
495
517
predominantSourceCodeLanguage = SourceCodeLanguage . from ( string: model. predominantSourceCodeLanguage)
496
- provisioningSourceData = model. provisioningSourceData
518
+ var provisioningSourceData = model. provisioningSourceData
497
519
classPrefix = model. classPrefix ?? " "
498
520
super. init ( model, pifLoader, signature: signature)
499
521
500
522
// Set our product reference's backpointer to ourself.
501
523
productReference. target = self
502
524
503
- try fixupProvisioningSourceData ( )
525
+ try StandardTarget . fixupProvisioningSourceData ( & provisioningSourceData, name: name, buildConfigurations: buildConfigurations)
526
+ _provisioningSourceData. initialize ( to: provisioningSourceData)
504
527
}
505
528
506
529
@_spi ( Testing) public override init ( fromDictionary pifDict: ProjectModelItemPIF , signature: String , withPIFLoader pifLoader: PIFLoader ) throws
@@ -525,7 +548,7 @@ public final class StandardTarget: BuildPhaseTarget
525
548
classPrefix = try Self . parseOptionalValueForKeyAsString ( PIFKey_Project_classPrefix, pifDict: pifDict) ?? " "
526
549
527
550
// The list of provisioning source data dictionaries is optional. For any configurations for which we were not given a provisioning source data object we will create a default one.
528
- provisioningSourceData = [ ProvisioningSourceData] ( )
551
+ var provisioningSourceData = [ ProvisioningSourceData] ( )
529
552
530
553
if let sourceDataDicts = try Self . parseOptionalValueForKeyAsArrayOfPropertyListItems ( PIFKey_Target_provisioningSourceData, pifDict: pifDict) {
531
554
provisioningSourceData = try sourceDataDicts. map { try PropertyList . decode ( ProvisioningSourceData . self, from: $0) }
@@ -536,10 +559,11 @@ public final class StandardTarget: BuildPhaseTarget
536
559
// Set our product reference's backpointer to ourself.
537
560
productReference. target = self
538
561
539
- try fixupProvisioningSourceData ( )
562
+ try StandardTarget . fixupProvisioningSourceData ( & provisioningSourceData, name: name, buildConfigurations: buildConfigurations)
563
+ _provisioningSourceData. initialize ( to: provisioningSourceData)
540
564
}
541
565
542
- private func fixupProvisioningSourceData( ) throws {
566
+ private static func fixupProvisioningSourceData( _ provisioningSourceData : inout [ ProvisioningSourceData ] , name : String , buildConfigurations : [ BuildConfiguration ] ) throws {
543
567
// Make sure all of our provisioning source data objects match existing configurations, and that there are no duplicate source data structs for a configuration.
544
568
var configurationNames = Set < String > ( buildConfigurations. map ( { $0. name } ) )
545
569
var foundConfigurationNames = Set < String > ( )
0 commit comments