Варианты установки Firebase в ваше приложение Apple

Swift Package Manager

Firebase recommends Swift Package Manager for new projects.

Через Xcode

Swift Package Manager support requires 26.2 or higher.

  1. If migrating from a CocoaPods-based project, run pod deintegrate to remove CocoaPods from your Xcode project. The CocoaPods-generated .xcworkspace file can safely be deleted afterward. If you're adding Firebase to a project for the first time, this step can be ignored.

  2. In Xcode, install the Firebase libraries by navigating to File > Add Packages .

  3. In the prompt that appears, select the Firebase GitHub repository:

    https://github.com/firebase/firebase-ios-sdk.git
    
  4. Select the version of Firebase you want to use. For new projects, we recommend using the newest version of Firebase.

  5. Choose the Firebase libraries you want to include in your app.

Once you're finished, Xcode will begin resolving your package dependencies and downloading them in the background.

Через Package.swift

To integrate Firebase to a Swift package via a Package.swift manifest, you can add Firebase to the dependencies array of your package. For more details, see the Swift Package Manager documentation .

dependencies: [

  .package(name: "Firebase",
           url: "https://github.com/firebase/firebase-ios-sdk.git",
           from: "8.0"),
  // ...

],

Then in any target that depends on a Firebase product, add it to the dependencies array of that target.

.target(
  name: "MyTargetName",
  dependencies: [
    .product(name: "FirebaseAuth", package: "Firebase"),
    // ...
  ]
),

Особенности, специфичные для конкретного продукта

Some Firebase products require extra integration steps in order to function correctly.

Google Analytics

Google Analytics requires adding the -ObjC linker flag to your target's build settings if included transitively.

Crashlytics

Для работы Crashlytics требуется загрузка отладочных символов.

You can use a run script build phase for Xcode to automatically upload debug symbols post-build. Find the run script here:

${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run

Another option for uploading symbols is to use the upload-symbols script. Place the script in a subdirectory of your project file (for example scripts/upload-symbols ), then make sure that the script is executable:

chmod +x scripts/upload-symbols

This script can be used to manually upload dSYM files. For usage notes and additional instructions for the script, run upload-symbols without any parameters.

CocoaPods

Firebase supports installation with CocoaPods in addition to Swift Package Manager.

Firebase's CocoaPods distribution requires Xcode 26.2 and CocoaPods 1.12.0 or higher. Here's how to install Firebase using CocoaPods:

  1. Create a Podfile if you don't already have one. From the root of your project directory, run the following command:

    pod init
  2. To your Podfile, add the Firebase pods that you want to use in your app.

    You can add any of the supported Firebase products to your app.

    Analytics включена

    # Add the Firebase pod for Google Analytics
    pod 'FirebaseAnalytics'
    
    # For Analytics without IDFA collection capability, use this pod instead
    # pod FirebaseAnalytics/Core
    
    # Add the pods for any other Firebase products you want to use in your app
    # For example, to use Firebase Authentication and Cloud Firestore
    pod 'FirebaseAuth'
    pod 'FirebaseFirestore'

    Learn more about IDFA, the device-level advertising identifier, in Apple's User Privacy and Data Use and App Tracking Transparency documentation.

    Analytics отключена

    # Add the pods for the Firebase products you want to use in your app
    # For example, to use Firebase Authentication and Cloud Firestore
    pod 'FirebaseAuth'
    pod 'FirebaseFirestore'
  3. Установите модули, затем откройте файл .xcworkspace , чтобы увидеть проект в Xcode:

    pod install --repo-update
    open your-project.xcworkspace

Особенности, специфичные для конкретного продукта

Some Firebase products require extra integration steps in order to function correctly.

Crashlytics

Для работы Crashlytics требуется загрузка отладочных символов.

В Xcode можно использовать этап сборки с помощью скрипта запуска, чтобы автоматически загружать отладочные символы после сборки. Скрипт запуска можно найти здесь:

"${PODS_ROOT}/FirebaseCrashlytics/run"

Карфаген

Поддержка Carthage находится на экспериментальной стадии. Инструкции по подключению Firebase к вашему приложению через Carthage см. на GitHub .

Интегрировать вручную

Firebase provides a pre-built binary XCFramework distribution for users who want to integrate Firebase without using a dependency manager. To install Firebase:

  1. Загрузите архив SDK фреймворка . Этот файл содержит архитектурные фрагменты для всех доступных целевых архитектур для всех SDK Firebase, поэтому его загрузка может занять некоторое время.

  2. Распакуйте файл, затем ознакомьтесь с README , чтобы найти фреймворки, которые вы хотите включить в свое приложение.

  3. Добавьте флаг компоновщика -ObjC в Other Linker Settings в параметрах сборки вашей целевой системы.