Firebase xcframework integration with SPM

Last update: May 23, 2022

Firebase xcframework integration with SPM

A small mirror for https://github.com/firebase/firebase-ios-sdk, to add support for using their binary dependencies (xcframeworks) with swift package manager.

This repo contains a Package.swift file, which uses a binaryTarget for all Firebase libraries (xcframework files are hosted in github releases).

Official SPM Support

Firebase currently supports SPM integration, see the official SDK integration instructions. This repo is an alternative for integrating with their pre-built xcframeworks for faster build times. See in depth discussion for official SPM support for xcframeworks here.

Installation

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MyLibrary",
    platforms: [.iOS(.v11)],
    products: [
        .library(name: "MyLibrary", targets: ["MyLibraryTarget"])
    ],
    dependencies: [
        .package(
            name: "Firebase",
            url: "https://github.com/akaffenberger/firebase-ios-sdk-xcframeworks.git",
            .exact("8.10.0")
        ),
    ],
    targets: [
        .target(
            name: "MyLibraryTarget",
            dependencies: [
                .product(name: "Google-Mobile-Ads-SDK", package: "Firebase"),
                .product(name: "FirebaseAnalytics", package: "Firebase")
            ]
        )
    ]
)

Add resource bundles

Some Firebase frameworks require resource bundles. To include those, there are two options:

  1. Use the provided script to automatically include all Firebase resources. Copy the following into a Run Script Phase:
sh "${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk-xcframeworks/.scripts/resources.sh"
  1. Or, manually drag and drop the specific resource bundles you need from the package into your Copy Bundle Resources Phase:

How it works

The Package.swift and Sources files are automatically generated via a script, which is set to run in a scheduled cron job via Github Actions.

The script performs the following actions:

  • Downloads the latest release from https://github.com/firebase/firebase-ios-sdk
  • Parses the Firebase.zip to generate Package.swift and Sources/
  • Commits changes on a new branch and creates a PR
  • Creates a draft release, with a tag that mirrors the Firebase release. The draft release includes the assets needed for the swift package

Run locally

  • Install github cli: $ brew install gh
  • Generate the swift package: $ cd .scripts && sh package.sh debug skip-release

GitHub

https://github.com/akaffenberger/firebase-ios-sdk-xcframeworks
Comments
  • 1. Missing FirebaseFirestoreSwift product

    When pulling in the official Firebase package directly, there is a product called FirebaseFirestoreSwift available that adds support for the @DocumentID property wrapper, and Codable based write methods like .setData(from: Codable).

    Would it be possible to include that product in this package?

    Reviewed by tylerjbarnes at 2022-01-15 18:49
  • 2. InAppMessaging bundle is missing

    8.15.0 - [Firebase/InAppMessaging][I-IAM400009] Display ran into error for message 3978956120715808093: Error Domain=com.firebase.inappmessaging.display Code=1 "(null)" UserInfo={message=resource bundle is missing}

    Screenshot 2022-04-26 at 12 30 27

    I can't get the in app messages to work.

    How are .bundles working with SPM and Firebase?

    Firebase seems to be using, for getting the resources for InAppMessaging

    + (NSArray *)relevantBundles {
      return @[ [NSBundle mainBundle], [NSBundle bundleForClass:[self class]] ];
    }
    

    Correct me if I'm wrong: SPM puts all the resources into the main app bundle, but mainBundle called from .xcframework won't be the app bundle, it'll be the framework bundle, hence it can't find the needed resources. That's as far as I've gone with my investigation.

    I'm trying to understand how to fix this issue as we really enjoy using this mirror. Could it have regressed? Or maybe I configured something incorrectly.

    Reviewed by michalciurus at 2022-04-26 10:32
  • 3. FirebaseFirestore unsafe build flags

    Since updating to version 9.0.0 I am unable to build the project. I get the following error:

    The package product 'FirebaseFirestore' cannot be used as a dependency of this target because it uses unsafe build flags.
    
    Reviewed by dineshvijaykumar at 2022-05-16 12:24
  • 4. `ld: framework not found FBLPromises`

    Reviewed by imWildCat at 2022-03-28 12:58
  • 5. Package collision for SwiftProtobuf

    Attempted to add a dependency on another library that uses SwiftProtobuf and get the following collision error:

    multiple targets named 'SwiftProtobuf' in: 'firebase-ios-sdk-xcframeworks', 'swift-protobuf'
    

    Any thoughts on how these could be reconciled? The dependency in question is Algolia InstantSearch https://github.com/algolia/instantsearch-ios, which relies on the https://github.com/apple/swift-protobuf package.

    I imagine other important dependencies may pop up with a similar issue.

    Reviewed by sejr at 2022-05-17 21:37
