ios – Pod init错误工具’xcodebuild’需要Xcode

前端之家收集整理的这篇文章主要介绍了ios – Pod init错误工具’xcodebuild’需要Xcode前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在我的新项目上运行pod init命令.
它从来没有发生在我身上.我试图解决的问题是:

>关闭Xcode
>创建一个新项目
>重新启动计算机

我在控制台中遇到的错误是:

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>'
```

解决方法

它需要在您的Xcode中设置您的 CocoaPod和命令行工具版本:

重置(卸载并安装)可可豆荚:
在终端上执行以下操作以获取最新的稳定版本:

sudo gem install cocoapods

使用关键字–pre来获取最新的预发布:

sudo gem install cocoapods --pre

如何设置/重置命令行工具:
如果您已经支付了Apple开发者帐户/ ID,可以从Apple Download Portal下载最新的命令行工具.

这是当前的beta和稳定的Xcode工具和支持命令行工具下载链接. (确保您使用Apple Developer Account上的高级开发者帐户登录以访问这些链接)

Xcode 10

  • 07002

    – 07003

    – 07004

在系统中安装了最新的命令行工具后,从Xcode菜单中进行设置.

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

enter image description here

尝试与终端应用程序相同

安装命令行工具(使用终端应用程序):

xcode-select --install

更改活动目录:

sudo xcode-select -switch /Library/Developer/CommandLineTools

猜你在找的Xcode相关文章