Sfoglia il codice sorgente

Add Firebase module for SPM (#5884)

Paul Beusterien 5 anni fa
parent
commit
9128c68493
4 ha cambiato i file con 55 aggiunte e 16 eliminazioni
  1. 29 2
      CoreOnly/Sources/Firebase.h
  2. 15 0
      CoreOnly/Sources/dummy.m
  3. 10 13
      Package.swift
  4. 1 1
      Tests/firebase-test/main.swift

+ 29 - 2
CoreOnly/Sources/Firebase.h

@@ -12,26 +12,39 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#import <FirebaseCore/FirebaseCore.h>
+// The module qualified imports are for CocoaPods and the simple file names
+// for Swift Package Manager.
 
 #if !defined(__has_include)
   #error "Firebase.h won't import anything if your compiler doesn't support __has_include. Please \
           import the headers individually."
 #else
+  #if __has_include(<FirebaseCore/FirebaseCore.h>)
+    #import <FirebaseCore/FirebaseCore.h>
+  #elif __has_include("FirebaseCore.h")
+    #import "FirebaseCore.h"
+  #endif
+
   #if __has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
     #import <FirebaseAnalytics/FirebaseAnalytics.h>
   #endif
 
   #if __has_include(<FirebaseAuth/FirebaseAuth.h>)
     #import <FirebaseAuth/FirebaseAuth.h>
+  #elif __has_include("FirebaseAuth.h")
+    #import "FirebaseAuth.h"
   #endif
 
   #if __has_include(<FirebaseCrashlytics/FirebaseCrashlytics.h>)
     #import <FirebaseCrashlytics/FirebaseCrashlytics.h>
+  #elif  __has_include("FirebaseCrashlytics.h")
+    #import "FirebaseCrashlytics.h"
   #endif
 
   #if __has_include(<FirebaseDatabase/FirebaseDatabase.h>)
     #import <FirebaseDatabase/FirebaseDatabase.h>
+  #elif __has_include("FirebaseDatabase.h")
+    #import "FirebaseDatabase.h"
   #endif
 
   #if __has_include(<FirebaseDynamicLinks/FirebaseDynamicLinks.h>)
@@ -43,14 +56,20 @@
 Firebase Dynamic Links works as intended."
       #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
     #endif
+  #elif __has_include("FirebaseDynamicLinks.h")
+    #import "FirebaseDynamicLinks.h"
   #endif
 
   #if __has_include(<FirebaseFirestore/FirebaseFirestore.h>)
     #import <FirebaseFirestore/FirebaseFirestore.h>
+  #elif __has_include("FirebaseFirestore.h")
+    #import "FirebaseFirestore.h"
   #endif
 
   #if __has_include(<FirebaseFunctions/FirebaseFunctions.h>)
     #import <FirebaseFunctions/FirebaseFunctions.h>
+  #elif __has_include("FirebaseFunctions.h")
+    #import "FirebaseFunctions.h"
   #endif
 
   #if __has_include(<FirebaseInAppMessaging/FirebaseInAppMessaging.h>)
@@ -62,6 +81,8 @@ Firebase Dynamic Links works as intended."
 Firebase In App Messaging works as intended."
       #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
     #endif
+  #elif __has_include("FirebaseInAppMessaging.h")
+    #import "FirebaseInAppMessaging.h"
   #endif
 
   #if __has_include(<FirebaseInstanceID/FirebaseInstanceID.h>)
@@ -77,7 +98,9 @@ Firebase In App Messaging works as intended."
 Firebase Messaging works as intended."
       #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
     #endif
-#endif
+  #elif __has_include("FirebaseMessaging.h")
+    #import "FirebaseMessaging.h"
+  #endif
 
   #if __has_include(<FirebaseMLCommon/FirebaseMLCommon.h>)
     #import <FirebaseMLCommon/FirebaseMLCommon.h>
@@ -151,10 +174,14 @@ Firebase Performance works as intended."
 Firebase Remote Config works as intended."
       #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
     #endif
+  #elif __has_include("FirebaseRemoteConfig.h")
+    #import "FirebaseRemoteConfig.h"
   #endif
 
   #if __has_include(<FirebaseStorage/FirebaseStorage.h>)
     #import <FirebaseStorage/FirebaseStorage.h>
+  #elif __has_include("FirebaseStorage.h")
+    #import "FirebaseStorage.h"
   #endif
 
   #if __has_include(<GoogleMobileAds/GoogleMobileAds.h>)

+ 15 - 0
CoreOnly/Sources/dummy.m

@@ -0,0 +1,15 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Placeholder file, since SwiftPM requires a source file to create a module.

+ 10 - 13
Package.swift

@@ -27,10 +27,10 @@ let package = Package(
   products: [
     // Products define the executables and libraries produced by a package, and make them visible to
     // other packages.
-    // .library(
-    //   name: "Firebase",
-    //   targets: ["Firebase"]
-    // ),
+    .library(
+      name: "Firebase",
+      targets: ["Firebase"]
+    ),
     .library(
       name: "FirebaseCore",
       targets: ["FirebaseCore"]
@@ -79,7 +79,7 @@ let package = Package(
       dependencies: [
         "FirebaseAuth",
         "FirebaseFunctions",
-        //  "Firebase",
+        "Firebase",
         "FirebaseCore",
         "FirebaseInstallations",
         // "FirebaseInstanceID",
@@ -154,9 +154,6 @@ let package = Package(
       cSettings: [
         .headerSearchPath("../.."),
       ]
-      // linkerSettings: [
-      //   .linkedFramework("Security"),
-      // ]
     ),
     .target(
       name: "GoogleUtilities_NSData",
@@ -187,11 +184,11 @@ let package = Package(
         .headerSearchPath("../../"),
       ]
     ),
-    // .target(
-    //   name: "Firebase",
-    //   path: "Firebase/Sources",
-    //   publicHeadersPath: "Public"
-    // ),
+    .target(
+      name: "Firebase",
+      path: "CoreOnly/Sources",
+      publicHeadersPath: "./"
+    ),
     .target(
       name: "FirebaseCore",
       dependencies: ["GoogleUtilities_Environment", "GoogleUtilities_Logger"],

+ 1 - 1
Tests/firebase-test/main.swift

@@ -13,7 +13,7 @@
 // limitations under the License.
 
 import Foundation
-// import Firebase
+import Firebase
 import FirebaseCore
 import FirebaseAuth
 import FirebaseFunctions