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

Xcode构建iOS项目报错:PhaseScriptExecution与CompileSwiftSources执行失败求助

Troubleshooting Xcode Build Failures on M1 Pro (Monterey 12.2.1)

Hey there, let’s dig into this build failure you’re hitting on your M1 Pro MacBook Pro. I’ve gone through all the details you shared, and here are some targeted fixes worth trying next:

  • Double-check Compilation Mode across Project and Target levels
    You mentioned Compilation Mode was already set to Incremental, but sometimes project-level settings get overridden by target-specific ones. Head to your project in Xcode:

    1. Select your main project (top level in the navigator) and check Build Settings > Swift Compiler - Code Generation > Compilation Mode
    2. Then select each individual target you’re building and verify the same setting matches. Ensure neither is set to Whole Module—this is the root cause of the "Incremental compilation has been disabled" warning.
  • Fix arm64 Architecture Exclusions (Simulator vs Device)
    For M1 Macs, simulator builds need special handling for arm64, but physical devices require it. Here’s the correct setup:

    1. Go to your target’s Build Settings > Architectures > Excluded Architectures
    2. Click the "+" button, add arm64 only for the iOS Simulator platform (use the dropdown to select the platform, don’t set it globally)
    3. Set Build Active Architecture Only to Yes for the Debug configuration. For physical device builds, don’t exclude arm64 at all.
  • Wipe Xcode Caches and Derived Data
    Corrupted caches are a common culprit for weird build failures. Let’s do a full reset:

    1. Quit Xcode completely
    2. Open Terminal and run these commands:
      rm -rf ~/Library/Developer/Xcode/DerivedData
      rm -rf ~/Library/Caches/com.apple.dt.Xcode
      
    3. Reopen Xcode, hit Cmd+Shift+K to clean the project, then try building again.
  • Debug the PhaseScriptExecution Failure
    The Command PhaseScriptExecution failed error usually points to a custom build script (like CocoaPods, SwiftLint, or Node.js-based tools) failing. Here’s how to fix it:

    Expand the full error log by clicking the red failure message—this will show you exactly which script is breaking.

    • If it’s a CocoaPods script: Run pod deintegrate then pod install in your project directory to reset pods.
    • If it’s a Node/npm-related script: Delete your node_modules folder and run npm install again. Ensure your Node packages are updated to M1-compatible versions.
  • Verify Swift Package Dependencies
    If your project uses Swift Packages, outdated or incompatible dependencies can break compilation:

    1. Go to File > Packages > Resolve Package Versions to refresh dependencies
    2. Check if any packages have known M1/Xcode compatibility issues—update them to the latest version, or switch to a fork that fixes the problem if available.
  • Test with a Fresh Project
    If none of the above work, create a blank iOS project in Xcode and try building it to simulator/device. If this works, the issue is specific to your project’s configuration. Gradually migrate your files, settings, and dependencies to the new project to pinpoint what’s causing the failure.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 19:57:44