Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "The target [...] is declared multiple times" after pod install?

Working on a react-native(version 0.59.5) project, just installed cocoapods(version 1.7.5)

Installation process:

(from within project directory)

-sudo gem install cocoapods

(from within iOS directory of project)

-pod init

-pod install --repo-update

Result:

Analyzing Dependencies [!] The Target 'ProjectName-tvOSTests' is declared multiple times.

then tried pod update which resulted in the same 'Analyzing Dependencies' warning. There is only a Podfile and a 'Pods' directory in iOS directory. the pods directory has three sub-directories which are all empty. It seems there was a hangup during pod install but I don't know where to look for the duplicate declaration.

I'm aware you should be working from within the ProjectName.xcworkspace file after a installing cocoapods, but there is no .xcworkspace file in my iOS directory of project. How do I fix this?

EDIT:

Podfile

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

target 'TicTacWHOA' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TicTacWHOA
  pod 'Google-Mobile-Ads-SDK'

  target 'TicTacWHOA-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'TicTacWHOATests' do
    inherit! :search_paths
    # Pods for testing
    pod 'Google-Mobile-Ads-SDK'
  end

end

target 'TicTacWHOA-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TicTacWHOA-tvOS

  target 'TicTacWHOA-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end
like image 759
Jim Avatar asked Sep 16 '19 21:09

Jim


2 Answers

The issue was that the "Target" was literally declared twice in the Podfile. so simple and right in front of your face potentially. I Just didn't think anything of it because it was a completely generated file except the one line I added.

like image 106
Jim Avatar answered Nov 15 '22 11:11

Jim


All you need to do is go to podfile and look for the code in the error for example my error was

[!] The target fifty-tvOSTests is declared multiple times.

now i have deleted this piece of code from the podfile once.

target 'fifty-tvOSTests' do
inherit! :search_paths
# Pods for testing 
end 

fifty is the name of my project you know well what is yours the above piece of code was twice in the Podfile so delete if you find multiple just keep only once

like image 34
Harvinder Singh Avatar answered Nov 15 '22 09:11

Harvinder Singh