Pod init error tool 'xcodebuild' requires Xcode
Asked Answered
A

4

6

Im trying to run pod init command on my new project. It has never happened to me before. The things I have tried to fix it are:

  • Closing Xcode
  • Creating a new project
  • Restarting my computer

The error I get in the console is:

error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance 

### Command

```
/usr/local/bin/pod init
```

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?


### Stack

```
   CocoaPods : 1.3.1
        Ruby : ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
    RubyGems : 2.5.2
        Host : Mac OS X 10.13.4 (17E199)
       Xcode :  ()
         Git : git version 2.15.1 (Apple Git-101)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ ed5bf5bee99a1909bcc8fb8ffa39fb08d1af6bc8
```

### Plugins

```
cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0
```

### Error

```
RuntimeError - [Xcodeproj] Unknown object version.
/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.4/lib/xcodeproj/project.rb:217:in `initialize_from_file'
/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.4/lib/xcodeproj/project.rb:102:in `open'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.3.1/lib/cocoapods/command/init.rb:41:in `validate!'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:333:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.3.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:22:in `load'
/usr/local/bin/pod:22:in `<main>'
```
Arkwright answered 18/4, 2018 at 18:8 Comment(0)
L
8

It needs to set your CocoaPod and command line tool version, in your Xcode:

Reset (Uninstall & install) cocoa pod:
Execute the following on your terminal to get the latest stable version:

sudo gem install cocoapods

Use keyword --pre to get the latest pre-release:

sudo gem install cocoapods --pre

How to set/reset Command Line Tool:
You can download latest command line tool from Apple Download Portal, if you have paid apple developer account/id.


Here are current beta and stable Xcode Tool and supporting command line tool download link. (Ensure you'are logged in using premium developer account on Apple Developer Account to access these links)

Xcode 10


Once you've latest command line tool installed in your system, set it from Xcode Menu.

(Xcode Menu Items) Xcode ▶ Preferences ▶ Location ▶ Command Line Tool ▶ Select appropriate command line tool

enter image description here


Try the same with Terminal App

Install Command Line Tools (using Terminal app):

xcode-select --install

Change the active directory:

sudo xcode-select -switch /Library/Developer/CommandLineTools
Longo answered 18/4, 2018 at 18:28 Comment(3)
thanks for your great and detailed answer but still no luck. I'll keep tryingArkwright
@PabloMarrufo - try to reset your cocoapods (uninstall & install again), It should work....Longo
that did it. You saved me!Arkwright
C
0

I got this error when I updated my xcode version to 9.1. I fixed the error with the below command. In your terminal just add

Sudo gem install cocoapods --pre

and enter your mac password. Then try with

pod init
Crustal answered 11/5, 2018 at 7:2 Comment(0)
H
0

I have an another option to solved the issues. because of the issues happened in xcode 9.3, so i have create the project in xcode 9.2 , install the pod. and than after open the project in xcode 9.3 and start work on it.

Hallah answered 28/5, 2018 at 10:20 Comment(0)
F
0

I got the same issue with cocoapods. I have resolved this with -

rm -rf ~/.cocoapods/repos/trunk/

hope this may help to someone.

Flagwaving answered 5/4, 2020 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.