报错:[!] Could not automatically select an Xcode project. Specify one in your Podfile like so: xcodeproj 'path/to/Project.xcodeproj' coccocoapods 导入第三方库的一个小Bug

小小的发一下小牢骚,就因为这个小问题浪费的一天多时间,不是我自己的问题,最后还是解决了,分享给小伙伴们,希望对你们有帮助,不要在浪费时间。

iOS Xcode 8.2.1 环境下的 cocoapods 都是最新版本的。

报错如下:

[!] Could not automatically select an Xcode project. Specify one in your Podfile like so:

xcodeproj ‘path/to/Project.xcodeproj’

1、开始的时候是以为路径的问题,本人就百度找找:

(为了方便小伙伴本人直接复制过来了)原文链接:http://www.aichengxu.com/other/7396635.htm

=======================路径问题的解决方法《一》=====================

如果是路径的问题可以用一下的方法:

下面介绍如何使用终端改xcode的路径:

1、打开终端//确认当前工作位置hmios-project-MacBook-Pro:~ hmios_project$ pwd

/Users/apple

//如果忘记具体执行代码 输入 xcode-select获取提示

hmios-project-MacBook-Pro:~ hmios_project$ xcode-select———-xcode-select: error: no command option given

Usage: xcode-select [options]

———-

Print or change the path to the active developer directory. This directorycontrols which tools are used for the Xcode command line tools (for example, xcodebuild) as well as the BSD development commands (such as cc and make).

Options:  

-h, –help                  print this help message and exit  

-p, –print-path            print the path of the active developer directory 

 -s, –switchset the path for the active developer directory  

–install                  open a dialog for installation of the command line 

developer tools  

-v, –version              print the xcode-select version  

-r, –reset                reset to the default command line tools path

———-

//可见-p是获取 xcode现在路径;-s是转移到对应路径

hmios-project-MacBook-Pro:~ hmios_project$ xcode-select -p/Users/apple/Documents/Xcode .app/Contents/Developer

//果然 xcode 不在应用程序中的位置

//ls 相应路径确认存在

hmios-project-MacBook-Pro:~ hmios_project$ ls /Applications/Xcode.app/Contents/Developer/

Applications  Library  Platforms  Tools Documentation  Makefiles  Toolchains  usr

//-s 相应路径 将 xcode 转移到对应路径

hmios-project-MacBook-Pro:~ hmios_project$ xcode-select -s /Applications/Xcode.app/Contents/Developer

///这里给我报了个错误

———-

xcode-select: error: –switch must be run as root (e.g. sudo xcode-select –switch).

———-

//然后我复制它给我的命令 将路径写入

hmios-project-MacBook-Pro:~ hmios_project$ sudo xcode-select –switch /Applications/Xcode.app/Contents/Developer/

//提示输入本机密码

//输入后成功。

========================路径解决方法《二》========================

原文:http://blog.csdn.net/zhangao0086/article/details/39703083

作者:Bannings

当把CocoaPods生成的workspace移动到上层目录时,需要改下Pods.xcconfig和工程里的一些设置,就通常没什么难度。

当遇到这个问题时:

[plain] view plain copy print?在CODE上查看代码片派生到我的代码片

Could not automatically select an Xcode project. Specify one in your Podfile like so:

xcodeproj ‘path/to/Project.xcodeproj’

在Podfile文件里指定下工程目录就行了,比如我在Podfile文件添加这行就行了:

[plain] view plain copy print?在CODE上查看代码片派生到我的代码片

……

xcodeproj ‘Portfolio/Portfolio.xcodeproj’

……

主要是让Pod找到子目录中的工程文件。

当在update或install时遇到这个问题:

[plain] view plain copy print?在CODE上查看代码片派生到我的代码片

Unable to find a specification for `xxxxx (~> 1.x.x)` depended upon by Podfile.

只需要把当前Pod的目录清理一下就行了。在终端执行以下命令:

[plain] view plain copy print?在CODE上查看代码片派生到我的代码片

pod repo remove master

pod setup

setup成功后执行install或update即可。

======================最后一个可能是这个坑的原因=====================

本人多次确认,通过创建工程认证,当在同一个路径的文件夹下面,放多个由cocoapods导入第三方库的文件的工程就会报

错误:

[!] Could not automatically select an Xcode project. Specify one in your Podfile like so:

xcodeproj ‘path/to/Project.xcodeproj’

这个错误,本人只是在桌面创建的工程一导入就马上正常,这个算是一个小小的坑吧,希望这个文章多小伙伴们有帮助。

    原文作者:KYM1988
    原文地址: https://www.jianshu.com/p/753277d8a124
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