ignoring duplicate libraries: ‘-lc++’
I noticed a new warning I haven’t seen before.
I found out two solutions from Firebase repository.
-Wl,-ld_classic
First solution is appending ‘-Wl,-ld_classic’ into Other Linker Flags.
It‘s not working. why? Because I appened the flags into my project’s build settings.
When I appended the flags into settings for FirebaseCrashlytics project. The warning was disappeared.
-Xlinker -no_warn_duplicate_libraries
Second solutions is ‘-Xlinker -no_warn_duplicate_libraries’. It is also for same Flags.
Both solutions are working. But if I updates Pods?
I have to append the flags whenever ‘pod update’.
Podfile
To make the settings automatic, I decided to modify Podfile.
Target
First I opened Podfile and appended this block under installer.pods_project.targets.each do |target|
.
if target.name == 'FirebaseCrashlytics'
end
With this block I can find FirebaseCrashlytics project in Pods.
If you don’t have it, add this block before last end
.
post_install do |installer|
installer.pods_project.targets.each do |target|
end
end
Config
Second, append this block inside it.
target.build_configurations.each do |config|
end
So I can find config. This means Project’s configuration.
And add condition to find Debug configuration.
if config.name == 'Debug'
end
OTHER_LDFLAGS
Lastly, append the flags into OTHER_LDFLAGS, which indicate Other Linker Flags
.
config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -Wl,-ld_classic"
Now I can’t see the warning even after updating Pods!
Full Script
post_install do |installer|
installer.pods_project.targets.each do |target|
...
if target.name == 'FirebaseCrashlytics'
target.build_configurations.each do |config|
if config.name == 'Debug'
config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -Wl,-ld_classic"
end
end
end
end
end
If you found this post helpful, please give it a round of applause 👏 and follow me. Explore more iOS-related content in my other posts.