ios - ionic Cordova 平台添加 iOS 失败
问题描述
我正在尝试运行命令
ionic cordova platform add ios@6.2.0
一切都更新了,我的版本是:
ionic - 6.17.1
npm - 7.21.1
node - 16.9.1
pod - 1.11.2
我有 2 天前刚刚发布的 Xcode (13) 的最新版本。运行该命令时,我得到:
--save flag or autosave detected
Saving ios@~6.2.0 into config.xml file ...
Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Debug
Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Release
Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES for build configuration Debug
Use Swift language version 5
Update IOS build setting SWIFT_OPTIMIZATION_LEVEL to: -Onone for build configuration Debug
Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES for build configuration Release
Use Swift language version 5
[ERROR] An error occurred while running subprocess cordova.
cordova platform add ios@6.2.0 exited with exit code 1.
在阅读了我找到的每篇文章后,我将其包含在我的 config.xml 中:
<preference name="UseSwiftLanguageVersion" value="5" />
考虑到我可能有一个不受支持的 Xcode 版本,我将 Xcode 降级到 v12.5.1,在 Xcode -> Preferences -> Locations 上选择它,然后重新启动所有终端和进程,重新启动 Mac,但仍然无法正常工作。
我尝试使用以下命令更新 CocoaPods:
pod install
pod setup
仍然没有任何工作,所以我决定运行命令
ionic cordova prepare ios
看看我是否可以继续但得到这个错误:
[error] Error: Cannot find module '@ionic/angular-toolkit/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/run-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
是的,如果您想知道每次我更新或运行命令时,我也删除了平台、插件、node_modules 和 www 文件夹,但任何事情都在发生。
解决方案
好吧,最后,经过 15 小时的工作和大量搜索,通过将我的 Node 版本从 16.9.1 降级到 14.17.5,这一切都得到了解决。
我不知道Angular jet不支持这个新的Node版本,但我发现了,你也可以通过运行命令
ng -v
最后说
Warning: The current version of Node (16.9.1) is not supported by Angular.
要降级您的 Node 版本,您可以按照这篇文章中的说明进行操作:
您还可以在此处查看所有可用的 Node 版本: https ://nodejs.org/es/about/releases/
由于 Angular 比 Node 落后一步,我建议下载Active版本而不是当前版本。
推荐阅读
- php - 需要使用 Laravel HTTP 客户端发出包含 OAuth 1.0a 的请求
- javascript - 在 Promise 中使用导出的 Object 变量
- python - 支持电报机器人
- c++ - 指向数组部分的指针。过滤数组的操作
- python - 为什么 python3 在 PyCharm 中抛出异常时没有命中断点并停止
- javascript - 为什么我的切换按钮无法使用 Javascript 打开我的响应式菜单?
- haskell - 如何使用 llvm 命令从 GHC llvm 后端生成的 llvm ir (*.ll) 文件创建可执行文件?
- proxy - 有没有办法在使用 CNTLM 代理时指定多个域?
- laravel - 推送提交到 gitlab 时出错,管道错误无法读取用户名
- php - 文件上传问题 Android WebView