When running pod install in Terminal, CocoaPods searches your current working directory for a specification file named Podfile. If the file does not exist, uses incorrect capitalization, or has a hidden file extension, CocoaPods halts with the following error:
[!] No `Podfile` found in the project directory.
This guide explains why CocoaPods fails to locate your configuration and how to resolve the issue across native Xcode projects, React Native, and Flutter applications.
Why this happens
CocoaPods relies strictly on a text file called Podfile (case-sensitive, with no file extension) residing in the same directory where you execute pod commands. Unlike modern package managers that might scan parent directories, CocoaPods checks only the active shell directory.
First-time CocoaPods users frequently encounter this issue after installing the gem (sudo gem install cocoapods or brew install cocoapods) and running pod install immediately. Installing the CLI tool does not automatically inject dependency configurations into an existing Xcode project; you must explicitly initialize or author a Podfile first.
Another common cause is working inside cross-platform frameworks such as React Native or Flutter. In these environments, the iOS native project files and their associated Podfile reside inside an ios/ subfolder rather than the repository root. Running pod install from the top-level directory triggers this error immediately.
Finally, text editors on macOS (like TextEdit) often append hidden .txt or .rtf extensions when creating files manually, converting Podfile into Podfile.txt. CocoaPods fails to match the filename and reports that no Podfile exists.
How to fix it
1. Initialize a new Podfile with pod init
If you have a standard native iOS project (.xcodeproj) and are adding CocoaPods for the first time, you must generate the initial configuration file.
Open Terminal and navigate to the root directory of your project where your .xcodeproj bundle is located:
cd /path/to/YourProject
Verify that your project file is present:
ls -d *.xcodeproj
Run the initialization command:
pod init
This creates a starter Podfile customized with your project’s build targets. Open the file in an editor:
open -a TextEdit Podfile
Add your desired dependencies inside your application target block:
platform :ios, '16.0'
use_frameworks!
target 'YourAppTarget' do
pod 'Alamofire', '~> 5.9'
end
Save the file, close the editor, and run:
pod install
Once completed, close any open .xcodeproj windows in Xcode and open the newly generated .xcworkspace file instead.
2. Change into the ios directory for cross-platform projects
In React Native, Flutter, Capacitor, and Ionic projects, CocoaPods manages dependencies exclusively for the native iOS runner. The Podfile is generated during project scaffolding and lives inside the ios directory.
Check your current location from Terminal:
pwd
ls -F
If you see package.json, pubspec.yaml, or an ios/ folder listed in your output, change into the ios directory before executing CocoaPods commands:
cd ios
pod install
If the Podfile is missing even inside the ios/ directory of a cross-platform project:
– In Flutter: Run flutter create . from your project root to regenerate platform files, or run flutter build ios --config-only to trigger native pod generation.
– In React Native: Ensure your template initialized completely. You can check the repository history or restore the default Podfile from the corresponding React Native release template.
3. Check for incorrect file naming or hidden extensions
CocoaPods requires exact matching for the filename. It must be named Podfile with a capital P and no trailing extension.
Inspect the exact filenames in your project directory using Terminal:
ls -la | grep -i podfile
If the output displays variations like podfile, Podfile.txt, or Podfile.rtf, rename the file to the required format:
mv Podfile.txt Podfile
Or, if it was written completely in lowercase:
mv podfile Podfile
After correcting the name, run pod install again.
4. Migrate dependencies to Swift Package Manager (SPM)
If you are setting up dependencies on a modern Xcode project, consider using Apple’s built-in Swift Package Manager instead of CocoaPods. SPM does not require Ruby gems, terminal tools, or wrapper workspaces.
To add packages directly in Xcode:
1. Open your .xcodeproj in Xcode.
2. Go to File > Add Package Dependencies…
3. Paste the Git repository URL of the library (for example, https://github.com/Alamofire/Alamofire).
4. Set your dependency rule (such as Up to Next Major Version) and click Add Package.
5. Select your application target and click Finish.
Using SPM eliminates Podfile path mismatches entirely and stores configuration directly inside your project bundle.
How to prevent it
- Always run
lsin Terminal before executing CocoaPods commands to confirm you are in the directory containingPodfileand your.xcodeprojfile. - In React Native and Flutter projects, automate your workflow using root scripts (for example, adding
"pod:install": "cd ios && pod install"to yourpackage.jsonscripts). - Use
pod initinstead of manually creating files with GUI text editors, which often append hidden.txtextensions. - Never delete the
Podfilewhen resolving dependency conflicts; edit the dependencies inside the file instead.
FAQ
Why did running pod install not create an .xcworkspace file?
CocoaPods only creates an .xcworkspace file after a successful pod install execution against a valid Podfile. If CocoaPods exits early with an error, the workspace file will not be generated.
Can I name my configuration file something other than Podfile?
CocoaPods expects Podfile by default. While you can pass a custom file using the --project-directory flag in certain automation scripts, standard projects must name the file Podfile for Xcode and CLI tools to recognize it.
Do I need to run pod init every time I add a new library?
No. You only run pod init once when setting up CocoaPods in a project. To add additional libraries later, edit the existing Podfile and run pod install or pod update.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
