pod安装后如何修复“目标[...]被多次声明”?

Jim*_*Jim 5 xcode cocoapods react-native

在一个 react-native(版本 0.59.5)项目上工作,刚刚安装了 cocoapods(版本 1.7.5)

安装过程:

(从项目目录中)

——sudo gem install cocoapods

(来自项目的iOS目录中)

——pod init

——pod install --repo-update

结果:

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

然后尝试pod update导致相同的“分析依赖项”警告。iOS 目录中只有一个 Podfile 和一个“Pods”目录。pods 目录包含三个子目录,它们都是空的。期间似乎挂断了电话,pod install但我不知道在哪里查找重复声明。

我知道您应该在安装 cocoapods 后在 ProjectName.xcworkspace 文件中工作,但是我的 iOS 项目目录中没有 .xcworkspace 文件。我该如何解决?

编辑:

播客文件

# 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
Run Code Online (Sandbox Code Playgroud)

Jim*_*Jim 15

问题是“目标”在 Podfile 中实际上被声明了两次。如此简单,就在您面前。我只是没有想到它,因为它是一个完全生成的文件,除了我添加的一行。


Har*_*ngh 5

您需要做的就是转到 podfile 并查找错误中的代码,例如我的错误是

[!] 目标fifty-tvOSTests被多次声明。

现在我已经从 podfile 中删除了这段代码一次。

target 'fifty-tvOSTests' do
inherit! :search_paths
# Pods for testing 
end 
Run Code Online (Sandbox Code Playgroud)

五十是我的项目的名称你很清楚你是什么上面的代码在Podfile中出现了两次所以如果你发现多个就删除只保留一次