Linker errors with Firebase Analytics integration in Pod private project
Environment:
- Xcode version: 11.1
- Firebase SDK version: 6.17.0
- Firebase Component: Analytics
- Component version: 6.2.2
- Installation method: CocoaPods
Problem:
I have a private Pod project with the following structure:

This is my Podfile: Podfile.txt
And this is my AgilePlay.podspec: AgilePlay.podspec.txt
With this integration, I can call Firebase from AppDelegate.swift:

And I can call FirebaseAnalytics from another class in my project (SearchViewController.swift) to do the tagging:

The problem is when I want to do the project's build. When I execute in XCode Product > Build, I have the following errors:

I have searched for solutions on Google, and I have checked my configuration as you explain in this issue, but the problem continues. Could you help me with this problem, please?
Thanks so much.
I found a few problems with this issue:
- I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
- This issue does not seem to follow the issue template. Make sure you provide all the required information.
More info about the error:
Undefined symbols for architecture arm64: "OBJC_CLASS$_FIRAnalytics", referenced from: objc-class-ref in SearchViewController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

You can probably remove the preinstall hook in your Podfile and simplify your app dependency structure by not using a custom podspec.
The target that's being linked (most likely AgilePlay.dylib in the Pods project) is missing Firebase Analytics. Make sure you're not doing anything that would prevent Analytics from being linked properly, such as overriding any CocoaPods-generated linker flags or search paths.
It's not possible to tell exactly what's wrong without looking at your project's configuration.
Thank you for your answer @morganchen12 . I don't understand what you mean with "remove the preinstall hook in your Podfile and simplify your app dependency structure by not using a custom podspec". Could you explain it to me with an example?
I have been searching in my project and I can't find any .dylib file.
This is the linker flags configuration for my AgilePlay pod:

If you need any other configuration, please ask me.
Can you share the full build logs?
Of course, @morganchen12 Here you are the most recent build log: Build target AgilePlay_2020-02-26T18-07-11.txt
Here's the linker invocation in question:
Ld /Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AgilePlay/AgilePlay.framework/AgilePlay normal arm64
cd /Users/juanfran/enimbos/agile/rtve_apple_tv/code/agile-play-ios/Example/Pods
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -rpath -Xlinker /usr/lib/swift -target arm64-apple-ios11.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk -L/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AgilePlay -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AgilePlay -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AgilePlayData -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/Alamofire -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AlamofireImage -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AlamofireSwiftyJSON -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/ContentCollection -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/FirebaseCore -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/FirebaseCoreDiagnostics -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/FirebaseInstallations -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/FirebaseInstanceID -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/GSKStretchyHeaderView -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/GoogleDataTransport -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/GoogleDataTransportCCTSupport -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/GoogleUtilities -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/IQKeyboardManagerSwift -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/ItaasClient -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/PaginatedTableView -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/PromisesObjC -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/ReachabilitySwift -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/Realm -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/RealmSwift -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/RxAVFoundation -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/RxAlamofire -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/RxCocoa -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/RxReachability -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/RxSwift -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/SDWebImage -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/StretchyContent -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/SwiftyJSON -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/VGSegment -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/lottie-ios -F/Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/nanopb -F/Users/juanfran/enimbos/agile/rtve_apple_tv/code/agile-play-ios/Example/Pods/FirebaseAnalytics/Frameworks -F/Users/juanfran/enimbos/agile/rtve_apple_tv/code/agile-play-ios/Example/Pods/GoogleAppMeasurement/Frameworks -F/Users/juanfran/enimbos/agile/rtve_apple_tv/code/agile-play-ios/Example/Pods/google-cast-sdk/GoogleCastSDK-ios-4.2.0 -filelist /Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/AgilePlay.build/Objects-normal/arm64/AgilePlay.LinkFileList -install_name @rpath/AgilePlay.framework/AgilePlay -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/AgilePlay.build/Objects-normal/arm64/AgilePlay_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/AgilePlay.build/Objects-normal/arm64/AgilePlay.swiftmodule -framework AVFoundation -framework Accelerate -framework AudioToolbox -framework CFNetwork -framework CoreBluetooth -framework CoreGraphics -framework CoreMedia -framework CoreText -framework Foundation -framework GoogleCast -framework MediaAccessibility -framework MediaPlayer -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -framework UIKit -framework AgilePlayData -framework AlamofireImage -framework ContentCollection -framework Foundation -framework GSKStretchyHeaderView -framework IQKeyboardManagerSwift -framework ItaasClient -framework Lottie -framework PaginatedTableView -framework RealmSwift -framework RxAVFoundation -framework RxCocoa -framework RxReachability -framework StretchyContent -framework VGSegment -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/AgilePlay.build/Objects-normal/arm64/AgilePlay_dependency_info.dat -o /Users/juanfran/Library/Developer/Xcode/DerivedData/AgilePlay-empdliwsovxuihdqpurllsirvwww/Build/Products/Debug-iphoneos/AgilePlay/AgilePlay.framework/AgilePlay
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRAnalytics", referenced from:
objc-class-ref in SearchViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Looks like you're trying to use Firebase as a dependency of a dynamic library pod, which is not supported. Try setting the static_framework flag to true in your custom Podfile.
Thanks so much, @morganchen12 , I have modified my podspec file for AgilePlay. This is the new podspec file: AgilePlay.podspec.txt
Now the build works fine, but if I look at the configuration of the AgilePlay pod now no associated framework appears:
What causes errors in other applications when I use this pod as a dependency in those applications.
This was the scenario with all the frameworks associated with the AgilePlay pod:
Could you tell me if it is possible to add the frameworks back to the AgilePlay pod? Thanks in advance.
You need to add all of the static dependencies into each app target that the framework is linked into. Normally CocoaPods will do this automatically for you.
@morganchen12 thanks for the replay. I added the frameworks as detailed in the following link: http://docs.onemobilesdk.aol.com/ios-ad-sdk/adding-frameworks-xcode.html But I have the same errors as if I didn't associate them. Also, when I run pod install in my AgilePlay Pod, the frameworks are removed. Do you know any other way to associate the frameworks with my AgilePlay pod?
Can you share the new errors?
Hey @jframosg. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 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!
Finally, I did not have to do the Firebase integration with my private pod. Thank you very much for your help, @morganchen12 !!