CocoaPods / CocoaPods

The Cocoa Dependency Manager.
https://cocoapods.org/
Other
14.59k stars 2.64k forks source link

Differing subspecs on multiple projects cause duplicated frameworks #10679

Open szotp opened 3 years ago

szotp commented 3 years ago

Report

What did you do?

  1. Setup workspace with two projects MinimalExample and MinimalExampleLib.
  2. Add subspec dependencies to two projects that are not exactly the same.

In the example I have used 3 different projects (to ensure it's not related to specific libary): MaterialComponents, AFNetworking, PromiseKit.

MaterialComponents: target names have this weird suffix

AFNetworking: target names are different, but framework names are the same

PromiseKit subspecs are exactly the same on both targets, and problem does not occur.

What did you expect to happen?

Valid Pods project is generated.

What happened instead?

Targets & frameworks are duplicated: Screenshot 2021-05-26 at 10 45 55

And during build, I'm getting these warnings:

Multiple targets match implicit dependency for linker flags 

A workaround is to use the same subspecs on both targets, even if I don't need them (as shown with PromiseKit).

CocoaPods Environment

Stack

   CocoaPods : 1.10.1
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
    RubyGems : 3.0.3
        Host : macOS 11.3.1 (20E241)
       Xcode : 12.4 (12D4e)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0

Podfile

workspace 'MinimalExample'
platform :ios, '12.0'

use_frameworks!

target 'MinimalExample' do
  # Pods for MinimalExample
  pod 'MaterialComponents/TextFields'
  pod 'MaterialComponents/Snackbar'

  pod 'AFNetworking/Reachability'
  pod 'AFNetworking/Serialization'

  pod 'PromiseKit/UIKit'
  pod 'PromiseKit/SystemConfiguration'
end

target 'MinimalExampleLib' do
  project 'MinimalExampleLib/MinimalExampleLib.xcodeproj'
  pod 'MaterialComponents/TextFields'
  # pod 'MaterialComponents/Snackbar' # uncomment to fix

  pod 'AFNetworking/Reachability'

  pod 'PromiseKit/UIKit'
  pod 'PromiseKit/SystemConfiguration'
end

# fix for another build failure, not related to reported issue
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

Project that demonstrates the issue

MinimalExample.zip

marciogranzotto commented 3 years ago

I have the same problem, but I'm using a private developer pod (which is my app's SDK) that includes xcframework libraries like Alamofire, AWS, RxSwift, Realm, etc. image

dnkoutso commented 3 years ago

I was able to repro the initial report. Yes this is a bug with subspecs because they are de-duped between different targets that use them however they produce the same framework name always.

dnkoutso commented 3 years ago

Actually @szotp this seems to be building for me on 1.11.0 (master branch). 1.11.0 has not shipped yet but it will soon.

Going to try 1.10.2 now.

I think @marciogranzotto post is a different issue fixed in 1.11.x.

dnkoutso commented 3 years ago

oh I see this is just a warning not a build failure, nevermind.

dnkoutso commented 3 years ago

we can possibly solve this via https://github.com/CocoaPods/CocoaPods/issues/8206#issuecomment-907492786