'podfile: multiple target with same pod but different branch or tag

target 'A' do
    pod 'PodName',  git: 'xxx/xxx.git',  tag: 'aaaaa'
end


target 'B' do
    pod 'PodName',  git: 'xxx/xxx.git',  tag: 'bbbbb'
end

I want to get different target with same pod but different tag or branch.But I get multiple dependencies with different sources error.



Solution 1:[1]

Basically, you can't.

When the pod install command run, it downloads and adds all the dependencies into the Pods folder, one folder per dependency.

You can't have multiple versions of the same Pod on the same project, neither pods with the same name from different sources, even with different targets. If you could bypass it by renaming the pod in its branch, it would potentially lead to duplicate symbols errors.

One solution would be breaking the targets into different Xcode projects, each one with its Podspec file, and using a shared sub-project for shared code.

You can see more on this Cocoapods thread.

Solution 2:[2]

as far as I know we can fix it by giving the definition for different targets:

in your podfile specify the targets like this

def pods_targetOne
    pod 'PodName',  git: 'xxx/xxx.git',  tag: 'aaaaa'
end


def pods_targetTwo
    pod 'PodName',  git: 'xxx/xxx.git',  tag: 'bbbbb'
end

target 'App_TargetOne' do
 pods_targetOne
end

target 'App_TargetTwo' do
 pods_targetTwo
end

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alxlives
Solution 2 iMRahib