Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionic cordova 命令执行失败 #268

Open
pengkobe opened this issue Jan 11, 2018 · 0 comments
Open

ionic cordova 命令执行失败 #268

pengkobe opened this issue Jan 11, 2018 · 0 comments

Comments

@pengkobe
Copy link
Owner

pengkobe commented Jan 11, 2018

背景

需要发布 ionic1.x ios 版本,发现 ionic serve 一切正常,当 build ios 的时候死活不通过。platform 文件夹下没有产生任何文件。提示

(node:1980) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Failed to fetch platform cordova-ios@~4.5.4

初次 build 时环境

cnpm 3.x: 
ionic: 1.x
cordova: 7.0.0
ionic-cli: 3.9.0

升级后环境

cnpm 4.5.1: 
ionic: 1.x
cordova: 8.0
ionic-cli: 3.19.0

cordova 8

你可能会遇到这个报错:

build error: Cannot find module '../cordova/platform_metadata

官方解释如下:

Please update all of your plugins (remove/add them). This is an issue with a Plugin trying to use a feature that was removed in cordova 8. Plus open issues on the appropriate plugin repo as this is not specifically an ionic issue.

一些尝试

  • 尝试降低 cordova-ios 版本至
  • 使用 cnpm 升级 ionic cordova,结果升级失败

    后续升级 cnpm 后再安装才成功,但是还是无法 add 成功

  • 见控制提示很多 check-permission。于是乎修改当前用户对 usr/local 目录的执行权限,参考链接,解决了每次都要输 sudo 的问题,不过还时无法解决无法 add 成功的问题

    依然失败

  • 降级 cordova 版本值 7.1.0(保持与 windows 上的版本一致)

    无用

  • 新建一个 ionic 项目( sidemenu ),拷贝源代码至新项目
    • 拷贝覆盖 www 内容,add、 后没报以前的错误了,只是由于没有本地安装插件,从 npm 同步的时候迟迟下载不下来。
    • ctrl + c关掉后,再执行ionic cordova platform rm ios,执行失败,换成 sudo 执行,直接卡住,后续再执行 ionic cordova platform add ios也一样
    • 新建一个空白项目,完全能够 add、 成功,再次替换 www、resources、plugins 三个文件夹
      • 提示 ios/icon/icon-1024.png 不存在
      • 添加后,又提示2208x2208太小了,需要改变大小至 2732x2732,此外,icon 图标大小需要调整至 1024x1024
      • 配置专属开发证书
      • 提示 swift2 不支持,在 build setting 中配置支持 swift3
      • 删除 console 插件
      • build 成功
      • 插件微调

        在新增插件的过程中,又发现了无法 add 的情况,后知后觉,移除 node_modules,去掉过期的插件,移除 package-lock.json 后,重新安装所有库,再重新 add 后,成功!

      • 修复 iOS 11 beta 9 with ionic 1 white bar issue,在 viewport meta 中加 viewport-fit=cover

总结

  • 大部分问题是环境问题
  • 小部分问题是 npm 包问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant