@@ -75,7 +75,7 @@ extension CarthageUtils {
75
75
/// Generates all required files for a Carthage release.
76
76
///
77
77
/// - Parameters:
78
- /// - packagedDir: The packaged directory assembled for Carthage and Zip distribution.
78
+ /// - packagedDir: The packaged directory assembled for the Carthage distribution.
79
79
/// - templateDir: The template project directory, contains the dummy Firebase library.
80
80
/// - jsonDir: Location of directory containing all JSON Carthage manifests.
81
81
/// - firebaseVersion: The version of the Firebase pod.
@@ -87,6 +87,7 @@ extension CarthageUtils {
87
87
jsonDir: URL ,
88
88
artifacts: ZipBuilder . ReleaseArtifacts ,
89
89
outputDir: URL ) {
90
+ factorProtobuf ( inPackagedDir: packagedDir)
90
91
let directories : [ String ]
91
92
do {
92
93
directories = try FileManager . default. contentsOfDirectory ( atPath: packagedDir. path)
@@ -190,6 +191,44 @@ extension CarthageUtils {
190
191
}
191
192
}
192
193
194
+ /// Factor Protobuf into a separate Carthage distribution to avoid Carthage install issues
195
+ /// trying to install the same framework from multiple bundles(#5276).
196
+ ///
197
+ /// - Parameters:
198
+ /// - packagedDir: The packaged directory assembled for Carthage and Zip distribution.
199
+
200
+ private static func factorProtobuf( inPackagedDir packagedDir: URL ) {
201
+ let directories : [ String ]
202
+ let protobufDir = packagedDir. appendingPathComponent ( " FirebaseProtobuf " )
203
+ do {
204
+ directories = try FileManager . default. contentsOfDirectory ( atPath: packagedDir. path)
205
+ } catch {
206
+ fatalError ( " Could not get contents of Firebase directory to package Carthage build. \( error) " )
207
+ }
208
+ let fileManager = FileManager . default
209
+ var didMove = false
210
+ // Loop through each directory to see if it includes Protobuf.framework.
211
+ for package in directories {
212
+ let fullPath = packagedDir. appendingPathComponent ( package )
213
+ . appendingPathComponent ( " Protobuf.framework " )
214
+ if fileManager. fileExists ( atPath: fullPath. path) {
215
+ if didMove == false {
216
+ didMove = true
217
+ do {
218
+ try fileManager. createDirectory ( at: protobufDir, withIntermediateDirectories: true )
219
+ try fileManager
220
+ . moveItem ( at: fullPath, to: protobufDir. appendingPathComponent ( " Protobuf.framework " ) )
221
+ } catch {
222
+ fatalError ( " Failed to create Carthage protobuf directory at \( protobufDir) \( error) " )
223
+ }
224
+
225
+ } else {
226
+ fileManager. removeIfExists ( at: fullPath)
227
+ }
228
+ }
229
+ }
230
+ }
231
+
193
232
/// Creates a fake Firebase.framework to use the module for `import Firebase` compatibility.
194
233
///
195
234
/// - Parameters:
0 commit comments