Skip to content

Fix Resource generation for Carthage xcframeworks #8182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 3, 2021

Conversation

paulb777
Copy link
Member

@paulb777 paulb777 commented Jun 3, 2021

Fix #8112

Carthage resources should remain in each .framework instead of at the root of .xcframeworks.

After all xcframework resources are processed and stored at the root of the .xcframework at https://github.com/firebase/firebase-ios-sdk/blob/master/ReleaseTooling/Sources/ZipBuilder/FrameworkBuilder.swift#L697, the new code consolidates both Zip Distro and Carthage resource processing in ZipBuilder.swift.

It still remains for the future to handle platform-specific Resources.

Successful test at https://github.com/firebase/firebase-ios-sdk/actions/runs/903575515.
I verified the Zip in the artifact matches the 8.1.0 release. The only exception is GoogleSignIn Resources are now in the framework. See comments for more discussion about GoogleSignIn. I also verified that the Firestore, GoogleSignIn, and FIAM Carthage zips successfully install on carthage update including the xcframeworks that were not installing because of the Resources location.

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

// Update the README.
readmeDeps += dependencyString(for: pod.key, in: productDir, frameworks: podFrameworks)

// Special case for Crashlytics:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Crashlytics code is only reindented and shows up in green below.

@@ -46,24 +46,6 @@ struct FirebaseBuilder {
options: carthageBuildOptions
)

// Prepare the release directory for zip packaging.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chunk is migrated to the if packageKind == "Firebase" { code below.

// Move all the bundles in the frameworks out to a common "Resources" directory to
// match the existing Zip structure.
let resourcesDir = productPath.appendingPathComponent("Resources")
try fileManager.moveItem(at: xcResourceDir, to: resourcesDir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moveItem instead of ResourcesManager.moveAllBundles since the resources were already processed when the xcframework was created.

@paulb777 paulb777 mentioned this pull request Jun 3, 2021
@paulb777 paulb777 force-pushed the pb-fix-carthage-resources branch from 43f5cd2 to 54bab2b Compare June 3, 2021 16:43
Copy link
Member

@ryanwilson ryanwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments, they helped a bunch!

Comment on lines +465 to +466
// TODO: Investigate changing the zip distro to also have Resources in the .frameworks to
// enable different platform Resources.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there was an issue in having them embedded in the frameworks but I can't remember, maybe it was an older Xcode version and latest versions would be fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have had another issue in the past, like an invalid Info.plist. My testing shows it to be fine now.

// match the existing Zip structure.
let resourcesDir = productPath.appendingPathComponent("Resources")
try fileManager.moveItem(at: xcResourceDir, to: resourcesDir)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: extra blank line.

Comment on lines 489 to 490
guard fileManager.isDirectory(at: platformPath)
else { continue }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be on a single line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing in next commit

Copy link
Member Author

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look good. Will fix spaces review commit and summarize testing in PR intro, and then merge

Comment on lines +465 to +466
// TODO: Investigate changing the zip distro to also have Resources in the .frameworks to
// enable different platform Resources.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have had another issue in the past, like an invalid Info.plist. My testing shows it to be fine now.

Comment on lines 489 to 490
guard fileManager.isDirectory(at: platformPath)
else { continue }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing in next commit

@paulb777
Copy link
Member Author

paulb777 commented Jun 3, 2021

There is an issue with blaze created frameworks 😞

~/test-8082/Firebase-actions-dir/carthage/8.1.0/GoogleSignIn  $ swift
Welcome to Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55).
Type :help for assistance.
  1> import Foundation
  2> Bundle(path: "GoogleSignIn.framework")!.infoDictionary
$R0: [String : Any]? = 0 key/value pairs

The one diff in the generated zip is the GoogleSignIn resources aren't being moved out of the framework any longer. I'll restore so that the zip is unchanged.

@paulb777
Copy link
Member Author

paulb777 commented Jun 3, 2021

On additional investigation, the Carthage GoogleSignIn.framework is the same structure it has always been. It turns out that Carthage needs to be able to process Info.plist's for .xcframeworks , but not for .frameworks. Given that GoogleSignIn will soon move to .xcframeworks and issues like #8154, I'll merge as is.

@paulb777 paulb777 merged commit 2fe8a25 into master Jun 3, 2021
@paulb777 paulb777 deleted the pb-fix-carthage-resources branch June 3, 2021 22:51
@firebase firebase locked and limited conversation to collaborators Jul 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firestore Carthage installation is missing gRPC-C++ in 8.0.0
3 participants