iOS Open-Source Telematics App with Firebase© integration
 iOS Open-Source Telematics App with Firebase© integration

Open-source telematics app for iOS. The application is suitable for UBI (Usage-based insurance), shared mobility, transportation, safe driving, tracking, family trackers, drive-coach, and other driving mobile applications

Mar 12, 2022
Firebase Analytics Firebase Notification Alamofire KingFisher Ombdb API
Firebase Analytics Firebase Notification Alamofire KingFisher Ombdb API

MovieOmdbApp Firebase Analytics Firebase Notification Alamofire KingFisher Ombdb

Dec 20, 2021
A swift package(SPM) with iOS UI component that loads and displays images from remote urls or local assets and displays in a slide-show form with auto scroll feature.

MDBannersView A swift package with an iOS UI component that loads and displays images from remote urls, local assets and displays in a slide-show form

Feb 5, 2022
DEVOTE In this SwiftUI tutorial, we will develop a task manager iOS application with Core Data integration.

DEVOTE In this SwiftUI tutorial, we will develop a task manager iOS application with Core Data integration. This is not a project with a boring user interface. This iOS and iPadOS application provides a personal touch and feel.

Dec 21, 2021
Simple Todo Application using SwiftUI / Firebase / Redux.
Simple Todo Application using SwiftUI / Firebase / Redux.

Simple Todo Application using SwiftUI/Firebase/Redux/Combine. Light _ _ _ _ Dark _ _ _ Feature Use SwiftUI fully. Use Firebase. Authentication Cloud F

May 10, 2022
Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple
Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple

Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple Follow the tutorial at alfianlosari.com Features Uses Fir

Mar 10, 2022
SwiftUI, Firebase, Kingfisher, googleapis
 SwiftUI, Firebase, Kingfisher, googleapis

SwiftUI-KokaiByWGO Xcode Version 12.0 SwiftUI, Firebase, Kingfisher, googleapis Learn Thai with pictures and sounds Note : This version have no CMS so

Oct 6, 2021
Instagram clone with firebase and swift
Instagram clone with firebase and swift

Instagram clone with firebase and swift

Nov 20, 2021
A grocery list app for families written in Swift using Firebase Realtime Database

FamiList | Grocery list app in Swift FamiList is a grocery list app for families written in Swift using Firebase Realtime Database. You can add differ

Nov 26, 2021
The app demonstrates how to use Firebase in a SwiftUI iOS app

Firebase SwiftUIDemo app This app demonstrates how to use Firebase in a SwiftUI iOS app. Firebase Setup Go to firebase.com Click new project. Copy app

Nov 28, 2021
The ToDoList application using FireBase allows you to register users
The ToDoList application using FireBase allows you to register users

ToDoFirebase Приложение ToDoList с использовавнием FireBase позволяет зарегистри

Dec 19, 2021
A detailed clone of the Instagram app built with Firebase
A detailed clone of the Instagram app built with Firebase

[This repository is no longer being maintained] InstagramClone A detailed clone

Dec 26, 2021
Learning App with Firebase Auth
Learning App with Firebase Auth

Learning App Displays how to make a learning app with Swift, iOS's programming l

Jan 9, 2022
Firebase Quickstart Samples for iOS

Firebase Quickstarts for iOS A collection of quickstart samples demonstrating the Firebase APIs on iOS. Each sample contains targets for both Objectiv

May 22, 2022
A SwiftUI component which handles logging in with Apple to Firebase
A SwiftUI component which handles logging in with Apple to Firebase

Login with Apple Firebase SwiftUI I made this SwiftUI component to handle logging in with Apple to Firebase. Demo Gif Usage in SwiftUI struct ContentV

May 17, 2022
Warning pushNotification - Using push notification with Firebase Cloud Messaging

재난문자 푸시 알림 구현 1) 구현 기능 2) 기본 개념 (1) Remote Notification 불시에 발생한 업데이트 불특정 시간 예측 불

Jan 24, 2022
Ready use service for Firebase. Included interface, recored devices and notifications.
Ready use service for Firebase. Included interface, recored devices and notifications.

SPProfiling Ready use service with using Firebase. Included interface, manage auth process, recored devices and profile data. Installation Ready for u

May 13, 2022
IOS mobile application that uses URLSession and Firebase
IOS mobile application that uses URLSession and Firebase

DogApp IOS mobile application that uses URLSession and Firebase. First a dog ima

Feb 13, 2022
An experiment to use Firebase and React Native to build a wwdc.family app
An experiment to use Firebase and React Native to build a wwdc.family app

wwdc.family This is an experiment to use Firebase and React Native to build a wwdc.family app. Don't use that source code as reference - I have no pri

Feb 9, 2022