Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix duplication error of GoogleUtilities Swift?

I am using firebase for tracking crashes in my project and i am using the below pods in my project.

 pod 'FirebaseCore', '6.6.4'
 pod 'FirebaseMessaging', '4.3.0'
 pod 'FirebaseAnalytics','6.3.1'

While archieving this project for placing the testflight build, i am getting duplication error below for google utilities :

 Multiple commands produce '/Path/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework':
 1) Target 'GoogleUtilities-00567490' has create directory command with output '/Path//IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
 2) Target 'GoogleUtilities-54e75ca4' has create directory command with output '/Path//IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'

When I checked my Pods settings in my build setting, I saw google utilities added twice in project. I have removed the one of the GoogleUtilities it's getting an error.

Note: I can able to run the build and I can't able to archive it. Is there any fix for achieving this build, without changing the legacy build system?

Because I have enabled the library distribution for my SDK, so when I made changes into legacy its throws an error.

like image 392
HariKarthick Avatar asked Apr 03 '20 16:04

HariKarthick


People also ask

What is GoogleUtilities?

GoogleUtilities provides a set of utilities for Firebase and other Google SDKs for Apple platform development. The utilities are not directly supported for non-Google library usage.

What is Use_modular_headers?

The use_modular_headers option generates module maps for Swift and Objective-C pods instead of generating frameworks. See http://blog.cocoapods.org/CocoaPods-1.5.0/ Attached is an example project (AppCode 2018.1, Xcode 9.3, Swift 4.1)


3 Answers

Update the Podfile to explicitly request all the needed GoogleUtilties subspecs. Examine the Podfile.lock to find the list.

There is a lot more detail at this CocoaPods issue.

like image 100
Paul Beusterien Avatar answered Oct 16 '22 09:10

Paul Beusterien


This issue occurred to me when i added a new target to my project using very similar but not equal firebase dependencies, so GoogleUtilities was duplicated because my other target doesn't need as much dependencies from utilities as the main one so, basically (with the help of Paul Beusterien answer) went to the Pods project and look at both targets (GoogleUtilities-xxx) -> Build Phases -> Compile Sources and look at the differences in files added, basically in the new target was missing 'GoogleUtilities/UserDefaults' and 'GoogleUtilities/MethodSwizzler' but this can be different in any case, so i just did a compilation like this

platform :ios, '13.0'

def google_utilites
  pod 'GoogleUtilities/AppDelegateSwizzler'
  pod 'GoogleUtilities/Environment'
  pod 'GoogleUtilities/Logger'
  pod 'GoogleUtilities/MethodSwizzler'
  pod 'GoogleUtilities/NSData+zlib'
  pod 'GoogleUtilities/Network'
  pod 'GoogleUtilities/Reachability'
  pod 'GoogleUtilities/UserDefaults'
end

abstract_target 'AggregatedPodsTarget' do
  use_frameworks!

  google_utilites
  
  pod 'FirebaseCore'
  pod 'FirebaseAuth'
  pod 'FirebaseFirestore'
  pod 'FirebaseStorage'
  pod 'FirebaseFunctions'
  pod 'FirebaseAnalytics'
  pod 'FirebaseMessaging'
  pod 'Firebase/Crashlytics'
  
  pod 'Google-Mobile-Ads-SDK'


  
  target 'MainApp' do
  end
  
  target 'MainApp Dev' do
  end
  
end

abstract_target 'ExtensionPodsTarget' do
  use_frameworks!
  
  google_utilites
  
  pod 'FirebaseAuth'
  pod 'FirebaseFunctions'
  
  target 'Extension' do
  end
  
  target 'Extension Dev' do
  end
end

after this i just did pod install and i went back to have only one GoogleUtilities Dependency

like image 29
Jorge Balleza Avatar answered Oct 16 '22 08:10

Jorge Balleza


Adding pod 'GoogleUtilities', '~> 7.7.0' to all the targets that use Firebase pods will make it work. In my case, this included 3 targets: iOS app, iMessage Extension and UnitTests.

No need to add this part explicitly:

def google_utilites
  pod 'GoogleUtilities/AppDelegateSwizzler'
  pod 'GoogleUtilities/Environment'
  pod 'GoogleUtilities/Logger'
  pod 'GoogleUtilities/MethodSwizzler'
  pod 'GoogleUtilities/NSData+zlib'
  pod 'GoogleUtilities/Network'
  pod 'GoogleUtilities/Reachability'
  pod 'GoogleUtilities/UserDefaults'
end
like image 8
Bogdan Razvan Avatar answered Oct 16 '22 08:10

Bogdan Razvan