Search code examples
xcodereact-nativecocoapods

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

Solution

  • 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.