I have no issue in adding Firebase Crashlytics into main app via File -> Add Package Dependencies...
However, how about adding it to Package library?
I have a Package library, which contains shared code for multiple extensions.
I try to edit its Package.swift
to
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "lib",
platforms: [.iOS(.v15)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "lib",
targets: ["lib"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/onevcat/Kingfisher.git", exact: "7.6.2"),
.package(url: "https://github.com/firebase/firebase-ios-sdk", exact: "9.6.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "lib",
dependencies: ["Kingfisher", "firebase-ios-sdk"]),
.testTarget(
name: "libTests",
dependencies: ["lib"]),
]
)
But, my package library still not able to recognise the code
import FirebaseCrashlytics
May I know how I can resolve this?
Thank you.
Your targets
target
dependencies
should look more like
.target(
name: "lib",
dependencies: [
.product(name:"FirebaseCrashlytics", package:"firebase-ios-sdk"),
.product(name:"Kingfisher", package: "Kingfisher")
]
),
With the product
being the specific part of Firebase that you want to use.
It is the equivalent of the screen you see after you click on "Add Package" from your first image.