How to solve Cocoapods error no podfile found in the project directory:
If you are new to iOS development, there is a high chance that you will face this issue. This error comes when you are trying to do pod install to install all your dependencies.
How to fix this:
The first thing to check is if Cocoapods is installed on your system or not. Cocoapods is a dependency manager and it is used in most Objective-C and Swift iOS projects. As mentioned on their homepage, it is used in more than 3 million of Apps and in over 85 thousand libraries.
Check if you have Cocoapods installed:
The first thing is to check if Cocoapods is installed or not. Open a terminal window and run the below commands:
sudo gem which cocoapods
It will show the installed version if you have it installed.
The first thing is to install Cocoapods if you don’t have it installed. Cocoapods is built with Ruby and it needs to be installed with the default Ruby installed in Mac.
Run the below command to install Cocoapods:
sudo gem install cocoapods
Once the installation is done, you can check the version info as shown in the previous step to confirm if it got installed or not.
How to use Cocoapods:
Go to the project folder and run:
It will create one Podfile on the root level of the project. Edit that podfile to add any external dependency. This file holds all dependencies names and their version to fetch. It looks as like below:
platform :ios, '8.0' use_frameworks! target 'MyApp' do pod 'AFNetworking', '~> 3.0' pod 'SwiftyJSON', '~> 2.3' end
You can add the libraries and run pod install to install these dependencies.
It creates one .xcworkspace file and you need to open this file instead of .xcproject or .xcodeproj file.