報錯:[!] 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的路徑:

[code]

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'

這個錯誤,本人只是在桌面創建的工程一導入就馬上正常,這個算是一個小小的坑吧,希望這個文章多小伙伴們有幫助。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容