[FR]: Expose the Firestore Pipelines API to Objective-C

Open
#17,013 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
objective-c, swift
Domain
api, database

Research direction

Start by reading the Swift Pipelines implementation under Firestore/Swift/Source/SwiftAPI/Pipeline and the Objective-C bridge in FIRPipelineBridge.h to understand the existing API surface. The issue proposes either a new supported Objective-C API or stabilizing the bridge, so the design and scope need agreement before implementation. Done means Objective-C-bound clients can use Pipelines through a documented, supported API; the issue names no tests to run.

Written by the indexing model from the issue text.

Description

api: firestore type: feature request
Description
  1. Use case. Cross-language consumers of the Firebase iOS SDK that bind it through Objective-C cannot use Firestore Pipelines. The concrete case is Kotlin Multiplatform: Kotlin/Native's cinterop (and the Kotlin Gradle plugin's SwiftPM import) sees only Objective-C headers, so a Kotlin library such as the GitLive Firebase Kotlin SDK, which mirrors the Firebase Android SDK's com.google.firebase.firestore API on iOS over FirebaseFirestoreInternal, can reach every Firestore feature except Pipelines. The Android SDK (com.google.firebase.firestore.pipeline) and the JS SDK (firebase/firestore/pipelines) both expose Pipelines to their languages, so Pipelines is now the one Firestore feature a shared Kotlin codebase cannot offer on iOS. The same applies to any other Objective-C-bound binding (React Native's Objective-C modules, Flutter's Objective-C plugins, C# bindings).

  2. Current behaviour. The Pipelines API is implemented in Swift (Firestore/Swift/Source/SwiftAPI/Pipeline) on top of the Objective-C bridge in FIRPipelineBridge.h. The bridge classes are the only Objective-C-visible part, and 13.0.0 prefixed them with __ (__FIRPipelineBridge, __FIRExprBridge, __FIRStageBridge, ...) to mark them internal and hide them from autocomplete, so they are neither a supported nor a stable surface. The Swift API itself uses structs, generics and protocols (Expression, Pipeline, PipelineSnapshot), which do not get @objc representations. Everything else recently added to Firestore has an Objective-C surface (FIRVectorValue and +[FIRFieldValue vectorWithArray:], the minimum/maximum transforms in 12.19.0, the new BSON types in 13.0.0), which is what makes Pipelines the outlier.

  3. Proposal. Give Pipelines a supported Objective-C API, in either of two shapes:

    • Public Objective-C classes mirroring the Android/JS surface: a FIRPipelineSource returned by -[FIRFirestore pipeline], a FIRPipeline with stage methods, FIRExpr/FIRField/FIRConstant expression classes, FIRAggregateFunction, FIROrdering, and FIRPipelineSnapshot/FIRPipelineResult for the results. The Swift API could then be a thin layer over these, as the rest of Firestore's Swift extensions are over the Objective-C classes.
    • Or promote the existing bridge classes to a supported, documented API (drop the __ prefix or add public typealiases), with the usual source-stability guarantees, since the bridge already covers the stages, expressions and results the Swift API uses.
API Proposal

A sketch of the first shape, following the Android SDK's pipeline() / collection() / where() / sort() / execute() naming:

FIRPipeline *pipeline = [[db pipeline] collection:@"books"];
pipeline = [pipeline where:[[FIRField fieldNamed:@"rating"] greaterThan:[FIRConstant constantWithInt:4]]];
pipeline = [pipeline sort:@[ [[FIRField fieldNamed:@"rating"] descending] ]];
pipeline = [pipeline limit:10];
[pipeline executeWithCompletion:^(FIRPipelineSnapshot *_Nullable snapshot, NSError *_Nullable error) {
  for (FIRPipelineResult *result in snapshot.results) {
    NSLog(@"%@", result.data);
  }
}];

With a realtime variant mirroring addSnapshotListener: on queries:

id<FIRListenerRegistration> registration =
    [pipeline addSnapshotListener:^(FIRPipelineSnapshot *_Nullable snapshot, NSError *_Nullable error) { ... }];
Firebase Product(s)

Firestore

Dominant language
C++
Stars
7k
Forks
1.8k
Avg merge
1d 1h
Merged PRs (30d)
70

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-ios-sdk

All issues in firebase/firebase-ios-sdk

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.