Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Functions/FirebaseFunctions/FIRFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,32 @@
#import "FIRFunctions.h"
#import "FIRFunctions+Internal.h"

#if SWIFT_PACKAGE
@import FirebaseCore;
@import GTMSessionFetcherCore;
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not adopt repo-relative imports for all private headers?

And for that matter, if that works, why not just use repo-relative imports for all the headers?

As it stands this is an unmaintainable mess. People will develop one way and fail to update the imports on the other side. This doesn't seem long term viable without finding a way to just have one set of imports.

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 should migrate to all repo-relative internal headers, but I'd prefer to work on standardization on master and separate from the Swift Package Manager branch.

Public headers cannot be repo relative because they'll generate conflicts with module-imports. The exception is public header imports from a non-header source in the same target.

Copy link
Contributor

Choose a reason for hiding this comment

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

But surely there has to be a way to hide this so that not every client of FirebaseCore has to have this mess inside it.

Consider an alternative:

FirebaseCore has a private header that contains:

#if SWIFT_PACKAGE
@import FirebaseCore;
#else
#import <FirebaseCore/FirebaseCore.h>
#endif

Now functions is none the wiser about this; we just adopt the convention that imports from one SDK to another always use our private umbrella header.

As it stands, this is creating a mass of technical debt. Honestly, I can't even read what's going on here and have a hard time understanding whether or not imports are being handled equivalently on both sides of the #else. Now that storage is done I think we're past the point of prototyping and we need to address this issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, addressing in #5758 and will rebase or reimplement this PR after that.

#import "FirebaseCore/Sources/Private/FIRComponent.h"
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h"
#import "FirebaseCore/Sources/Private/FIRDependency.h"
#import "FirebaseCore/Sources/Private/FIRLibrary.h"
#import "Interop/Auth/Public/FIRAuthInterop.h"
#else
#import <FirebaseAuthInterop/FIRAuthInterop.h>
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIRComponent.h>
#import <FirebaseCore/FIRComponentContainer.h>
#import <FirebaseCore/FIRDependency.h>
#import <FirebaseCore/FIRLibrary.h>
#import <FirebaseCore/FIROptions.h>
#import <GTMSessionFetcher/GTMSessionFetcher.h>
#import <GTMSessionFetcher/GTMSessionFetcherLogging.h>

#import <FirebaseCore/FIRApp.h>
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIROptions.h>

#import <GTMSessionFetcher/GTMSessionFetcherService.h>
#endif

#import "FIRError.h"
#import "FIRHTTPSCallable+Internal.h"
Expand All @@ -29,11 +50,6 @@
#import "FUNSerializer.h"
#import "FUNUsageValidation.h"

#import <FirebaseCore/FIRApp.h>
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIROptions.h>
#import <GTMSessionFetcher/GTMSessionFetcherService.h>

// The following two macros supply the incantation so that the C
// preprocessor does not try to parse the version as a floating
// point number. See
Expand Down
4 changes: 4 additions & 0 deletions Functions/FirebaseFunctions/FUNContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

#import "FUNContext.h"

#if SWIFT_PACKAGE
#import "Interop/Auth/Public/FIRAuthInterop.h"
#else
#import <FirebaseAuthInterop/FIRAuthInterop.h>
#endif

#import "FUNInstanceIDProxy.h"

Expand Down
38 changes: 14 additions & 24 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ let package = Package(
name: "Firebase",
targets: ["Firebase"]
),
.library(
name: "FirebaseCore",
targets: ["FirebaseCore"]
),
.library(
name: "FirebaseAuth",
targets: ["FirebaseAuth"]
Expand All @@ -43,16 +39,9 @@ let package = Package(
name: "FirebaseCrashlytics",
targets: ["FirebaseCrashlytics"]
),
// .library(
// name: "FirebaseFunctions",
// targets: ["FirebaseFunctions"]),
.library(
name: "FirebaseInstallations",
targets: ["FirebaseInstallations"]
),
.library(
name: "FirebaseInstanceID",
targets: ["FirebaseInstanceID"]
name: "FirebaseFunctions",
targets: ["FirebaseFunctions"]
),
.library(
name: "FirebaseStorage",
Expand All @@ -75,6 +64,7 @@ let package = Package(
name: "firebase-test",
dependencies: [ // "FirebaseAuth", "FirebaseFunctions",
"Firebase", "FirebaseCore", "FirebaseCrashlytics",
"FirebaseFunctions",
"FirebaseInstallations", "FirebaseInstanceID",
"FirebaseStorage", "FirebaseStorageSwift",
"GoogleUtilities_Environment", "GoogleUtilities_Logger",
Expand Down Expand Up @@ -204,17 +194,17 @@ let package = Package(
.define("FIRAuth_MINOR_VERSION", to: "1.1"), // TODO: Fix version
]
),
// .target(
// name: "FirebaseFunctions",
// dependencies: ["FirebaseCore", "GTMSessionFetcher_Core"],
// path: "Functions/FirebaseFunctions",
// publicHeadersPath: "Public",
// cSettings: [
// // SPM doesn't support interface frameworks or private headers
// .headerSearchPath("../../"),
// .define("FIRFunctions_VERSION", to: "0.0.1"), // TODO Fix version
// .define("SWIFT_PACKAGE", to: "1"), // SPM loses defaults if other cSettings
// ]),
.target(
name: "FirebaseFunctions",
dependencies: ["FirebaseCore", "GTMSessionFetcherCore"],
path: "Functions/FirebaseFunctions",
publicHeadersPath: "Public",
cSettings: [
// SPM doesn't support interface frameworks or private headers
.headerSearchPath("../../"),
.define("FIRFunctions_VERSION", to: "0.0.1"), // TODO: Fix version
]
),
.target(
name: "FirebaseInstanceID",
dependencies: ["FirebaseCore", "FirebaseInstallations",
Expand Down
2 changes: 1 addition & 1 deletion Sources/firebase-test/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Firebase
import FirebaseCore
import FirebaseAuth
import FirebaseCrashlytics
// import FirebaseFunctions
import FirebaseFunctions
import FirebaseInstallations
import FirebaseInstanceID
import FirebaseStorage
Expand Down