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

Resolution issue with different set of supspecs #12384

Open
1 task done
pyretttt opened this issue May 16, 2024 · 0 comments
Open
1 task done

Resolution issue with different set of supspecs #12384

pyretttt opened this issue May 16, 2024 · 0 comments

Comments

@pyretttt
Copy link

pyretttt commented May 16, 2024

Resolution issue with different set of supspecs.

What did you do?

Hey there!
Encountered pods resolution issue.
Details below:

Consider following Podfile and .podspecs.

target 'App'
   pod 'A', :path => 'path/to/local/pod'
   pod 'B', :path => 'path/to/local/pod'

Pod::Spec.new do |s|
  s.name          = 'A'
  ...
  s.dependency 'Lib/ResourceA' # <~ Look here
  s.dependency 'Lib/ResourceB' # <~ Look here
end

Pod::Spec.new do |s|
  s.name            = 'B'
  ...
  s.dependency 'Lib/ResourceB' # <~ Look here
  s.dependency 'Lib/ResourceC' # <~ Look here
end

Then pod install will resolve it like so.
pod A depends on Lib
pod B depends on Lib
Lib depends on Lib-ResourceA, Lib-ResourceB, Lib-ResourceC
Everything is fine.

Now lets consider following example:

target 'App'
   pod 'A', :path => 'path/to/local/pod'
   pod 'B', :path => 'path/to/local/pod'

target 'IndependentTarget' # <~ Added target in the same xcodeproj. But don't link it into App
   pod 'A', :path => 'path/to/local/pod' # <~ Depend only on A.

Pod::Spec.new do |s|
  s.name          = 'A'
  ...
  s.dependency 'Lib/ResourceA' # <~ Look here
  s.dependency 'Lib/ResourceB' # <~ Look here
end

Pod::Spec.new do |s|
  s.name            = 'B'
  ...
  s.dependency 'Lib/ResourceB' # <~ Look here
  s.dependency 'Lib/ResourceC' # <~ Look here
end

What happens now?!
cocoa pods resolve dependencies in the following way.
Same:
pod B depends on Lib
Lib depends on Lib-ResourceA, Lib-ResourceB, Lib-ResourceC
Different:
pod A depends on Lib-ResourceA-ResourceB
Lib-ResourceA-ResourceB depends on Lib-ResourceA-ResourceB-A and Lib-ResourceA-ResourceB-B.

Being that A and B both linked to App target it leads to duplication of artefacts, resource and etc.

What did you expect to happen?

I would say that duplication of target A could be solution.
A-App
A-IndependentTarget
But it may lead to problems when IndependentTarget linked to App.

What happened instead?

Copypaste
pod B depends on Lib
Lib depends on Lib-ResourceA, Lib-ResourceB, Lib-ResourceC
Wrong:
pod A depends on Lib-ResourceA-ResourceB
Lib-ResourceA-ResourceB depends on Lib-ResourceA-ResourceB-A and Lib-ResourceA-ResourceB-B.

CocoaPods Environment

Stack

   CocoaPods : 1.15.2
        Ruby : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
    RubyGems : 3.4.10
        Host : macOS 13.6 (22G120)
       Xcode : 15.2 (15C500b)
         Git : git version 2.39.3 (Apple Git-145)
Ruby lib dir : /***/.rbenv/versions/3.2.2/lib
Repositories : 
               trunk - CDN - https://cdn.cocoapods.org/

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

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'SandUIKit' do
  pod 'MyPod/SubspecThree', :path => './pod'
  pod 'MyPod/SubspecTwo', :path => './pod'
  pod 'MyPod2', :path => './pod'
  pod 'MyPod3', :path => './pod'
  pod 'Resource', :path => './pod'
end

target 'TestThree' do
  pod 'MyPod/SubspecOne', :path => './pod'
  pod 'MyPod/SubspecThree', :path => './pod'
  pod 'MyPod2', :path => './pod'
  pod 'Resource/Regular', :path => './pod'
  pod 'Resource/Medium', :path => './pod'
end

Project that demonstrates the issue

demo project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant