firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Unit test - _OBJC_CLASS_$_FIRAnalytics symbol(s) not found for architecture x86_64

Open piotrsmajek opened this issue 2 years ago • 2 comments

Description

I have SPM package with FirebaseAnalytics dependency which is added to app and to other packages which contains unit tests too.

Below my Package.swift of my SPM package.

// 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: "AppAnalytics",
    platforms: [.iOS("14.0")],
    products: [
        .library(
            name: "AppAnalytics",
            targets: ["AppAnalytics"]),
        .library(
            name: "AppAnalyticsMocks",
            targets: ["AppAnalyticsMocks"])
    ],
    dependencies: [
        .package(path: "../Core"),
        .package(path: "../Networking"),
        .package(path: "../PUC"),
        .package(url: "https://github.com/firebase/firebase-ios-sdk.git", exact: Version(10, 7, 0)),
        .package(url: "https://github.com/Quick/Quick", exact: Version(5, 0, 1)),
        .package(url: "https://github.com/Quick/Nimble", exact: Version(10, 0, 0))
    ],
    targets: [
        .target(
            name: "AppAnalytics",
            dependencies: ["Core",
                           "Networking",
                           "PUC",
                           .product(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),
                           .product(name: "FirebasePerformance", package: "firebase-ios-sdk")]),
        .target(
            name: "AppAnalyticsMocks",
            dependencies: ["AppAnalytics"],
            path: "Mocks"),
        .testTarget(
            name: "AppAnalyticsTests",
            dependencies: ["AppAnalytics",
                           "AppAnalyticsMocks",
                           "Quick",
                           "Nimble"])
    ]
)

And when I build app there is no problem, but when I'm building unit test I have error

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FIRAnalytics", referenced from:
      objc-class-ref in AppAnalytics.o
ld: symbol(s) not found for architecture x86_64

Reproducing the issue

No response

Firebase SDK Version

10.7.0

Xcode Version

14.2

Installation Method

Swift Package Manager

Firebase Product(s)

Analytics

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

piotrsmajek avatar Mar 31 '23 09:03 piotrsmajek

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Mar 31 '23 09:03 google-oss-bot

Marking for Firebase 11 to see if it gets addressed by dynamic libraries

paulb777 avatar Aug 08 '23 21:08 paulb777

Hi @piotrsmajek, is this still an issue on Xcode 15? Xcode 15 introduced a new linker. If it still does not work, does adding .product(name: "FirebaseAnalytics", package: "firebase-ios-sdk" as a dependency of the AppAnalyticsTests target fix the undefined symbol error?

ncooke3 avatar Jul 26 '24 21:07 ncooke3

Hey @piotrsmajek. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Aug 02 '24 01:08 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@piotrsmajek if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Aug 08 '24 01:08 google-oss-bot