【问题标题】:ionic Cordova platform add iOS failsionic Cordova 平台添加 iOS 失败
【发布时间】:2021-11-16 03:27:24
【问题描述】:

我正在尝试运行命令

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 文件夹,但任何事情都在发生。

【问题讨论】:

    标签: ios swift iphone xcode ionic-framework


    【解决方案1】:

    嗯,最后,经过 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 版本,您可以按照这篇文章中的说明进行操作:

    How to downgrade Node version

    您还可以在此处查看所有可用的 Node 版本: https://nodejs.org/es/about/releases/

    由于 Angular 比 Node 落后一步,我建议下载 Active 版本,而不是 当前 版本。

    【讨论】:

      【解决方案2】:

      巧合的是,今天我不得不将一个 Cordova 项目迁移到 iOS 6.2,因为 Apple 通常会在几个小时前更新并让所有内容都过时(应该注意的是向后兼容性最好)。

      我将与您分享与cordova一起使用而无需过多挖掘的简短命令:

      0-) sudo npm install cordova-ios@latest

      1-) sudo ionic cordova platform remove ios

      2-) sudo ionic cordova platform add ios@latest // 不指定版本,最后一个已经假设了这个

      3-) sudo chmod -R 777 platforms/ios // 通常情况下,我必须在我的计算机上启用读写权限,但我确保完全权限。

      4-) sudo ionic cordova build ios

      5-) 你在生成的项目中再次打开XCode,瞧,你可以编译它了。

      如果第 1 步失败,请运行 2 次(出于某种原因,我总是需要运行 2 次才能完成)。

      最好的问候。

      【讨论】:

      • 我这样做了,在第2步失败了,添加平台时,和以前一样的错误,当试图将平台保存到config.xml中时......你知道Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Debug是什么意思吗?是什么意思?
      • 尝试连续运行第2步,如果不成功,分享错误。
      猜你喜欢
      • 2013-07-31
      • 1970-01-01
      • 2020-04-27
      • 2020-07-31
      • 2019-11-18
      • 1970-01-01
      • 1970-01-01
      • 2020-10-30
      • 2018-06-07
      相关资源
      最近更新 更多