小小的發(fā)一下小牢騷侠仇,就因為這個小問題浪費的一天多時間霉祸,不是我自己的問題筑累,最后還是解決了,分享給小伙伴們丝蹭,希望對你們有幫助慢宗,不要在浪費時間。
iOS Xcode 8.2.1 環(huán)境下的 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
//如果忘記具體執(zhí)行代碼 輸入 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現(xiàn)在路徑缅茉;-s是轉(zhuǎn)移到對應路徑
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 轉(zhuǎn)移到對應路徑
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的目錄清理一下就行了扶平。在終端執(zhí)行以下命令:
[plain] view plain copy print?在CODE上查看代碼片派生到我的代碼片
pod repo remove master
pod setup
setup成功后執(zhí)行install或update即可。
======================最后一個可能是這個坑的原因=====================
本人多次確認蔬蕊,通過創(chuàng)建工程認證结澄,當在同一個路徑的文件夾下面,放多個由cocoapods導入第三方庫的文件的工程就會報
錯誤:
[!] Could not automatically select an Xcode project. Specify one in your Podfile like so:
xcodeproj 'path/to/Project.xcodeproj'
這個錯誤岸夯,本人只是在桌面創(chuàng)建的工程一導入就馬上正常麻献,這個算是一個小小的坑吧,希望這個文章多小伙伴們有幫助猜扮。