简体   繁体   English

Pod init 错误工具“xcodebuild”需要 Xcode

[英]Pod init error tool 'xcodebuild' requires Xcode

Im trying to run pod init command on my new project.我试图在我的新项目上运行pod init命令。 It has never happened to me before.以前从来没有发生在我身上。 The things I have tried to fix it are:我试图解决的问题是:

  • Closing Xcode关闭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>'
```

It needs to set your CocoaPod and command line tool version, in your Xcode:它需要在你的 Xcode 中设置你的CocoaPod和命令行工具版本:

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:使用关键字--pre获取最新的预发布:

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.如果你已经支付了苹果开发者账号/id,你可以从苹果下载门户下载最新的命令行工具。


Here are current beta and stable Xcode Tool and supporting command line tool download link.这是当前测试版和稳定版的 Xcode 工具以及支持的命令行工具下载链接。 (Ensure you'are logged in using premium developer account on Apple Developer Account to access these links) (确保您使用 Apple Developer Account 上的高级开发者帐户登录以访问这些链接)

Xcode 10 Xcode 10


Once you've latest command line tool installed in your system, set it from Xcode Menu.在系统中安装最新的命令行工具后,从 Xcode 菜单设置它。

(Xcode Menu Items) Xcode ▶ Preferences ▶ Location ▶ Command Line Tool ▶ Select appropriate command line tool (Xcode 菜单项)Xcode ▶ 首选项 ▶ 位置 ▶ 命令行工具 ▶ 选择合适的命令行工具

在此处输入图片说明


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

I got this error when I updated my xcode version to 9.1.当我将 xcode 版本更新到 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.并输入您的mac密码。 Then try with然后尝试

pod init

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.由于 xcode 9.3 中发生的问题,所以我在 xcode 9.2 中创建了项目,安装了 pod。 and than after open the project in xcode 9.3 and start work on it.然后在xcode 9.3中打开项目并开始工作。

I got the same issue with cocoapods.我在 cocoapods 上遇到了同样的问题。 I have resolved this with -我已经解决了这个问题 -

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

hope this may help to someone.希望这可能对某人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM