Skip to content

Merge FirebaseStorageSwift and FirebaseStorage #9045

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 11 commits into from
Dec 8, 2021

Conversation

paulb777
Copy link
Member

@paulb777 paulb777 commented Dec 2, 2021

We originally thought that we could move to combined Swift/ObjC libraries with a single combined CocoaPod and a dependent SwiftPM library. However, that strategy is problematic since it makes usability of public imports different between the two package managers, along with testing and usability complications.

This PR prototypes using the same library structure for both. It also solves the problem of providing Swift error codes for any API that needs them by using REFINED_FOR_SWIFT for any applicable API and wrapping the error handling in a Swift specific API. See the list API implementation.

I believe we have two unavoidable breakages:

  • When we start to depend on Swift libraries, we will require all CocoaPods users to use frameworks (static or dynamic). This is probably fine since most users are probably already there - but will require a breaking release.
  • I don't know of a good way to continue to support the Firebase pod and Firebase.h to support APIs only available through Swift. This will be a big breaking change and we will need to come up with a good migration strategy.

Open Questions:

  • Should we use @_exported import FirebaseStorageObjC to pass through Objective C APIs or should we explicitly wrap all of them in Swift after marking them as REFINED_FOR_SWIFT?
  • Can we do a Swift version of a Firebase module with can_import to continue to support import Firebase?

Next Steps for Storage:

  • Update all APIs that can return an error similarly to list

@google-cla google-cla bot added the cla: yes label Dec 2, 2021
@paulb777 paulb777 marked this pull request as draft December 2, 2021 23:39
@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

list(maxResults: maxResults,
pageToken: pageToken,
completion: getResultCallback(completion: completion))
__list(withMaxResults: maxResults,
Copy link
Member Author

Choose a reason for hiding this comment

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

list implementation for Swift clients that will find the error handling in Result.swift

(void (^)(FIRStorageListResult *result, NSError *_Nullable error))completion
NS_SWIFT_NAME(list(maxResults:completion:));
completion:(void (^)(FIRStorageListResult *result,
NSError *_Nullable error))completion NS_REFINED_FOR_SWIFT;
Copy link
Member Author

Choose a reason for hiding this comment

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

Hide API for Swift

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import FirebaseStorage
@_exported import FirebaseStorageObjC
Copy link
Member Author

Choose a reason for hiding this comment

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

Pass Objective C APIS through to Swift.

Copy link
Member

@ncooke3 ncooke3 left a comment

Choose a reason for hiding this comment

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

LGTM – thanks for the thorough writeup! Left mostly nits below. Feel free to defer to future PRs.

@paulb777 paulb777 marked this pull request as ready for review December 8, 2021 22:40
@paulb777
Copy link
Member Author

paulb777 commented Dec 8, 2021

Going to merge this here to storage-v9 since this now demonstrates an always Swift-on top library approach along with providing the structure to pass through and/or override any Objective C API.

I'll address open questions and next steps in subsequent PRs.

Feel free to continue to add comments and I'll address those as well.

@paulb777 paulb777 merged commit e557c44 into storage-v9 Dec 8, 2021
@paulb777 paulb777 deleted the pb-merge-storage-swift branch December 8, 2021 23:50
@firebase firebase locked and limited conversation to collaborators Jan 8, 2022
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.

3 participants