Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Class is implemented in both warnings. #10989

Open
1 task done
zemos opened this issue Oct 7, 2021 · 8 comments
Open
1 task done

Multiple Class is implemented in both warnings. #10989

zemos opened this issue Oct 7, 2021 · 8 comments
Labels
help wanted Help from new or existing contributors would be greatly appreciated!

Comments

@zemos
Copy link

zemos commented Oct 7, 2021

Report

What did you do?

bundle exec pod install

What did you expect to happen?

Install all pod dependencies correctly.

What happened instead?

This issue exists only in Xcode 13. When using Xcode 12, everything works as expected.
When using Xcode 13, I receive multiple warnings stating that various classes are implemented in two places. For example:

objc[4956]: Class BUZipArchive is implemented in both /System/Library/PrivateFrameworks/BookUtility.framework/BookUtility (0x1dd407148) and /private/var/containers/Bundle/Application/BEA3B9C7-0E59-442D-B1D7-B4F7950A490A/JenkinsiOSTest.app/JenkinsiOSTest (0x10532d0b0). One of the two will be used. Which one is undefined.

It also causes a significant increase in build size.
I've noticed that pods modify Pods-Unity-iPhone.*.xcconfig files by adding an entry with OTHER_LDFLAGS and a few others.

This issue doesn't happen when I add use_frameworks! :linkage => :static to Podfile or when I remove duplicate frameworks from OTHER_LDFLAGS section in Pods-Unity-iPhone.*.xcconfig files.

CocoaPods Environment

Stack

   CocoaPods : 1.11.0
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
    RubyGems : 3.0.3
        Host : macOS 11.5.2 (20G95)
       Xcode : 13.0 (13A233)
         Git : git version 2.30.1 (Apple Git-130)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : my-company-podspecs - git - git@bitbucket.orgMyCompany/podspecs.git @ 6edd82a813d9baf4f04ab480d6eda5876d3e596f

               my-company-podspecs-1 - git - My/company/podspecs.git @ 3da0a61867f5df4a8477e763b407cb8f0d0d7902

               cocoapods - git - https://github.com/CocoaPods/Specs.git @ 9131956dadd510f863b18b0f5ec18fea5ca65b64

               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /Users/developer/Projekty/TestProjects/JenkinsTest/Build/vendor/bundle/ruby/2.6.0/bin/pod

Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

Podfile

# File is automatically generated by PodFileGenerator. Any manual changes will be overwritten.
install! 'cocoapods', :warn_for_unused_master_specs_repo => false
source 'our/Specs/Repo.git'
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '10.0'
use_frameworks!

target 'UnityFramework' do
   # Pods for UnityFramework
    pod 'IdfaConsentView', '3.0.9'
    pod 'CORApplicationMetadata', '1.0.0'
    pod 'IronSourceSDK', '7.1.10.0'
    pod 'IronSourceChartboostAdapter', '4.3.8.0'
    pod 'IronSourceFyberAdapter', '4.3.19.0'
    pod 'IronSourceInMobiAdapter', '4.3.12.0'
    pod 'IronSourcePangleAdapter', '4.3.8.0'
    pod 'IronSourceTapjoyAdapter', '4.1.18.0'
    pod 'IronSourceUnityAdsAdapter', '4.3.13.0'
    pod 'IronSourceVungleAdapter', '4.3.13.0'
	
	target 'Unity-iPhone Tests' do
		inherit! :search_paths
		# Pods for testing
	end

end
target 'Unity-iPhone' do

end
@dnkoutso
Copy link
Contributor

dnkoutso commented Oct 7, 2021

Not sure if its entirely cocoapods related but it might be. Would need help to diagnose this

@dnkoutso dnkoutso added the help wanted Help from new or existing contributors would be greatly appreciated! label Oct 7, 2021
@paulb777
Copy link
Member

paulb777 commented Oct 7, 2021

Possibly related to linking a static pod into the dynamic 'UnityFramework'. use_frameworks! :linkage => :static might be a good solution.

@angelolloqui
Copy link
Contributor

angelolloqui commented Nov 29, 2021

We have a similar issue. Our project contains several frameworks with dependencies in them that are shared. After updating from cocoapods 1.10.1 to 1.11.2 we got the same issue. The problem is not only that we have now duplicates, but also that the dependencies do not work as expected. For example, our Firebase Remote Config does not work since there are multiple instances of same classes.

Class FIRAValue is implemented in both /Users/agarcia/Library/Developer/Xcode/DerivedData/playtomic-fnwaopoktlebirdkizvfkwueafsh/Build/Products/Debug (Integration)-iphonesimulator/SocialCommunity.framework/SocialCommunity (0x115db62e0) and /Users/agarcia/Library/Developer/Xcode/DerivedData/playtomic-fnwaopoktlebirdkizvfkwueafsh/Build/Products/Debug (Integration)-iphonesimulator/Paywall.framework/Paywall (0x1112193b0). One of the two will be used. Which one is undefined.

