@@ -380,10 +380,6 @@ struct FrameworkBuilder {
380
380
}
381
381
umbrellaHeader = umbrellaHeaderURL. lastPathComponent
382
382
}
383
- // Add an Info.plist. Required by Carthage and SPM binary xcframeworks.
384
- CarthageUtils . generatePlistContents ( forName: frameworkName,
385
- withVersion: podInfo. version,
386
- to: frameworkDir)
387
383
388
384
// TODO: copy PrivateHeaders directory as well if it exists. SDWebImage is an example pod.
389
385
@@ -639,33 +635,7 @@ struct FrameworkBuilder {
639
635
" \( framework) : \( error) " )
640
636
}
641
637
642
- // Move any privacy manifest-containing resource bundles into the
643
- // platform framework.
644
- try ? fileManager. contentsOfDirectory (
645
- at: frameworkPath. deletingLastPathComponent ( ) ,
646
- includingPropertiesForKeys: nil
647
- )
648
- . filter { $0. pathExtension == " bundle " }
649
- // TODO(ncooke3): Once the zip is built with Xcode 15, the following
650
- // `filter` can be removed. The following block exists to preserve
651
- // how resources (e.g. like FIAM's) are packaged for use in Xcode 14.
652
- . filter { bundleURL in
653
- let dirEnum = fileManager. enumerator ( atPath: bundleURL. path)
654
- var containsPrivacyManifest = false
655
- while let relativeFilePath = dirEnum? . nextObject ( ) as? String {
656
- if relativeFilePath. hasSuffix ( " PrivacyInfo.xcprivacy " ) {
657
- containsPrivacyManifest = true
658
- break
659
- }
660
- }
661
- return containsPrivacyManifest
662
- }
663
- // Bundles are moved rather than copied to prevent them from being
664
- // packaged in a `Resources` directory at the root of the xcframework.
665
- . forEach { try ! fileManager. moveItem (
666
- at: $0,
667
- to: platformFrameworkDir. appendingPathComponent ( $0. lastPathComponent)
668
- ) }
638
+ processPrivacyManifests ( fileManager, frameworkPath, platformFrameworkDir)
669
639
670
640
// Headers from slice
671
641
do {
@@ -688,25 +658,23 @@ struct FrameworkBuilder {
688
658
fatalError ( " Could not create framework directory needed to build \( framework) : \( error) " )
689
659
}
690
660
691
- // Info.plist from `fromFolder`
692
- do {
693
- let infoPlistSrc = fromFolder. appendingPathComponent ( " Info.plist " ) . resolvingSymlinksInPath ( )
694
- let infoPlistDst = platformFrameworkDir. appendingPathComponent ( " Info.plist " )
695
- try fileManager. copyItem ( at: infoPlistSrc, to: infoPlistDst)
696
- } catch {
697
- fatalError ( " Could not create framework directory needed to build \( framework) : \( error) " )
698
- }
699
-
700
- // Copy the binary to the right location.
661
+ // Copy the binary and Info.plist to the right location.
701
662
let binaryName = frameworkPath. lastPathComponent. replacingOccurrences ( of: " .framework " ,
702
663
with: " " )
703
664
let fatBinary = frameworkPath. appendingPathComponent ( binaryName) . resolvingSymlinksInPath ( )
665
+ let infoPlist = frameworkPath. appendingPathComponent ( " Info.plist " ) . resolvingSymlinksInPath ( )
666
+ let infoPlistDestination = platformFrameworkDir. appendingPathComponent ( " Info.plist " )
704
667
let fatBinaryDestination = platformFrameworkDir. appendingPathComponent ( framework)
705
668
do {
706
669
try fileManager. copyItem ( at: fatBinary, to: fatBinaryDestination)
707
670
} catch {
708
671
fatalError ( " Could not copy fat binary to framework directory for \( framework) : \( error) " )
709
672
}
673
+ do {
674
+ try fileManager. copyItem ( at: infoPlist, to: infoPlistDestination)
675
+ } catch {
676
+ // The Catalyst and macos Info.plist's are in another location. Ignore failure.
677
+ }
710
678
711
679
// Use the appropriate moduleMaps
712
680
packageModuleMaps ( inFrameworks: [ frameworkPath] ,
@@ -719,6 +687,39 @@ struct FrameworkBuilder {
719
687
return frameworksBuilt
720
688
}
721
689
690
+ /// Process privacy manifests.
691
+ ///
692
+ /// Move any privacy manifest-containing resource bundles into the platform framework.
693
+ func processPrivacyManifests( _ fileManager: FileManager ,
694
+ _ frameworkPath: URL ,
695
+ _ platformFrameworkDir: URL ) {
696
+ try ? fileManager. contentsOfDirectory (
697
+ at: frameworkPath. deletingLastPathComponent ( ) ,
698
+ includingPropertiesForKeys: nil
699
+ )
700
+ . filter { $0. pathExtension == " bundle " }
701
+ // TODO(ncooke3): Once the zip is built with Xcode 15, the following
702
+ // `filter` can be removed. The following block exists to preserve
703
+ // how resources (e.g. like FIAM's) are packaged for use in Xcode 14.
704
+ . filter { bundleURL in
705
+ let dirEnum = fileManager. enumerator ( atPath: bundleURL. path)
706
+ var containsPrivacyManifest = false
707
+ while let relativeFilePath = dirEnum? . nextObject ( ) as? String {
708
+ if relativeFilePath. hasSuffix ( " PrivacyInfo.xcprivacy " ) {
709
+ containsPrivacyManifest = true
710
+ break
711
+ }
712
+ }
713
+ return containsPrivacyManifest
714
+ }
715
+ // Bundles are moved rather than copied to prevent them from being
716
+ // packaged in a `Resources` directory at the root of the xcframework.
717
+ . forEach { try ! fileManager. moveItem (
718
+ at: $0,
719
+ to: platformFrameworkDir. appendingPathComponent ( $0. lastPathComponent)
720
+ ) }
721
+ }
722
+
722
723
/// Package the built frameworks into an XCFramework.
723
724
/// - Parameter withName: The framework name.
724
725
/// - Parameter frameworks: The grouped frameworks.
0 commit comments