Skip to content

Commit a60a0e2

Browse files
authored
Workaround Carthage Protobuf parallel install issue (#5345)
1 parent b6bda07 commit a60a0e2

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

Carthage.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ more details and additional installation methods.
2828
- Create a Cartfile with a **subset** of the following components - choosing the
2929
Firebase components that you want to include in your app. Note that
3030
**FirebaseAnalyticsBinary** must always be included.
31+
32+
- If you're using FirebaseMessaging, FirebasePerformance, FirebaserRemoteConfig,
33+
FirebaseABTesting, FirebaseInAppMessaging, or FirebaseML,
34+
**FirebaseProtobufBinary** must also be included.
3135
```
3236
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseABTestingBinary.json"
3337
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAdMobBinary.json"
@@ -54,6 +58,7 @@ binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMLVisionLabelMode
5458
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMLVisionObjectDetectionBinary.json"
5559
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMLVisionTextModelBinary.json"
5660
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json"
61+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseProtobufBinary.json"
5762
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json"
5863
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseStorageBinary.json"
5964
```

FirebaseCore/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
# v6.6.7 -- M69
2+
- [fixed] Fixed Carthage installation failures involving `Protobuf.framework`.
3+
`Protobuf.framework` is now separately installable via adding
4+
`FirebaseProtobufBinary.json` to the Cartfile. Full details in the [Carthage usage
5+
instructions](https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md#carthage-usage).
6+
(#5276)
7+
18
# v6.6.6 -- M68
2-
- [fixed] Unincluded umbrella header warnings in Carthage and zip distributions
9+
- [fixed] Fixed unincluded umbrella header warnings in Carthage and zip distributions
310
introduced in Firebase 6.21.0. (#5209)
411

512
# v6.6.5 -- M67

ZipBuilder/Sources/ZipBuilder/CarthageUtils.swift

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension CarthageUtils {
7575
/// Generates all required files for a Carthage release.
7676
///
7777
/// - Parameters:
78-
/// - packagedDir: The packaged directory assembled for Carthage and Zip distribution.
78+
/// - packagedDir: The packaged directory assembled for the Carthage distribution.
7979
/// - templateDir: The template project directory, contains the dummy Firebase library.
8080
/// - jsonDir: Location of directory containing all JSON Carthage manifests.
8181
/// - firebaseVersion: The version of the Firebase pod.
@@ -87,6 +87,7 @@ extension CarthageUtils {
8787
jsonDir: URL,
8888
artifacts: ZipBuilder.ReleaseArtifacts,
8989
outputDir: URL) {
90+
factorProtobuf(inPackagedDir: packagedDir)
9091
let directories: [String]
9192
do {
9293
directories = try FileManager.default.contentsOfDirectory(atPath: packagedDir.path)
@@ -190,6 +191,44 @@ extension CarthageUtils {
190191
}
191192
}
192193

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+
193232
/// Creates a fake Firebase.framework to use the module for `import Firebase` compatibility.
194233
///
195234
/// - Parameters:

0 commit comments

Comments
 (0)