【问题标题】:How do I select a project in my Podfile? I'm getting the error: Unable to find the Xcode project for the target 'Pods'如何在我的 Podfile 中选择一个项目?我收到错误消息:无法找到目标“Pods”的 Xcode 项目
【发布时间】:2017-03-07 11:45:12
【问题描述】:

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

platform :ios, '7.0'

xcodeproj 'SimpleWeather'  

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

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

项目名称为 SimpleWeather。

【问题讨论】:

  • 你的项目名称是什么? Pods 文件的位置在哪里?
  • 我已经尝试将 podfile 放在 SimpleWeather 和 Developer 中
  • 将它移动到您的 SimpleWeather 项目目录中,注释掉 xcodeproj 并运行 $ pods install
  • 如果您绝对必须使用项目名称,请检查项目名称引号,它们应该是“反引号”。 Podfile Syntax Reference
  • 当我安装 pods 时,我得到 pods: command not found。当我做 pod install 我把 xcodeproj 放回去我得到: [!] 无法自动选择 Xcode 项目。在您的 Podfile 中指定一个,如下所示: xcodeproj 'path/to/Project.xcodeproj' 我不确定我应该使用 bash 开发人员 myname 还是只使用 myname

标签: ios xcode cocoapods


【解决方案1】:

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

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

  1. 打开终端并执行:$ sudo gem install cocoapods
  2. 导航到您的项目文件夹(我假设在您的情况下它是cd /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj)。
  3. 设置 Cocoapod pod setup
  4. 创建 Podfile touch Podfile
  5. 打开 Podfile open -e Podfile 并插入您的 Podfile 代码
  6. 最后安装 Podfile pod install

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

有关详细信息,请参阅this

【讨论】:

  • 嘿,它给了我这样的“[!] [!] Podfile 不包含任何依赖项。”
  • 这很奇怪,我以前从未遇到过这个错误。您确定您输入的所有内容都正确吗?
  • @dhaval 您的 pod 是否已输入到 Podfile 文件中? nano Podfile
  • 有时我点击 Finder 中的.xcodeproj 文件并选择“文件夹中的新终端”,这会在.xcodeproj 文件夹中打开终端,所以我当然需要cd .. 回到一个级别到项目文件夹。物联网,用ls真正检查你在正确的文件夹中
  • 在进行上述更改之前,它更喜欢 rm -rf MyProject.xcworkspace
【解决方案2】:

当您的 Xcode 项目中有多个 .xcodeproj 时也会出现此错误。

在一般情况下,您不需要多个 .xcodeproj。去掉不必要的.xcodeproj,之后Cocoapods应该会自动得到正确的路径。

【讨论】:

    【解决方案3】:

    重申我们最初的对话:

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

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

    /Users/myName/Developer/SimpleWeather
    

    【讨论】:

      【解决方案4】:

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

      替换路径

      【讨论】:

        【解决方案5】:

        要解决此问题,只需按照以下步骤操作即可解决您的问题:

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

        第二步:touch podfile

        第三步:open -e Podfile

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

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

        第 5 步:Pod 安装

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

        CheersKP

        【讨论】:

          【解决方案6】:

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

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

          【讨论】:

            【解决方案7】:

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

            【讨论】:

              【解决方案8】:

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

              source 'https://github.com/CocoaPods/Specs.git'
              platform :ios, '9.0'
              use_frameworks!
              
              target 'SimpleWeather'
              pod 'Alamofire', '~> 3.4'
              

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

              【讨论】:

                【解决方案9】:

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

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

                【讨论】:

                  【解决方案10】:

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

                  【讨论】:

                    【解决方案11】:

                    检查您的 Podfile 中的以下几行

                    config = use_native_modules!
                    
                    use_react_native!(:path => config["reactNativePath"])
                    

                    target '<project_name>' do

                    【讨论】:

                      【解决方案12】:

                      希望这个答案在许多人使用 SPM 时有用。我的情况如下:我有一个必须转换为 cocoapod 的二进制框架包,以及它的依赖关系树。在包所在的 git 存储库中,.gitignore 文件包含以下行:/*.xcodeproj。这意味着即使在本地一切正常,只要 CI 尝试运行 pod install 就会失败。

                      【讨论】:

                        猜你喜欢
                        • 2013-02-01
                        • 2018-01-16
                        • 2023-01-19
                        • 2021-01-09
                        • 2021-11-13
                        • 2016-08-22
                        • 1970-01-01
                        • 1970-01-01
                        相关资源
                        最近更新 更多