Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

pod install cannot tell which Xcode project to use

ErrorCould not automatically select an Xcode project

Short 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.

  • Applies to CocoaPods, Xcode
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 Podfile
  2. 2Match what you see, then jump to its fix

    1. 1ls -d *.xcodeproj prints two or more namesSeveral .xcodeproj files sit next to the PodfileFix
    2. 2ls -d *.xcodeproj prints nothingThe Podfile is in a different folder from the projectFix
    3. 3pod install succeeds, but the workspace has an unexpected nameThe workspace name differs from what you expectFix

What does the error look like?

  • Could not automatically select an Xcode project
  • pod 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 *.xcodeproj

2Fix

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'
end

3Verify

pod install now runs to the end and creates the workspace.

pod install
ls -d *.xcworkspace

Confirmed by guides.cocoapods.org

Did this fix it?

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'
end

3Verify

Run the install from the Podfile's folder and open the workspace it creates.

pod install

Confirmed by guides.cocoapods.org

Did this fix it?

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 *.xcworkspace

2Fix

Set the workspace name explicitly if the team needs a particular one.

workspace 'MyWorkspace'

target 'MyApp' do
  project 'MyApp'
end

3Verify

A fresh pod install creates the workspace with that name.

pod install && ls -d *.xcworkspace

Confirmed by guides.cocoapods.org

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.