pod install cannot tell which Xcode project to use
Could not automatically select an Xcode projectShort answer
CocoaPods picks the project by itself only when exactly one .xcodeproj sits in the same folder as the Podfile. If there are two or more, or none, it stops. Name the project with the project directive in the Podfile, or move the Podfile into the folder of the project.
Fix it fast
1Find out which cause you have
List the Xcode projects in the folder that holds the Podfile. The count tells you which cause applies.
ls -d *.xcodeproj ls Podfile2Match what you see, then jump to its fix
What does the error look like?
Could not automatically select an Xcode projectpod install stops before creating the workspace
Cause 1 of 3
Several .xcodeproj files sit next to the Podfile
1Check
The docs say a project is used automatically only if there is exactly one project in the Podfile's directory and no target names one. With more, each target needs an explicit project.
ls -d *.xcodeproj2Fix
Add a project line to each target, naming the project it belongs to, as the docs example does.
target 'MyApp' do
project 'MyApp'
pod 'Alamofire'
end3Verify
pod install now runs to the end and creates the workspace.
pod install
ls -d *.xcworkspaceConfirmed by guides.cocoapods.org
Cause 2 of 3
The Podfile is in a different folder from the project
1Check
With zero projects in the Podfile's folder there is nothing to select. This happens when the Podfile was created at the repository root but the project is in a sub-folder.
find . -maxdepth 3 -name "*.xcodeproj" -not -path "./Pods/*"2Fix
Either move the Podfile to the folder of the project, or give the relative path to the project from the Podfile.
target 'MyApp' do
project 'ios/MyApp'
pod 'Alamofire'
end3Verify
Run the install from the Podfile's folder and open the workspace it creates.
pod installConfirmed by guides.cocoapods.org
Cause 3 of 3
The workspace name differs from what you expect
1Check
Without a workspace directive, the project's name becomes the workspace's name when there is exactly one project.
ls -d *.xcworkspace2Fix
Set the workspace name explicitly if the team needs a particular one.
workspace 'MyWorkspace'
target 'MyApp' do
project 'MyApp'
end3Verify
A fresh pod install creates the workspace with that name.
pod install && ls -d *.xcworkspaceConfirmed by guides.cocoapods.org
How do I stop it coming back?
- Run pod init in the folder of the .xcodeproj so the Podfile starts in the right place.
- When a repository holds several projects, name each project in its target block.
- Open the .xcworkspace and not the .xcodeproj after every pod install.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Mobile apps
pod install says there is no Podfile in the project directory
No Podfile found in the project directory
CocoaPods looks for a file named Podfile in the folder where you run the command.
2 causes, each with a fixMobile apps
Cannot change the App Privacy answers in App Store Connect
Publish Your App Privacy Responses?
Only the Account Holder, Admin and App Manager roles can answer the App Privacy questions.
2 causes, each with a fixMobile apps
App record creation fails because you lack permission
You cannot add a new app in App Store Connect as a Developer or limited user
Only the Account Holder, an Admin or an App Manager can create an app record, and Apple blocks it until the Account Holder has signed the latest agreement.
3 causes, each with a fixMobile apps
You cannot find the button to pull your app back from review
No 'remove this version from review' message appears on the version page
There is no button called Reject Binary.
3 causes, each with a fixMobile apps
Your Apple Account cannot sign in to App Store Connect
Sign-in to App Store Connect is refused for an account that should have access
App Store Connect does not open to every Apple Account.
3 causes, each with a fixMobile apps
Apple rejected the app under Guideline 4.3, Design: Spam
Guideline 4.3(b) - Design - Spam
Guideline 4.3 is Apple's duplicate rule.
5 causes, each with a fix