You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行ionic cordova platform add iOS命令失败,尝试多方案仍无法解决

Ionic添加iOS 6.2.0平台运行报错问题复现
  • 初始执行命令: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

补充说明:每次更新依赖或执行命令前,都会提前删除platforms、plugins、node_modules和www文件夹,上述所有操作均未解决问题。

内容的提问来源于stack exchange,提问作者Jaime Lovera

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 16:18:02