无法找到名为“ProjectName”的目标

Unable to find a target named `ProjectName`

我在 PodFile 和 运行 命令中添加了新的 pod

pod install

它删除了之前的所有 pods 并且失败并出现以下错误

Unable to find a target named `ProjectName`

但是我使用 Git 恢复了所有删除的 pods,但现在我的项目没有被编译,它给我以下错误:

/Users/userName/Library/Developer/Xcode/DerivedData/Project_Name-fhktwvetozjdorboqdzfwlpzrcyw/Build/Intermediates/Project_Name.build/Debug-iphonesimulator/Project_Name.build/Script-D7BB987C75C5AEC6033AA28E.sh:
/Users/userName/Desktop/iOS_Workspace/Project_Name/Pods/Target Support
Files/Pods-Project_Name/Pods-Project_Name-resources.sh: /bin/sh^M: bad
interpreter: No such file or directory

我尝试了所有关于 pods 的解决方案,但都不适合我。
任何帮助将不胜感激。谢谢

根据错误,您指定了一个名为 ProjectName 的目标,但这在您的项目中不存在。仔细阅读 podfile syntax reference 并确保添加正确的目标名称(在我的例子中它被称为 Tester:)

花了几个小时 Google 刚刚打开 Podfile,发现项目名称是错误的。所以我刚刚在Podfile中写了正确的项目名称,问题已经解决了。

之前:

target 'Wrong Project Name' do
    pod 'Parse'
    pod 'SDWebImage'
end

之后:

target 'Correct Project Name' do
    pod 'Parse'
    pod 'SDWebImage'
end

这是由于目标名称已更改。

刚刚打开 Podfile 并将目标名称替换为新的目标名称。

(在我的例子中“GoogleMapSample”是“地图样本”,

“GoogleMapSampleTests”是“Map SampleTests”,

“GoogleMapSampleUITests”是“Map SampleUITests”,

意味着我只是将所有目标的“Map Sample”替换为“GoogleMapSample”)

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

target 'GoogleMapSample' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

    pod 'GoogleMaps'
    pod 'GooglePlaces'
    pod 'Alamofire', '~> 4.4’
    pod 'SwiftyJSON', '~> 4.0'


  # Pods for GoogleMapSample

  target 'GoogleMapSampleTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'GoogleMapSampleUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

在我的例子中,目标名称是相同的,
但是区分大小写错误。
"myTarget" // 播客文件
"MyTarget" // Xcode

  1. 备份podfile(复制粘贴到指定位置)。
  2. 删除 pod 文件。移至回收站(来自)Xcode.
  3. 转到终端,找到您的 pods 目录后,点击:pod init
  4. 从备份文件中粘贴内容(第一步)...仅复制 pod 库。前任。吊舱 'Firebase/Core'
  5. pod 安装
  6. 重新启动您的项目,然后打开 YourProjectName.xcworkspace。

确保您当前在 Podfile 中的项目名称与正确的名称匹配

target 'Project name' do
  use_frameworks!

  # Pods for Project name

pod 'SwiftMessages'

end

我有很多如下所示的模式。所以,我们应该在 pod 文件中映射一个模式。

错误:目标'MobileBranch'做

正确:目标'Test-MobileBranch'做

正确:目标'Main-MobileBranch'做