Macaca Macaca 安装提示 xcode is uninstalled!!

HappyCat · 2018年08月29日 · 最后由 Muse1021 回复于 2020年06月17日 · 2067 次阅读

macaca doctor 显示:

xcode 已经重装,macaca 也已经卸载重装,还是提示该问题。

本人安装环境:
Mac os:10.13.4 (17E202)
xcode:9.4.1

共收到 13 条回复 时间 点赞
HappyCat · #14 · 2018年08月29日 Author
仅楼主可见

确认下 xcode 的安装路径啊

xcode 手工打开试试可以吗?

11楼 已删除

已经解决,因为下载使用了 xcode-beta 版本,把 xcode-beta 版本删除了,重新选择一下 sudo xcode-select --switch /Applications/Xcode.app 就可以了。

我更新 xcode 后,也遇到了同样的问题,但是卸载 macaca 重装,更新操作系统的版本 都没能解决,求指导呀

saling 回复

sudo xcode-select --switch /Applications/Xcode.app

HappyCat 回复

这个方法试过了,但是还是不行,还把 xcode command line tools 卸载重装了,也不行
试过更新操作系统,重装 macaca,都没能解决

打开 macaca-doctor 源码里面的 ios.js,有一段代码

exports.xcodeBuild = function *() {
  try {
    const binPath = yield _.exec(`which xcodebuild`);

    if (!_.isExistedFile(binPath)) {
      return _.fail('Xcode is uninstalled');
    }

    let originVersion = this.getXcodeVersion();
    let version = originVersion.length !== 3 ? originVersion : `${originVersion}.0`;

    const MIN_VERSION = '9.2.0';

    if (semver.lt(version, MIN_VERSION)) {
      _.fail('xcodebuild version: %s lower than %s', originVersion, MIN_VERSION);
    } else {
      _.pass('xcodebuild version: %s', originVersion);
    }
  } catch (e) {
    console.log(e);
    return _.fail('Xcode is uninstalled');
  }
};

上面的报错都是拿到的版本号是 9.4.1.0,其实最后版本对比代码是

const semver = require('semver');
console.log(semver.lt('9.2.0','9.4.1.0'))

然后就直接报错了

TypeError: Invalid Version: 9.4.1.0
    at new SemVer (\node_modules\_semver@5.3.0@semver\semver.j
s:293:11)
    at SemVer.compare (\node_modules\_semver@5.3.0@semver\semv
er.js:342:13)
    at compare (\node_modules\_semver@5.3.0@semver\semver.js:5
66:31)
    at Function.lt (\node_modules\_semver@5.3.0@semver\semver.
js:600:10)
    at Object.<anonymous> (Desktop\test.js:2:20)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

改成

const semver = require('semver');
console.log(semver.lt('9.2.0','9.4.1'))

就返回 true 了

基本判断是这句话的代码逻辑拿到的 xcodebuild 版本出发了 + 上.0 的操作

let version = originVersion.length !== 3 ? originVersion : `${originVersion}.0`;

我看 io.js,问题应该是 split 没有指定分隔符,加上'.'就可以了

let version = originVersion.split().length === 3 ? originVersion : `${originVersion}.0`;

有没有路过的好心人,帮我看看问题啊,谢谢https://testerhome.com/topics/16316

pazzo 回复

我加了也没用还是报错

zjf12345 回复

不知道你加到什么
let version = originVersion.split('.').length === 3 ? originVersion : ${originVersion}.0;
我改成这样已经可以了,

terrychow 回复

代码路径在哪啊。。。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册