@@ -346,34 +346,23 @@ struct FrameworkBuilder {
346
346
" \( error) " )
347
347
}
348
348
349
- // Find the location of the public headers, any platform will do.
350
349
guard let anyPlatform = targetPlatforms. first,
351
350
let archivePath = slicedFrameworks [ anyPlatform] else {
352
351
fatalError ( " Could not get a path to an archive to fetch headers in \( frameworkName) . " )
353
352
}
354
353
355
- // Get the framework Headers directory. On macOS, it's a symbolic link.
356
- let headersDir = archivePath. appendingPathComponent ( " Headers " ) . resolvingSymlinksInPath ( )
357
-
358
- // The macOS Headers directory can have a Headers file in it symbolically linked to nowhere.
359
- // Delete it here to avoid putting it in the zip or crashing the Carthage hash generation.
360
- // For example,in the 8.0.0 zip distribution see
361
- // Firebase/FirebaseAnalytics/PromisesObjC.xcframework/macos-arm64_x86_64/PromisesObjc
362
- // .framework/Headers/Headers
363
- do {
364
- try fileManager. removeItem ( at: headersDir. appendingPathComponent ( " Headers " ) )
365
- } catch {
366
- // Ignore
367
- }
368
-
369
354
// Find CocoaPods generated umbrella header.
370
355
var umbrellaHeader = " "
356
+ // TODO(ncooke3): Evaluate if `TensorFlowLiteObjC` is needed?
371
357
if framework == " gRPC-Core " || framework == " TensorFlowLiteObjC " {
372
358
// TODO: Proper handling of podspec-specified module.modulemap files with customized umbrella
373
359
// headers. This is good enough for Firebase since it doesn't need these modules.
360
+ // TODO(ncooke3): Is this needed for gRPC-Core?
374
361
umbrellaHeader = " \( framework) -umbrella.h "
375
362
} else {
376
363
var umbrellaHeaderURL : URL
364
+ // Get the framework Headers directory. On macOS, it's a symbolic link.
365
+ let headersDir = archivePath. appendingPathComponent ( " Headers " ) . resolvingSymlinksInPath ( )
377
366
do {
378
367
let files = try fileManager. contentsOfDirectory ( at: headersDir,
379
368
includingPropertiesForKeys: nil )
@@ -391,14 +380,6 @@ struct FrameworkBuilder {
391
380
}
392
381
umbrellaHeader = umbrellaHeaderURL. lastPathComponent
393
382
}
394
- // Copy the Headers over.
395
- let headersDestination = frameworkDir. appendingPathComponent ( " Headers " )
396
- do {
397
- try fileManager. copyItem ( at: headersDir, to: headersDestination)
398
- } catch {
399
- fatalError ( " Could not copy headers from \( headersDir) to Headers directory in " +
400
- " \( headersDestination) : \( error) " )
401
- }
402
383
// Add an Info.plist. Required by Carthage and SPM binary xcframeworks.
403
384
CarthageUtils . generatePlistContents ( forName: frameworkName,
404
385
withVersion: podInfo. version,
@@ -603,18 +584,46 @@ struct FrameworkBuilder {
603
584
// `Both ios-arm64 and ios-armv7 represent two equivalent library definitions`
604
585
var frameworksBuilt : [ URL ] = [ ]
605
586
for (platform, frameworkPath) in slicedFrameworks {
606
- let platformDir = platformFrameworksDir. appendingPathComponent ( platform. buildName)
587
+ // Create the following structure in the platform frameworks directory:
588
+ // - platform_frameworks
589
+ // └── $(PLATFORM)
590
+ // └── $(FRAMEWORK).framework
591
+ let platformFrameworkDir = platformFrameworksDir
592
+ . appendingPathComponent ( platform. buildName)
593
+ . appendingPathComponent ( fromFolder. lastPathComponent)
607
594
do {
608
- try fileManager. createDirectory ( at: platformDir , withIntermediateDirectories: true )
595
+ try fileManager. createDirectory ( at: platformFrameworkDir , withIntermediateDirectories: true )
609
596
} catch {
610
597
fatalError ( " Could not create directory for architecture slices on \( platform) for " +
611
598
" \( framework) : \( error) " )
612
599
}
613
600
614
- // Package a normal .framework given the `fromFolder` and the binary from `slicedFrameworks`.
615
- let destination = platformDir. appendingPathComponent ( fromFolder. lastPathComponent)
601
+ // Headers from slice
602
+ do {
603
+ let headersSrc : URL = frameworkPath. appendingPathComponent ( " Headers " )
604
+ . resolvingSymlinksInPath ( )
605
+ // The macOS slice's `Headers` directory may have a `Headers` file in
606
+ // it that symbolically links to nowhere. For example, in the 8.0.0
607
+ // zip distribution, see the `Headers` directory in the macOS slice
608
+ // of the `PromisesObjC.xcframework`. Delete it here to avoid putting
609
+ // it in the zip or crashing the Carthage hash generation. Because
610
+ // this will throw an error for cases where the file does not exist,
611
+ // the error is ignored.
612
+ try ? fileManager. removeItem ( at: headersSrc. appendingPathComponent ( " Headers " ) )
613
+
614
+ try fileManager. copyItem (
615
+ at: headersSrc,
616
+ to: platformFrameworkDir. appendingPathComponent ( " Headers " )
617
+ )
618
+ } catch {
619
+ fatalError ( " Could not create framework directory needed to build \( framework) : \( error) " )
620
+ }
621
+
622
+ // Info.plist from `fromFolder`
616
623
do {
617
- try fileManager. copyItem ( at: fromFolder, to: destination)
624
+ let infoPlistSrc = fromFolder. appendingPathComponent ( " Info.plist " ) . resolvingSymlinksInPath ( )
625
+ let infoPlistDst = platformFrameworkDir. appendingPathComponent ( " Info.plist " )
626
+ try fileManager. copyItem ( at: infoPlistSrc, to: infoPlistDst)
618
627
} catch {
619
628
fatalError ( " Could not create framework directory needed to build \( framework) : \( error) " )
620
629
}
@@ -623,7 +632,7 @@ struct FrameworkBuilder {
623
632
let binaryName = frameworkPath. lastPathComponent. replacingOccurrences ( of: " .framework " ,
624
633
with: " " )
625
634
let fatBinary = frameworkPath. appendingPathComponent ( binaryName) . resolvingSymlinksInPath ( )
626
- let fatBinaryDestination = destination . appendingPathComponent ( framework)
635
+ let fatBinaryDestination = platformFrameworkDir . appendingPathComponent ( framework)
627
636
do {
628
637
try fileManager. copyItem ( at: fatBinary, to: fatBinaryDestination)
629
638
} catch {
@@ -633,9 +642,9 @@ struct FrameworkBuilder {
633
642
// Use the appropriate moduleMaps
634
643
packageModuleMaps ( inFrameworks: [ frameworkPath] ,
635
644
moduleMapContents: moduleMapContents,
636
- destination: destination )
645
+ destination: platformFrameworkDir )
637
646
638
- frameworksBuilt. append ( destination )
647
+ frameworksBuilt. append ( platformFrameworkDir )
639
648
}
640
649
return frameworksBuilt
641
650
}
0 commit comments