Run the app
The app to run without console warnings about multiple classes.
Console warnings of the type
class AFAutoPurgingImageCache is implemented in both /Users/david/Library/Developer/Xcode/DerivedData/PodsDynamicLibTest-gidixodenwoqttcqkxresgoadfkg/Build/Products/Debug-iphonesimulator/Framework.framework/Framework (0x102eaac58) and /Users/david/Library/Developer/CoreSimulator/Devices/8ED2F0F1-37B0-4BE2-8427-B4D70DEE1A2D/data/Containers/Bundle/Application/0868D1B5-9454-4F07-8CDE-5218F53901A8/App.app/App (0x101f9f050). One of the two will be used. Which one is undefined.
CocoaPods : 1.3.1
Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
RubyGems : 2.6.11
Host : Mac OS X 10.12.6 (16G29)
Xcode : 9.1 (9B46)
Git : git version 2.10.1
Ruby lib dir : /usr/local/Cellar/ruby/2.4.1_1/lib
Repositories : helpshift - https://github.com/helpshift/CocoaPods.git @ f32e7f82986f8df58f5cbb30421a8548eb222b21
master - https://github.com/CocoaPods/Specs.git @ bc25b40465df84e6645d99b0c606ac7b102e2eda
tophatch - https://github.com/tophatch/SpecsRepo.git @ 778d9226d877dd3ffa3ccae9d8baa7c8cb1db278
Executable Path: /usr/local/bin/pod
cocoapods-clean : 0.0.1
cocoapods-deintegrate : 1.0.1
cocoapods-dependencies : 1.0.0
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.2.0
cocoapods-try : 1.1.0
source 'https://github.com/CocoaPods/Specs.git'
workspace 'PodsDynamicLibTest.xcworkspace'
target 'Framework' do
platform :ios, '11.0'
project 'App/App.xcodeproj'
pod 'AFNetworking', '~> 3.0'
end
target 'App' do
platform :ios, '11.0'
project 'App/App.xcodeproj'
pod 'DateTools'
end
https://github.com/tophatch/CocoapodsDuplicateSymbolTestProject
The issue occurs when the two targets are embedded in the same parent project. If the targets are in different projects then it does not occur.
This was not an issue in cocoapods 1.2, it was introduced in 1.3.
If you look at https://github.com/tophatch/CocoapodsDuplicateSymbolTestProject/blob/master/Pods/Target%20Support%20Files/Pods-App/Pods-App.debug.xcconfig
you will see that OTHER_LDFLAGS includes -l"AFNetworking"
I think it should not be included.
This was actually introduced in 1.2.1. Perhaps with #6481?
It does seem wrong for the App to link in -l"AFNetworking"
, but it also seems a bit strange to want to link a dynamic framework but not include use_frameworks!
in the Podfile. Adding use_frameworks!
will also eliminate the warnings.
My understanding is that use_frameworks!
causes dynamic frameworks to be used for each pod that are dependencies, is that correct? If so, then this has a performance impact on start-up. The desired behavior is to statically link all of the pods into the single dynamic framework.
Yes, use_frameworks!
causes a dynamic framework for each dependency pod.
What's the reason for one dynamic framework versus linking everything statically?
In our case we have multiple app extensions that share a common core with the main app.
Understood, thanks.
It does look related to #6481.
The -l"AFNetworking"
gets removed and the warnings go away with the following coarse-grained change:
$ git diff
diff --git a/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb b/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb
index 22fc4d20..84ea4439 100644
--- a/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb
+++ b/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb
@@ -461,8 +461,8 @@ module Pod
other_ld_flags = pod_targets.select(&:should_build?).map do |pod_target|
if pod_target.requires_frameworks?
%(-framework "#{pod_target.product_basename}")
- elsif XCConfigHelper.links_dependency?(aggregate_target, pod_target)
- %(-l "#{pod_target.product_basename}")
+ # elsif XCConfigHelper.links_dependency?(aggregate_target, pod_target)
+ # %(-l "#{pod_target.product_basename}")
end
end
xcconfig.merge!('OTHER_LDFLAGS' => other_ld_flags.compact.join(' '))
Any thoughts @dnkoutso?
This was mostly an issue fix in which Cocoapods links the same dependency for both test bundles and app targets.
Theoretically dynamic frameworks can link dependencies and the app target should not link them but the cocoapods model since the beginning is that all dependencies are linked to the app (host) target instead.
There is a chance this can be fixed by a smaller change but I think we need a bigger plan in which dynamic frameworks actually link their dependencies.
If a dependency is linked and added to the app target then it should not be linked to the test target. That was the initial fix with links_dependency?
as i recalled correctly and I think it was part of 1.2.0 release.
Is issue something that will likely be fixed? Is there anything I can do to help?
Its fairly complicated issue, I think the entire system with embedding targets is fairly broken at the moment, everything is assumed to be linking to the top level target.
I think a general overhaul of this linking mechanism is required.
The other issue I had mentioned earlier is double linking dependencies on test bundles and app targets which 1.3.x fixes. We should not be linking dependencies to a test bundle if the app already brings that dependencies otherwise you get multiple warnings around class loading.
The problem is that to use app extensions projects need to be split up into multiple frameworks/layers (ie: at least a core one that can be consumed from both the main app and the respective app extensions), however at runtime certain 3rd party libraries will fail (for example GoogleMaps) because they try to access static variables and the static values seem not to be shared across framework. In other words there will be different versions of the class definition at runtime. This is a huge problem – the impact being that shared code that uses any sort of class/static variable cannot inter-operate across the app frameworks!
Posting the workaround that I'm currently using in case it's helpful to anyone. This workaround uses the pre_install
hook to remove duplicate dependencies. The issue occurs in the analyzer which runs before the pre_install
hook. So you only have to change one thing if you make the change there. Using the example from https://github.com/CocoaPods/CocoaPods/issues/7155#issue-267398054, add the following to your Podfile
.
pre_install do |installer|
embedded_target = installer.aggregate_targets.find { |aggregate_target| aggregate_target.name == 'Pods-Framework' }
host_target = installer.aggregate_targets.find { |aggregate_target| aggregate_target.name == 'Pods-App' }
host_target.pod_targets = host_target.pod_targets - embedded_target.pod_targets
end
From what I can tell, this issue was first introduced in https://github.com/CocoaPods/CocoaPods/pull/6575 and first released as v1.2.1.
Please let me know if you notice any potential issues with my workaround.
Related issues:
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:
This problem still exists in cocoapods-1.5.3
@combinatorial have you found any solution to this?
No I have not.
@combinatorial Looks like long time Google search, I found a solution on my case similar to this. This may not apply to your case.
Previously, I received multiple target error messages (One of the two will be used. Which one is undefined.
) and crashed from test. I had two targets (App and App Test), used pod version 1.5.2
and some said remove OTHER_LDFLAGS
from Pods-[AppName].debug.xcconfig
which worked for me. (HERE) But I believe it doesn't seem right things to do, especially each time updating pods. So here is what I tried.
1) Go to project setting select target;In my case App Test Unit Test.
2) Build Settings->Other Linker Flags;It had listed all the frameworks from Cocoapods (which I believe already ported on App Host Project Target)
3) Remove the duplicate lists, from release candidates (Debug and/or Release);In My case I left only -ObjC
and -all_load
.
4) Try to update the pod by pod update
5) It will still include OTHER_LDFLAGS
, but no more complain about duplicate warnings on runtime
is There any concrete workaround to Fix this problem?
@mehdok https://stackoverflow.com/a/52773670/2446684 Hope this can help you.
I am having the same issue . I installed Parse with cocoa pods, and this is the errors i get:
objc[2025]: Class PFFile is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PhotoFoundation.framework/PhotoFoundation (0x11a97f590) and /Users/Nacire/Library/Developer/CoreSimulator/Devices/2520711E-A844-4531-ABE9-2DFF4D393685/data/Containers/Bundle/Application/053ECEDB-B4AD-4BAE-B429-BD1CFF1A348B/wildMarket.app/Frameworks/Parse.framework/Parse (0x10230b9a0). One of the two will be used. Which one is undefined.
objc[2025]: Class PFLogger is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PhotoFoundation.framework/PhotoFoundation (0x11a980300) and /Users/Nacire/Library/Developer/CoreSimulator/Devices/2520711E-A844-4531-ABE9-2DFF4D393685/data/Containers/Bundle/Application/053ECEDB-B4AD-4BAE-B429-BD1CFF1A348B/wildMarket.app/Frameworks/Parse.framework/Parse (0x10230bf90). One of the two will be used. Which one is undefined.
failed
Can someone help me fix this please??
Seeing these warnings with the PayPalHere SDK https://github.com/paypal/paypal-here-sdk-ios-distribution pods.
Its fairly complicated issue, I think the entire system with embedding targets is fairly broken at the moment, everything is assumed to be linking to the top level target.
I think a general overhaul of this linking mechanism is required.
So no change with this for over a year now? @dnkoutso Is this an actual issue or can I just ignore these warnings? I'm assuming it's the same class linked in either way - but static variables do seem to be a concern here, you don't want 2 copies of those!
@pnemere It is dangerous to build with the duplicate warnings. I recommend using one of the workarounds discussed above until there is a more general CocoaPods fix.
@paulb777 should this be re-opened?
@amorde Yes I confirmed the original test case still fails on current master.
I have the same issue with TwitterKit:
objc[399]: Class TWTRAppAuthProvider is implemented in both /private/var/containers/Bundle/Application/E78E176F-18D0-4441-BB75-E1F3930A03FB/Minimai.app/Frameworks/TwitterKit.framework/TwitterKit (0x104f214b8) and /private/var/containers/Bundle/Application/E78E176F-18D0-4441-BB75-E1F3930A03FB/Minimai.app/Frameworks/TwitterCore.framework/TwitterCore (0x104c56308). One of the two will be used. Which one is undefined.
Same issue with Firebase (over 80 warnings total), one of them:
objc[30258]: Class FIRAnalytics is implemented in both /Users/toyo/Library/Developer/Xcode/DerivedData/Satellite-grzchbsyocupipepoepufwotlxnr/Build/Products/Debug-iphonesimulator/SatelliteSDK.framework/SatelliteSDK (0x101fa27b8) and /Users/toyo/Library/Developer/CoreSimulator/Devices/1B4ADD06-344B-4A61-A82B-2EF8F25184A7/data/Containers/Bundle/Application/5DC93E04-7FA3-4199-ADC2-A483ED19FB12/Satellite.app/Satellite (0x1008f7170). One of the two will be used. Which one is undefined.
Any update on this. Getting the same errors for Fabric, BrainTree and Flurry
PROJECT_ROOT_DIR = File.dirname(File.expand_path(__FILE__))
PODS_DIR = File.join(PROJECT_ROOT_DIR, 'Pods')
PODS_TARGET_SUPPORT_FILES_DIR = File.join(PODS_DIR, 'Target Support Files')
post_install do |installer|
remove_static_framework_duplicate_linkage({
'SharedFramework' => ['Fabric', 'Crashlytics', 'GoogleMaps', 'GoogleSignIn', 'GooglePlaces']
})
end
# CocoaPods provides the abstract_target mechanism for sharing dependencies between distinct targets.
# However, due to the complexity of our project and use of shared frameworks, we cannot simply bundle everything under
# a single abstract_target. Using a pod in a shared framework target and an app target will cause CocoaPods to generate
# a build configuration that links the pod's frameworks with both targets. This is not an issue with dynamic frameworks,
# as the linker is smart enough to avoid duplicate linkage at runtime. Yet for static frameworks the linkage happens at
# build time, thus when the shared framework target and app target are combined to form an executable, the static
# framework will reside within multiple distinct address spaces. The end result is duplicated symbols, and global
# variables that are confined to each target's address space, i.e not truly global within the app's address space.
#
# Previously we avoided this by linking the static framework with a single target using an abstract_target, and then
# provided a shim to expose their interfaces to other targets. The new approach implemented here removes the need for
# shim by modifying the build configuration generated by CocoaPods to restrict linkage to a single target.
def remove_static_framework_duplicate_linkage(static_framework_pods)
puts "Removing duplicate linkage of static frameworks"
Dir.glob(File.join(PODS_TARGET_SUPPORT_FILES_DIR, "Pods-*")).each do |path|
pod_target = path.split('-', -1).last
static_framework_pods.each do |target, pods|
next if pod_target == target
frameworks = pods.map { |pod| identify_frameworks(pod) }.flatten
Dir.glob(File.join(path, "*.xcconfig")).each do |xcconfig|
lines = File.readlines(xcconfig)
if other_ldflags_index = lines.find_index { |l| l.start_with?('OTHER_LDFLAGS') }
other_ldflags = lines[other_ldflags_index]
frameworks.each do |framework|
other_ldflags.gsub!("-framework \"#{framework}\"", '')
end
File.open(xcconfig, 'w') do |fd|
fd.write(lines.join)
end
end
end
end
end
end
def identify_frameworks(pod)
frameworks = Dir.glob(File.join(PODS_DIR, pod, "**/*.framework")).map { |path| File.basename(path) }
if frameworks.any?
return frameworks.map { |f| f.split('.framework').first }
end
return pod
end
Where should I paste in this snippet? In my podfile?
@Yetispapa yes, you also need to change the call to remove_static_framework_duplicate_linkage
to match your project configuration.
I tried the code but I got an error on the identify_framework line. I just put the snippet below my framework list. Is that right? Can you give me an simple example how the pod file should look like. Thanks
Sent with GitHawk
@Yetispapa I have the same. @ileitch could you please add identify_frameworks
function?
@Yetispapa @astrokin Oops, updated with identify_frameworks
.
We're currently facing this issue, used the solution from @ileitch which worked good.
Is there any official workaround/fix planned in future Cocoapods releases?
@jakunico The solution from @ileitch doesn't work for me. I get:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GIDSignIn", referenced from:
objc-class-ref in GoogleLogin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have a non-cocoapods framework in an app. I have included the pod in both (GoogleSignIn). Without the code it runs with a duplicate framework. With the extra Podfile code, it won't compile.
$ pod --version
1.7.0.rc.1
Edit: This workaround did work for me though: https://stackoverflow.com/a/47977680/1174766
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
I've seen a fair number of workarounds for this on the app-side (adding stuff to Podfile) around the web, but does anyone know of any way to configure the dynamic framework such that devs who install via Cocoapods won't see these warnings?
Does latest version fix this issue?
This kind of warnings will make singleton not working.
We made the subprojects static libs to avoid this problem.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
But this issue isn’t resolved yet
Does anybody of the contributors know, it this is on track to be included in 1.9.0 ?
It's not - if this is an issue for you I'd encourage you to contribute 👍
1.9.0 beta is wrapping up soon so I don't think this would make it in to that release.
I am using Xcode 11.3 with cocoapods 1.9.1 (latest). I am still facing this issue when I do Product -> Archive. This error only happen during archiving and it works fine during Running,Testing.
Multiple targets match implicit dependency for linker flags '-framework Parse'. Consider adding an explicit dependency on the intended target to resolve this ambiguity. (in target 'App1' from project 'App1')
I found a workaround for this but this is cumbersome because I need to run pod install to switch compilation for Testing vs Archiving.
target 'App1' do
...
pod 'Parse', '1.17.3'
end
target 'App1Test' do
...
pod 'Parse', '1.17.3'
end
I used the work around suggested by Huang Diaobo in stack overflow
target 'App1' do
...
pod 'Parse', '1.17.3'
end
schema = ENV['schema']
if schema == 'UnitTest'
target 'App1Test' do
pod 'Parse', '1.17.3'
end
end
With the above, I need to switch the pod install whenever I build for test vs build for archive.
1) For UnitTest: export schema='UnitTest' && pod install
2) For Archiving: unset schema && pod install
The issue still exist
This issue still exists and above solutions are not helping. Could we do something about it? It is a big problem when we want to modularize the project into frameworks. Thanks for all hard work
I'm also facing the same issue.
System
MacOS Catalina 10.15.3
Xcode: 11.4.1
Cocoapods : 1.9.1
Podfile defination
platform :ios, '10.0'
def shared_pods
pod 'Firebase/Messaging'
end
target 'MainTarget' do
use_frameworks!
pod 'Moya', '~> 14.0'
shared_pods
pod 'Firebase/Auth'
pod 'Firebase/Analytics'
pod 'Firebase/Database'
pod 'Firebase/Crashlytics'
pod 'GoogleSignIn'
pod 'FBSDKLoginKit'
end
target 'NotificationService' do
use_frameworks!
shared_pods
end
Warning
I'm using multiple Firebase pods in MainTarget. And in an app extension target using pod 'Firebase/Messaging'. Getting warning : "Multiple target match implicit dependency for linker flag -framework GoogleUtilities"
for both targets. However running in simulator works fine.
Error
While archiving the project I'm getting error Multiple command produce ...
. Can not archive the project
Workaround
For now this blog helped me to remove duplicity https://qiita.com/sowtara/items/67d42f8ee8e413260ddc
Closed but the bug is still present in CocoaPods 1.9.3.
Hello
I have a same problem, but only with GoogleMaps
pod. I downgrade CocoaPods to 1.9.2 version, but problem actual.
My pod file:
platform :ios, '10.0'
use_frameworks!
inhibit_all_warnings!
source 'https://github.com/CocoaPods/Specs.git'
def shared_pods
# pod 'Kingfisher'
# pod 'GoogleMaps'
pod 'Fabric'
pod 'Crashlytics'
pod 'SVProgressHUD'
pod 'IQKeyboardManagerSwift'
pod 'VoxImplantSDK'
pod 'Firebase/Core'
pod 'AppsFlyerFramework'
pod 'Moya'
# pod 'ObjectMapper'
# pod 'SnapKit'
end
abstract_target 'defaults' do
# main
target 'MainTarget' do
shared_pods
end
target 'MainTarget-dev' do
shared_pods
pod 'EnvironmentSwitcher'
end
# modules
target 'LiteOverlayView' do
pod 'SnapKit'
end
target 'LiteRoundedButton' do
pod 'SnapKit'
end
target 'LiteExtensions' do
pod 'Kingfisher'
pod 'GoogleMaps'
pod 'ObjectMapper'
end
end
In pod file MainTarget
and MainTarget-dev
is usual targets, other Lite*
targets - inner is frameworks
And on run in console I see:
objc[4688]: Class GMSMapsClearcutClient is implemented in both /private/var/containers/Bundle/Application/2F37632C-EE38-448F-94F6-B8FF29EED7C5/lite.app/Frameworks/LiteExtensions.framework/LiteExtensions (0x10485c5d8) and /private/var/containers/Bundle/Application/2F37632C-EE38-448F-94F6-B8FF29EED7C5/lite.app/lite (0x101b51a28). One of the two will be used. Which one is undefined.
objc[4688]: Class GMSAPIClientParameters is implemented in both /private/var/containers/Bundle/Application/2F37632C-EE38-448F-94F6-B8FF29EED7C5/lite.app/Frameworks/LiteExtensions.framework/LiteExtensions (0x10485c628) and /private/var/containers/Bundle/Application/2F37632C-EE38-448F-94F6-B8FF29EED7C5/lite.app/lite (0x101b51a78). One of the two will be used. Which one is undefined.
....
And it is only with GoogleMaps
pod. Others (SnapKit
and ObjectMapper
) dont have classes, which implemented in both
.
After display maps on view controller, I have runtime crash.
I see and try remove GoogleMaps
manually from Build settings from Other Linker Flags
and Other C Flags
, but is dont works.
How I can fix this duplication or maybe downgrade to CocoaPods version?
This is still incredibly broken with Firebase, but the following workaround from @TadeasKriz works for me: https://github.com/CocoaPods/CocoaPods/issues/7126#issuecomment-399395611
Hi!
Has anyone been able to fix this without the use of a post_install
script?
I am trying to distribute a dynamic framework without the need for the user to add a script.
Any way to solve this on the podspec?
Most helpful comment
The problem is that to use app extensions projects need to be split up into multiple frameworks/layers (ie: at least a core one that can be consumed from both the main app and the respective app extensions), however at runtime certain 3rd party libraries will fail (for example GoogleMaps) because they try to access static variables and the static values seem not to be shared across framework. In other words there will be different versions of the class definition at runtime. This is a huge problem – the impact being that shared code that uses any sort of class/static variable cannot inter-operate across the app frameworks!