79

When i type "pod install" in a correct directory I always get this

Analyzing dependencies

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

    project 'path/to/Project.xcodeproj'

podfile

platform :ios, '8.0'
use_frameworks!

target 'Posting' do
pod 'ALCameraViewController'

end

I'm in the project directory where Podfile can be found.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
kvra13
  • 1,019
  • 2
  • 10
  • 16

26 Answers26

176

I had an old .xcodeproj-file in my folder, so there was 2 of them. I removed the old one and it works!

ullstrm
  • 9,812
  • 7
  • 52
  • 83
  • 5
    I was left with an old .xcodeproj file after an attempted rename followed by discarding all changes in git. I guess the project file stuck around. – Justin Vallely Oct 30 '17 at 22:53
  • 3
    XCode generated a ._*.xcodeproj file, while failing to open without the `pod install`, so that needed to be deleted first. – duckbrain Feb 02 '18 at 23:05
  • 1
    Damn! If it wasn't for this answer I'd be here all day. Today I accidentally renamed the project and renaning it back didn't remove the new .xcodeproj. Being ignored by git didn't help as I had no idea it stayed there. When I read your answer it "clicked". Thank you very much. – Nuno Gonçalves Oct 18 '18 at 14:03
  • 1
    Ok, this saved my butt. I somehow got another project's .xcodeproj file in my project's folder. Once I deleted that the pod update works again. Thank you! (Voted) – Duncan C Jul 23 '19 at 19:12
20

Add your Podfile to project line for Specify project path

target 'MyGPSApp' do
  project 'FastGPS'
  ...
end

details: https://guides.cocoapods.org/syntax/podfile.html#project

torun
  • 465
  • 1
  • 5
  • 11
16
platform :iOS, '8.0'
use_frameworks!

target 'Posting' do
project 'projectpath/project.xcodeproj'
pod 'ALCameraViewController'
end
dllnboy
  • 179
  • 1
  • 2
15

Mistakenly added two .xcodeproj file in the project folder.

This is why pod did not decided which one he will work for. I simply delete the unnecessary xcodeproj file from the project.

Now Solved

Shourob Datta
  • 1,886
  • 22
  • 30
12

This happened to me, I had my "podfile" in the subfolder and not the main directory, e.g., ~/MyProject/MyProject/podfile instead of ~/Myproject/podfile

Hope this helps!

Sharukh Mastan
  • 1,491
  • 18
  • 17
7

It is taking single declaration for each target. Add line at top of the file after platform:

project '<Project>.xcodeproj'

target '<Project>' do
 #bla bla bla
end

target '<Project>-tvOS' do
 #bla bla bla
end

Arjun Kava
  • 5,303
  • 3
  • 20
  • 20
6

For me below solution worked

Since Podfile and .xcodeproj is at same level, I added project 'oceanview.xcodeproj' at top of the file.

So my podfile looks like below,

platform :ios, '9.0'
project 'abc.xcodeproj' #added this line
target 'abc' do
end

then run command pod install

Naren
  • 1,504
  • 16
  • 19
4

I had 2 files with .xcodeproj along with 1 .xcworkspace, inside my project folder. I deleted one and problem got resolved.

In my case, I removed the one whose size was zero bytes.

JiteshW
  • 2,195
  • 4
  • 32
  • 61
4

I have got this error when I have moved my repo to an external drive.

My solution was to move the repository to the main drive.

Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
  • Could I move my repo to an external drive to build a Xcode project because of my poor low space MacBook air? – Shrdi Jun 16 '20 at 15:17
  • try it. It didn't work for me but it was almost one year ago and maybe this subject have been addressed in newer Cocoapods versions – Blazej SLEBODA Jun 16 '20 at 16:02
3

Oddly I had 2 .xcodeproj files in the same directory . I think i duplicated one. It showed up in the workspace as red, When I removed one it worked fine .

yeahdixon
  • 6,647
  • 1
  • 41
  • 43
3

To address this, you'll need to add the correct path to your project.xcodeproj. Having this one fixed, It's very likely you'll need to provide the path to your project.xcworkspace. The code below addresses both issues.

target 'your-app-bundle-name' do

platform :ios, '8.0'
workspace 'path/to/your/project.xcworkspace/'
project 'path/to/your/project.xcodeproj/'