Note that this does not happen with 1.10.1

Our setup is pretty long because we have several micro frameworks and multiple example apps, but let me put the important pieces. The main app is the Playtomic target, we also have some shared frameworks like foundation, sdk, playtomic_ui or mozart, and then we have multiple features in modules like Paywall or SocialCommunity. Here the setup for some of them with the parts related to Firebase:

def sdk_pods
    google_utilites
    pod 'Firebase/Core', $firebase_version
    pod 'Firebase/Database', $firebase_version
    pod 'Firebase/Storage', $firebase_version
    pod 'Firebase/Auth', $firebase_version
   ....
end

def playtomic_ui_pods
....
end

def mozart_pods
  google_utilites
  pod 'Firebase/Messaging', $firebase_version
end

def module_pods
  sdk_pods
  mozart_pods
  playtomic_ui_pods
end

def app_pods
    google_utilites
    pod 'Firebase/Analytics', $firebase_version
    pod 'Firebase/Crashlytics', $firebase_version
    pod 'Firebase/RemoteConfig', $firebase_version
    ....
end

target 'Playtomic' do
  use_frameworks!
  project 'App/App.xcodeproj', 'Debug (Integration)' => :debug, 'Release (Integration)' => :release

  module_pods
  app_pods
  
  target 'Unit Tests' do
    inherit! :search_paths
  end
end

target 'PlaytomicFoundation' do
  use_frameworks! :linkage => :static
  project 'PlaytomicFoundation/PlaytomicFoundation.xcodeproj', 'Debug (Integration)' => :debug, 'Release (Integration)' => :release
  foundation_pods

  target 'PlaytomicFoundationTests'
end

target 'SocialCommunity' do
  use_frameworks!
  project 'Modules/Social/SocialCommunity.xcodeproj', 'Debug (Integration)' => :debug, 'Release (Integration)' => :release
  module_pods
  chart_pod
  target 'SocialCommunityExample'
  target 'SocialCommunityTests'
end

target 'Paywall' do
  use_frameworks!
  project 'Modules/Paywall/Paywall.xcodeproj', 'Debug (Integration)' => :debug, 'Release (Integration)' => :release
  module_pods

  target 'PaywallExample'
  target 'PaywallTests'
end

EDIT: The issue seems to come from the -objc linker flag added. If I get rid of them in my frameworks the error and duplicates are gone. Any idea why that was added? I can not see much info, just a ticket here: #10234 (BTW, I am building with an M1 and Xcode13)

@paulb777
Copy link
Member

@angelolloqui It is problematic to link static frameworks into dynamic frameworks. See a detailed explanation at https://github.com/firebase/firebase-ios-sdk/blob/master/docs/firebase_in_libraries.md.

To link static frameworks into other frameworks with CocoaPods, use_frameworks! :linkage => :static is a good option so that all the frameworks become static, everything gets linked a build time, and duplicates at runtime are prevented.

Regarding #10234, the -ObjC option is required for properly linking Objective C libraries. Otherwise C style linking done and features like Objective C categories may not link.

@cihadturhan
Copy link

@zemos my setup is pretty much similar to yours.
I have a unity project with ironsource adapters and I get tons of warnings like this:

Class _TtC10Foundation13__JSONEncoder is implemented in both 
/usr/lib/swift/libswiftFoundation.dylib (0x1fa136730) 
and /private/var/containers/Bundle/Application/75DC394B-7F31-41A5-82E4-B3F439E78131/xxx.app/Frameworks/libswiftFoundation.dylib (0x1047cdbc8). 
One of the two will be used. Which one is undefined.

I't try use_frameworks with static linkage to see if it changes anything

@cihadturhan
Copy link

Nope, :linkage => :static didn't work at all.
I had the following error:

Error loading /var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/UnityFramework.framework/UnityFramework
  Reason: tried: '/private/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/CB100BC2-1DC8-4C2A-A83F-4618E48F2222/MelodiesRun.app/Frameworks/libswiftCore.dylib' (no such file)

@davilucasg1
Copy link

I have the same error, this happens because both the framework and the application use firebase sdk and generate these conflicts

@Mycose
Copy link

Mycose commented Jan 25, 2023

@angelolloqui I'm having the same issue, did you by any chance suceed to fix it ? :D
The issue is not closed and no more answer :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Help from new or existing contributors would be greatly appreciated!
Projects
None yet
Development

No branches or pull requests

7 participants