The integration of Firebase and Google Swift Packages, which Swift turns into Xcode targets, causes compilation warnings and runtime issues like the one described below. I’m creating this discussion to better understand:
Why those issues happen.
What can users do about them?
What Tuist could do to smooth the integration.
I’m looping @marekfort into the conversations since he’s been working a lot with those dependencies lately.
View in #support on Slack
@Derian_Cordoba : Hey everyone, I’m having an issue with Firebase
, specifically with FirebaseCore / FirebaseCoreInternal
, I’m creating an authentication module as dynamic framework to reuse in different targets but when I add the Firebase Authentication
module in my dynamic framework, when I run the app, I get the following error message:
Ld /Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Products/Debug-iphonesimulator/FirebaseCore/FirebaseCore.framework/FirebaseCore normal (in target 'FirebaseCore' from project 'Firebase')
cd /Users/deriancordoba/Developer/personal/MyApp/Tuist/.build/tuist-derived/Firebase
/Applications/Xcode-16.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios12.0-simulator -dynamiclib -isysroot /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk -O0 -L/Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Products/Debug-iphonesimulator/FirebaseCore -F/Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Products/Debug-iphonesimulator/FirebaseCore -F/Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Products/Debug-iphonesimulator -filelist /Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Intermediates.noindex/Firebase.build/Debug-iphonesimulator/FirebaseCore.build/Objects-normal/arm64/FirebaseCore.LinkFileList -install_name @rpath/FirebaseCore.framework/FirebaseCore -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Intermediates.noindex/Firebase.build/Debug-iphonesimulator/FirebaseCore.build/Objects-normal/arm64/FirebaseCore_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -framework UIKit -framework Firebase -framework FirebaseCoreInternal -framework GoogleUtilities_Environment -framework GoogleUtilities_Logger -framework GoogleUtilities_NSData -Xlinker -no_adhoc_codesign -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Intermediates.noindex/Firebase.build/Debug-iphonesimulator/FirebaseCore.build/Objects-normal/arm64/FirebaseCore_dependency_info.dat -o /Users/deriancordoba/Library/Developer/Xcode/DerivedData/MyApp-colypuqgicrelsfcbdrmomsvpavu/Build/Products/Debug-iphonesimulator/FirebaseCore/FirebaseCore.framework/FirebaseCore
ld: warning: Could not find or use auto-linked library 'swiftCompatibility56': library 'swiftCompatibility56' not found
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityConcurrency': library 'swiftCompatibilityConcurrency' not found
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityPacks': library 'swiftCompatibilityPacks' not found
Undefined symbols for architecture arm64:
"__swift_FORCE_LOAD_$_swiftCompatibility56", referenced from:
__swift_FORCE_LOAD_$_swiftCompatibility56_$_FirebaseCoreInternal in FirebaseCoreInternal[3](Heartbeat.o)
"__swift_FORCE_LOAD_$_swiftCompatibilityConcurrency", referenced from:
__swift_FORCE_LOAD_$_swiftCompatibilityConcurrency_$_FirebaseCoreInternal in FirebaseCoreInternal[3](Heartbeat.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 see my frameworks distribution in the attached images.
Also, I had the objc
flag in my project settings:
"OTHER_LDFLAGS": ["-ObjC"],
I think this issue maybe resolved if I move the Firebase Authentication directly in my app target. If you know about a solution to address this issue it will be awesome, thanks.
I found a solution updating the Authentication
framework from dynamic framework
to staticFramework
.
I tested importing the Authentication
target in my App target and importing the another dynamic framework in the Authentication
target.
@Igor_Katselenbogen : Hi Derian and others!
Could please someone help and give some hints and directions about Firebase and Tuist integration?
What is the reason of so many frequent problems? How to understand the situation better?
Currently, I also struggle with Firebase Auth integration. It randomly crashes sometimes on some devices for no obvious reason. It is also hard to replicate.
Usually whenever I need to integrate a new module from Firebase it is a hell and it takes crazy time to crack the correct permutation of static/dynamic frameworks to make it work.
What is the right way to address this problem in more complete way? Thanks!
I guess the points are:
• The main target and the targets relying on firebase have to have -objC liner flag.
• Firebase targets should be marked as static? ( )
• Targets that rely on the Firebase should be dynamic? ( )
What are your opinion on that?
I resolved the issue by changing my custom Authentication
framework from dynamic to static, which allowed me to correctly link Firebase dependencies with it. I also ensured that both FirebaseCore
and FirebaseCoreInternal
remain static when configured in the Package.swift
file. This is important because if we configure these dependencies as a dynamic framework, issues arise with Firebase’s internal dependencies.
We can see it as follows:
FirebaseAuthentication -> Custom Static framework -> App
In addition, we can use some dynamic framework in the static frameworks if needed.
[FirebaseAuthentication, Custom dynamic framework] -> Custom Static framework -> App
I think it would be a good idea to analyze Firebase dependencies more thoroughly since, due to the large amount of Objective-C code, we could try to create a more viable path for implementing it with Tuist or at least streamline it.