pod 'ALCameraViewController'

end
Sylvester Loreto
  • 404
  • 6
  • 18
3

If you're working off an external drive, you might have to run dot_clean path/to/working/directory on macos, or rm ./._* in the working directory for linux, to remove any temporary files starting with ._ that might have been created as backup.

Praise
  • 188
  • 2
  • 5
  • 1
    This did the trick for me, thank you! For me it happened when I changed my source control with XCode open, which seems to have left hidden files in that folder which were messing things up! – Jason Masters May 31 '22 at 18:38
  • This works for me. Because I have the issue since I move my working directory to external ssd. Thank you !!! – Isma Rekathakusuma May 09 '23 at 04:19
1

I had this issue when I accidentally deleted '.xcodeproj' file.

Edison D'souza
  • 4,551
  • 5
  • 28
  • 39
1

You should specific project path inside pod file

platform :ios, '8.0'
   use_frameworks!

   project 'PATH_TO_PROJECT/YOUR_PROJECT_NAME.xcodeproj'
    target 'Posting' do
    pod 'ALCameraViewController'

end
Vengleab SO
  • 716
  • 4
  • 11
1

I had my project stored in the Icloud and when I moved it to my desktop, the terminal found the project and allowed me to install the POD.

Charlie
  • 170
  • 12
1

I solved the problem as follows new Podfile

pod init
pod install
Sasha Tsvigun
  • 311
  • 5
  • 15
1

This seems to be an issue with an additional file being added to Xcode. In case you are trying to troubleshoot, it makes sense to look at any additional files you may have added. Either on Xcode or directly in your file.

In my case it was this: /node_modules/react-native-gesture-handlers/ios/RNGestureHandler

After deleting this I hit pod install, and it worked fine.

CoderLee
  • 3,079
  • 3
  • 25
  • 57
Ali Shirazee
  • 1,008
  • 10
  • 11
1
project '/Users/macw/Documents/IOS Projects/Test-Demo/Test-Demo.xcodeproj'

target “Test-Demo” do pod 'AMapLocation' end

I did, and then the problem was solved.

ewq qwe
  • 11
  • 1
0

Did you include the entire ALCameraViewController repository in your project folder? I did that initially, and I got the same error. Go back to the repo and follow the README.md file step by step.

If you did include the entire repo, I would also advise to remove all the folders that you included in your project that came from the ALCameraViewController repo. Then try to install the repo in the Podfile again, the error should be gone.

0

I had the Same problem , i solved it by moving the podfile to the main project folder , in your case : 1- move the pod file to 'Posting' folder , in which there are 'Posting' subfolder and 'Posting.xcodeproj' file
2- re run the ' pod install ' command. 3- enjoy

A_Mo
  • 338
  • 2
  • 8
0

I had the same issue, the problem was in that my project folder was synchronized with iCloud and .xcodeproj wasn't fully loaded from it. It was visible in Finder but not visible in Terminal. The solution was to open/close .xcodeproj and try "pod install" again

Alina Egorova
  • 109
  • 1
  • 4
0

I had a conflict because we were working in a team and I had a manifest.lock file under my pods directory that I had to remove and then run the pod install command and it worked :)

Tanzeel
  • 455
  • 6
  • 16
0

This happened to me too. We use git. And often change branches. While I changing a branch, some bug in Xcode made the project file lose its name. I did clean and changed branches or pull again. The Xcode project file was restored. But the old file with the missing name was still in there. This is not detected by git, if you try to do a pod update with this file in there, It will file. Delete this file or make sure you have only xcode proj file. This should fix it

Nithin Pai
  • 2,190
  • 3
  • 13
  • 6
0

For the newer versions of xcode (ie 12.4 and above), use this target instead:

  post_install do |installer|
   installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
   config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
  end
 end
end

NOTICE that for this solution we are using version 10.0 as our target. Good luck

0

Remove the Pod/ folder and run 'pod install' again.

Alan Silva
  • 139
  • 1
  • 8
0

In my case project folder I was trying to run my project from was located in my usb, I moved the project from usb to Desktop also my project folder name was huge which I changed to concise like this

/Users/Untitled/abcxyz-123123/abcxyz-123123/

after that I changed it to

/Users/username/XYZ/

after that I ran 'pod install' and it worked!