ios 如何在我的 Podfile 中选择一个项目?我收到错误:无法找到目标“Pods”的 Xcode 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21070977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:05:17  来源:igfitidea点击:

How do I select a project in my Podfile? I'm getting the error: Unable to find the Xcode project for the target 'Pods'

iosxcodecocoapods

提问by meghan66

I'm doing the Ray Wenderlich tutorial called SimpleWeather.
The podfile is in the same folder as the project. Here's my code from the podfile:

我正在做名为 SimpleWeather 的 Ray Wenderlich 教程。
podfile 与项目位于同一文件夹中。这是我来自 podfile 的代码:

platform :ios, '7.0'

xcodeproj 'SimpleWeather'  

pod 'Mantle'  
pod 'LBBlurredImage'  
pod 'TSMessages'  
pod 'ReactiveCocoa'  

The error message is this: [!] Unable to find the Xcode project /Users/myName/Developer/SimpleWeather.xcodeprojfor the target Pods.

错误信息是这样的:[!] Unable to find the Xcode project /Users/myName/Developer/SimpleWeather.xcodeprojfor the target Pods

The name of the project is SimpleWeather.

该项目的名称是 SimpleWeather。

采纳答案by kukido

Reiterating our original conversation:

重申我们最初的对话:

Accordingly to Podfile Syntax Referencethe Podfile looks right.

根据Podfile Syntax Reference,Podfile 看起来是正确的。

Make sure you are running $pod installfrom your project directory:

确保您$pod install从项目目录运行:

/Users/myName/Developer/SimpleWeather

回答by fahu

I'm pretty sure you are not in the right directory. Are you sure your .xcodeprojis in the Developer folder? There might be a subfolder you need to navigate to.

我很确定你不在正确的目录中。你确定你.xcodeproj在开发者文件夹中吗?您可能需要导航到一个子文件夹。

The right way to enable CocoaPods in your Project is:

在项目中启用 CocoaPods 的正确方法是:

  1. Open Terminal and execute: $ sudo gem install cocoapods
  2. Navigate to your Project folder (I assume in your case it's cd /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj).
  3. Setup Cocoapod pod setup
  4. Create the Podfile touch Podfile
  5. Open the Podfile open -e Podfileand insert your code for Podfile
  6. Finally install the Podfile pod install
  1. 打开终端并执行: $ sudo gem install cocoapods
  2. 导航到您的项目文件夹(我假设在您的情况下是cd /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj)。
  3. 设置 Cocoapod pod setup
  4. 创建 Podfile touch Podfile
  5. 打开 Podfileopen -e Podfile并插入Podfile的代码
  6. 最后安装Podfile pod install

If you follow this instructions everything should work. When opening your project make sure to open the .xworkspacefile.

如果您按照此说明进行操作,一切都应该可以正常工作。打开项目时,请确保打开.xworkspace文件。

For more information, see this.

有关更多信息,请参阅

回答by Brian

This error also occurs when you have multiple .xcodeprojin your Xcode project.

当您.xcodeproj的 Xcode 项目中有多个时,也会发生此错误。

You don't need more than one .xcodeprojin general cases. Remove unnecessary .xcodeproj, and Cocoapods should get the correct path automatically afterwards.

.xcodeproj在一般情况下,您不需要多个。删除不必要的.xcodeproj,然后 Cocoapods 应该会自动获得正确的路径。

回答by Rohan Bhale

Hey your path for the project might be wrong. Go to the project and right click on SimpleWeather.xcodeproj and select Get Info as show in the image below(The right side window is for Get Info here). Copy this path from the details window and paste it into the Podfile. After that append /SimpleWeather.xcodeproj to that pasted path. This might solve the problem(Note: It is a snap shot for my project). In your case the solution might be replacing the path with this /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj

嘿,您的项目路径可能是错误的。转到项目并右键单击 SimpleWeather.xcodeproj 并选择获取信息,如下图所示(右侧窗口用于获取信息)。从详细信息窗口复制此路径并将其粘贴到 Podfile 中。之后将 /SimpleWeather.xcodeproj 附加到粘贴的路径。这可能会解决问题(注意:这是我项目的快照)。在您的情况下,解决方案可能会用此/Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj替换路径

enter image description here

在此处输入图片说明

回答by Kalpesh Panchasara

To solve this issue, just follow below steps and your issue will get resolved :

要解决此问题,只需按照以下步骤操作,您的问题就会得到解决:

Step 1 : Open Terminal and navigate to your project folder

第 1 步:打开终端并导航到您的项目文件夹

Step 2 : touch podfile

第2步 : touch podfile

Step 3 : open -e Podfile

第 3 步: open -e Podfile

Step 4 : Write below line in your text edit and close it

第 4 步:在文本编辑中写下一行并关闭它

workspace '/Users/systemName/Developer/yourprojectname/yourprojectname.xcworkspace'

工作区 '/Users/systemName/Developer/yourprojectname/yourprojectname.xcworkspace'

Step 5 : Pod install

第 5 步:Pod 安装

And after successful process, you will not get this error again.

成功处理后,您将不会再次收到此错误。

CheersKP

干杯KP

回答by Yura Huber

Maybe you have two project .xcodeproj, remove one.

也许你有两个项目.xcodeproj,删除一个。

Remove Podfile.lock, folder Pods. On Terminal cd /Users/myName/Developer/SimpleWeatherand pod install

删除Podfile.lock,文件夹Pods。在终端cd /Users/myName/Developer/SimpleWeatherpod install

回答by pulp

I had the same problem. Then with many attempts of trials and errors I finally got the working solution:

我有同样的问题。然后经过多次尝试和错误的尝试,我终于得到了可行的解决方案:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'SimpleWeather'
pod 'Alamofire', '~> 3.4'

This works when you are in your project directory (I assume you should navigate using terminal to /Users/myName/Developer/SimpleWeather/)

这在您位于项目目录中时有效(我假设您应该使用终端导航到 /Users/myName/Developer/SimpleWeather/)

回答by nandhini

so okay i had tried every possible thing ...i had only one .xcodeproj file but sill i couldnt install so finally i had tried with the following
1. open terminal cd to your project folder one with .xcodeproj
2. type pod init
3. type touch Podfile
4. type pod install
Magic happens and your pod files gets installed

所以好吧,我已经尝试了所有可能的事情......我只有一个 .xcodeproj 文件,但我无法安装所以最后我尝试了以下
1. 打开终端 cd 到您的项目文件夹之一,其中一个是 .xcodeproj
2. 输入 pod init
3 . 输入 touch Podfile
4. 输入 pod install
魔法发生,你的 Pod 文件被安装

回答by Arvind Kumar

You installed your Xcode..in application use this command to execute

您安装了 Xcode..in 应用程序,使用此命令执行

sudo xcode-select -switch /Applications/Xcode.app

回答by Sam G

For people who are on Mac and also using code editors, the duplicate file that is causing this issue is ._projectname.xcodeprojbecause it has the same extension as the regular .xcodeproj files.

对于使用 Mac 并使用代码编辑器的用户,导致此问题的重复文件是._projectname.xcodeproj,因为它与常规 .xcodeproj 文件具有相同的扩展名。