Search Issue Tracker

Won't Fix

Votes

1

Found in

2022.3.16f1

2023.2.4f1

2023.3.0b1

Issue ID

UUM-59574

Regression

Yes

"Unexpected duplicate tasks" error in Xcode when the project is rebuilt

-

Reproduction steps:
1. Open the attached project “ReproProj”
2. Go to File > Build Settings and choose iOS build target
3. Make sure that the build uses Xcode 15.x and press Build And Run
4. Wait for the build to finish
5. In the opened Xcode project, if needed, change Xcode scheme to “UnityFramework” and press the Build button
6. Go back to Editor and press CMD+B
7. Press the Build button in Xcode
8. Observe Xcode logs

Expected result: Xcode Build succeeds
Actual result: Xcode Build fails with “Unexpected duplicate tasks” error

Reproducible with: 2022.2.21f1, 2022.3.16f1, 2023.2.4f1, 2023.3.0b1
Not reproducible with: 2021.3.34f1, 2022.1.24f1, 2022.2.0a13
Couldn't test 2022.2.0a14 - 2022.2.20f1 (“BuildFailedException: Incremental Player build failed!”)

Reproducible on: macOS 14.2 (M1 Max), macOS 14.0 (Intel)
Not reproducible on: No other environment tested

Note: As a workaround, from the second time on, build the project from the Build Settings window using Build And Run and selecting the "Replace" option when prompted by macOS

  1. Resolution Note:

    There is an issue with postprocess script, where shell script build phase is edited manually:

    if (section == "PBXShellScriptBuildPhase" && line.Trim().StartsWith("shellScript"))
    {
    pbxproj.Flush();
    pbxproj.BaseStream.Seek(-2L - Environment.NewLine.Length, SeekOrigin.Current);
    pbxproj.WriteLine("\\necho \\\"Hello\\\"\";");
    }

    What is happening, is that we add shell script in GameAssembly to run il2cpp build.
    Now, we really need il2cpp build properly done, so we always add this run script phase with proper commandline etc.
    This works in both replace and append, since internally (in PBXProject) when adding shellscript phase, we are checking first if such phase exists already (by comparing name/commandline/some other things), see https://docs.unity3d.com/ScriptReference/iOS.Xcode.PBXProject.AddShellScriptBuildPhase.html
    Since pbxproject *text* itself is edited, when we load it to append, the buildphase that GameAssembly needs is different from what is in the project, so it is added anew. And mind you we cannot just delete previous one because this is, kinda, no longer "unity added it and controls it"

Comments (10)

  1. micahxavier2018

    Apr 17, 2025 02:46

    Same here, this bug is messing up my ability to “quickly” build and test for iOS. I’m using macOS sequoia 15.4, Xcode 16.2. Unity 6000.0.43f1. I build the Xcode project in windows and build the iOS with Xcode

  2. eduardooriz

    Apr 10, 2025 15:07

    You can just go on Xcode to GameAssembly > Build Phases and delete one of the duplicated run scripts (garbage bin icon) the team seems aware of this bug

  3. ccoppoletti

    Apr 08, 2025 19:25

    This happened to me after building for iOS Simulator SDK then trying to append over a project I built. It is not resolved in 2022.3.45f1

  4. artfail

    Apr 07, 2025 02:04

    Same issue. Xcode 16.3, Unity 6000.0.45

  5. artfail

    Apr 06, 2025 02:25

    I am also hitting this issue with Xcode 16.3. I tried with both Unity 6.0.44 and 6.0.45

  6. artfail

    Apr 05, 2025 21:38

    I am ALSO experiencing this with Xcode 16.3 and Unity 6000.00.44f1.

  7. fred_unity188

    Apr 05, 2025 12:01

    Same issue here. From Unity's answer, I don't quite get what we're supposed to do as a workaround

  8. sama-van

    Apr 03, 2025 17:02

    Temp fix:

    1. Delete the whole Xcode project.
    2. rm -rf ~/Library/Caches/com.apple.dt.Xcode
    3. rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache
    4. Restart machine.
    5. Build from Unity again.

  9. sama-van

    Apr 03, 2025 16:36

    Same issue with Unity 6000.0.44F1 & xcode Version 16.2.

  10. pstpetrov

    Apr 03, 2025 14:36

    I am experiencing this with Xcode 16.3, Unity 6000.00.44f1. Is there a workaround?

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.