Problem

When we do pod initialization with cocoapods in MacOS like this:

➜  ~ pod init

we get this error:

[!] No Xcode project found, please specify one

Environment

  • MacOS 10.14
  • Ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
  • Gem 2.5.2.3
  • Cocoapod 1.9.3

Reason

The pod init function expects the current director to contains the file: MyProject.xcodeproj, wherein the MyProject is your xcode project’s name.

Solution

You should change your current directory to the directory that contains the .xcodeproj file like this:


➜  MyProject git:(master) ls -l
drwxr-xr-x  10 xx  staff   320B 10  8 21:34 MyProject
[email protected]  5 xx  staff   160B 10  8 21:19 MyProject.xcodeproj

➜  MyProject git:(master) pod init  
➜  MyProject git:(master) ✗ ll
total 8
drwxr-xr-x  10 xx  staff   320B 10  8 21:34 MyProject
[email protected]  5 xx  staff   160B 10  8 21:19 MyProject.xcodeproj
-rw-r--r--   1 xx  staff   246B 10 11 07:51 Podfile


➜  MyProject git:(master) ✗ cat Podfile 
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'MyProject' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MyProject

end

Ok, everything is done.