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

Xcode编译报错求助:Multiple commands produce <execute-shell-script> 问题

Fixing "Multiple commands produce" Error with Duplicate Build Scripts in Xcode

Hey there, I’ve dealt with this exact frustrating issue before when working with multiple Xcode targets. Let’s walk through how to resolve it.

What’s causing this?

The error pops up because your main target PorjectName and extension target notificationServiceExt both have identical build script phases (like "Build Project Frameworks", "Build Assets Catalog", etc.). Xcode gets confused when two separate targets try to run identical scripts that produce the same output, so it throws this conflict error.

Step-by-step fixes:

  • First, identify duplicate scripts
    Open your Xcode project, select the blue project icon, then switch between PorjectName and notificationServiceExt in the TARGETS list. Go to the Build Phases tab for each, and check for the script names mentioned in your error log—you’ll see they exist in both targets.

  • Option 1: Remove redundant scripts
    If the script is only needed for the main project (not the extension), simply delete the duplicate script phase from the notificationServiceExt target’s Build Phases. Right-click the script phase and select "Delete" to remove it.

  • Option 2: Share a single external script file
    If both targets need the script functionality, don’t duplicate the code. Create a new .sh file in your project (e.g., BuildFrameworks.sh), paste the script content into it, then replace the inline script in both targets with a call to this external file. For example, use:

    "${PROJECT_DIR}/BuildFrameworks.sh"
    

    This way, Xcode recognizes the commands as separate (since they’re calling a file instead of having identical inline content), and the conflict goes away.

  • Option 3: Assign unique output paths
    If you must keep separate inline scripts, expand each script phase (click the arrow in the top-right corner of the script block), then add a unique Output File path for each target. For example:

    • For PorjectName: $(BUILT_PRODUCTS_DIR)/MainTarget_BuildFrameworks.output
    • For notificationServiceExt: $(BUILT_PRODUCTS_DIR)/ExtTarget_BuildFrameworks.output
      Xcode uses these output paths to distinguish between commands, so this should resolve the conflict.
  • Clean and rebuild
    After making changes, hit Cmd+Shift+K to clean the build folder, then Cmd+B to rebuild your project. This ensures old build artifacts don’t interfere with the fix.

A quick heads-up

Sometimes these duplicate scripts get added automatically by tools like CocoaPods. Double-check your Podfile to make sure you’re not accidentally applying a post-install script to multiple targets when it only needs one.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 11:24:18