Xcode + developer tools must be installed on your Mac.
1. Open Terminal and run the following command to install Cocoa Pods for Xcode:
sudo gem install cocoapods
Enter your Mac password. The required packages will be downloaded and installed.

2. In Terminal, navigate to the root folder of your Xcode project i.e. the folder containing MyProject.xcodeproj
cd /Users/Robbamforth/Projects/MyProject
3. Run the following command to create an empty initial PodFile
in your Xcode project folder.
pod init
Now you have a PodFile
in your projects root directory.
4. Open the with TextEdit (or other editor), and add your pod details under the ‘#Pods for MyProject’ tag
# Pods for MyProject
pod 'GoogleMLKit/Translate', '3.1.0'
5. Install the pod using the following command in Terminal:
pod install
This will download the libraries required for your pod, install the necessary components, and create a new workspace named MyProject.xcworkspace.
From now on, open the .xcworkspace file from finder to work in xcode. If you open the .xcodeproj file, you will not be able to compile or run your project with cocoa pods references.
You can add additional pods to the PodFile in step 4, then repeat step 5 to install.