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

Ionic Cordova构建失败:无法读取'toLowerCase'属性(Xcode更新后)

Fix for Ionic/Cordova iOS Build Failure After Xcode 11.1 Update

This error is almost certainly due to Cordova iOS 4.5.5 being incompatible with Xcode 11+. The list-emulator-build-targets script in the outdated Cordova iOS platform can't handle changes Xcode 11 made to the output of device/emulator listing commands, leading to the Cannot read property 'toLowerCase' of undefined error when it tries to process an undefined value.

Here are your options, ordered by long-term sustainability:

This is the best fix, as it aligns your tooling with the newer Xcode version and avoids future compatibility issues.

  • First, update your Ionic and Cordova CLI to the latest compatible versions (for Ionic 4):
    npm install -g ionic@latest cordova@latest
    
  • Remove the outdated iOS platform:
    ionic cordova platform rm ios
    
  • Add a Cordova iOS version that supports Xcode 11 (v5.1.1 or newer is safe for Xcode 11.x):
    ionic cordova platform add ios@5.1.1
    
  • Rebuild your app:
    ionic cordova build ios
    

Note: If you run into plugin compatibility issues after updating, check if your plugins have updates available (run ionic cordova plugin list to see versions, then update individual plugins with ionic cordova plugin update <plugin-name>).

2. Perform a Clean Build (If updating Cordova doesn't immediately work, or to rule out corrupted files)

Sometimes cached platform files can cause issues even after version changes. Try a full clean:

  • Delete the platforms, plugins, and node_modules folders:
    rm -rf platforms plugins node_modules
    
  • Clear npm's cache:
    npm cache clean --force
    
  • Reinstall dependencies:
    npm install
    
  • Re-add the updated iOS platform (as in step 1) and rebuild:
    ionic cordova platform add ios@5.1.1
    ionic cordova build ios
    

3. Rollback Xcode (Temporary Workaround)

If you can't update Cordova right now, rolling back to an older Xcode version that works with Cordova iOS 4.5.5 (like Xcode 10.x) will resolve the issue. Here's how:

  • Download an older Xcode version from Apple's Developer Downloads section (you'll need to log in with your Apple ID).
  • Mount the DMG file, drag the older Xcode app to your Applications folder (rename it something like Xcode_10.3.app to distinguish it from the current version).
  • Switch your system to use the older Xcode via terminal:
    sudo xcode-select -s /Applications/Xcode_10.3.app
    
  • Verify the switch with:
    xcodebuild -version
    

Keep in mind this is a temporary fix—you'll need to update Cordova eventually to support newer iOS versions and Xcode updates.

内容的提问来源于stack exchange,提问作者El Dude

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:05:41