XCode says: "Unexpected duplicate tasks: WriteAuxiliaryFile..."

Hi there,

till today I had no problems to build and run my project via Xcode on a iPadPro. But now, after Unity is finished, XCode starts and shows this:
“Unexpected duplicate tasks: WriteAuxiliaryFile /Users/MyName/Library/Developer/Xcode/DerivedData/Unity-iPhone-hgmepjuucxmvytadtadsnjiirqky/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/GameAssembly.build/Script-C62A2A42F32E085EF849CF0B.sh”

AI says there are duplicate build scripts or tasks. This can happen after a Unity update, a new plugin or a build cleanup. The path points to a temporary script in the DerivedData folder - i.e. a build artifact.

  • I did not update Unity. But there was this general iOS and macOS update in the last days. I did not know, this would affect this.
  • deleting the whole folder with the iOS build, re-start the Build and Run in Unity and suddenly it works.

How can I manage to not always have to manually delete that iOS folder first?

Thanks!

Had the same issue and the dev team is aware of it. in the meantime try to delete one of the duplicated scripts (bin icon)

Any Updates? Still happening on the latest version of Unity I’m afraid :frowning:

Workaround steps:

  1. Open Xcode project ➔ Targets ➔ GameAssembly ➔ Build Phases tab.
  2. Look for multiple Run Script sections. If you see duplicates, click the trash bin on the extra ones to delete.
  3. Product ➔ Clean Build Folder (Shift + Command + K).
  4. Clear Derived Data:
    Option 1: Use DevCleaner (free Mac app).
    Option 2: Run this Terminal command:
    rm -rf ~/Library/Developer/Xcode/DerivedData

(Not sure what the right order of operations for Clear Derived Data / Clean Build Folder is but some combo of those worked for me.)

Any solution? This is really annoying, having to delete my game’s Xcode directory on every build and re-enter the provisioning profile in Xcode each time. I’m using Unity 2022.3.47f1

EDIT:
Hello, in my case I have discovered what the problem was.
I updated my game’s provisioning profile and installed it in XCode, but I didn’t update it in Unity’s build settings. That’s what caused the conflict.
I hope this helps someone with the same problem.

20 days later and still no fix?

I am also encountering this error. I tried coming back to an old project and have seen it in 2022 and Unity6 LTS and now the latest version (Unity 6000.1.3f1)

The first build of the project works fine, but in the second build these scripts appear twice:

export BEE_CACHE_BEHAVIOUR="RW"
export CACHE_SERVER_ADDRESS="none_but_bee_still_wants_us_to_set_it"
export REAPI_CACHE_CLIENT="Il2CppOutputProject/IL2CPP/BeeLocalCacheTool"
export BEE_CACHE_DIRECTORY="$HOME/Library/Unity/cache/bee"
mkdir -p "$CONFIGURATION_TEMP_DIR/artifacts/arm64/buildstate/"
mkdir -p "$PROJECT_DIR/Il2CppTempDirArtifacts/$CONFIGURATION"
ln -sF  "$CONFIGURATION_TEMP_DIR/artifacts" "$PROJECT_DIR/Il2CppTempDirArtifacts/$CONFIGURATION/artifacts"
if [ "$CONFIGURATION" = "Debug" ];
then
    IL2CPP_CONFIG="Debug"
else
    IL2CPP_CONFIG="Release"
fi

HOST_ARCH=$(uname -m)
if [ "$HOST_ARCH" = "arm64" ];
then
    HOST_ARCH_BEE="arm64"
else
    HOST_ARCH_BEE="x64"
fi

if [ "$ARCHS" = "arm64" ];
then
    LIB_ARCH="arm64"
elif [ "$ARCHS" = "x86_64" ];
then
   LIB_ARCH="x64"
else
   LIB_ARCH="$HOST_ARCH_BEE"
fi

echo "Lib arch: $LIB_ARCH"
echo "Host arch: $HOST_ARCH"
echo "Bee arch: $HOST_ARCH_BEE"

IL2CPP_DIR="$PROJECT_DIR/Il2CppOutputProject/IL2CPP/build/deploy_$HOST_ARCH"
IL2CPP="$IL2CPP_DIR/il2cpp"
chmod +x "$IL2CPP"
chmod +x "$IL2CPP-compile"
chmod +x "$IL2CPP_DIR/bee_backend/mac-$HOST_ARCH_BEE/bee_backend"

"$IL2CPP" --compile-cpp --platform=iOS --baselib-directory="Libraries" --incremental-g-c-time-slice=3 --dotnetprofile=unityaot-macos --usymtool-path="/Applications/Unity/Hub/Editor/6000.1.3f1/Unity.app/Contents/Tools/macosx/usymtool" --profiler-report --print-command-line --static-lib-il2-cpp --generatedcppdir="Il2CppOutputProject/Source/il2cppOutput" --custom-il2-cpp-root="Il2CppOutputProject/IL2CPP" --architecture="$LIB_ARCH" --outputpath="$CONFIGURATION_BUILD_DIR/libGameAssembly.a" --cachedirectory="Il2CppTempDirArtifacts/$CONFIGURATION/artifacts/$LIB_ARCH" --configuration="$IL2CPP_CONFIG" 
rm -rf "$PROJECT_DIR/Il2CppTempDirArtifacts/$CONFIGURATION"

Unfortunately if I remove any of them I get new errors. Like

UnityFramework:
Command Ld failed with a nonzero exit code

or GameAssembly: Framework Not Found (or something similar)

To be clear:
A new install of Unity6
A new project
Build project first time: works (only one of above scripts added)
Build project second time: Duplicate run scripts (above), remove either of them, more problems arise.
Have tried deleting derived data and cleaning xcode build extensively.
Have tried 2022.1.10f1, 2022.3.52f1. 6000.0.48f1 and 6000.1.3f1.
Have tried opening in new xcworkspace

MacBook M3 Max Sequoia 15.2, Xcode Version 16.3 (16E140)

It seems to be incremental build that makes it happen. Only fix I found is to make a completely clean build, with a custom script that cleans the entire build folder.

Has anybody made a bug report yet?

It seems it was fixed:

its not fixed and still appears in Unity 6000.0.49f1 and Unity 6000.1.4f1 on second Build - The first works fine, the second has an Duplicated Run Script in Xcode->GameAssembly->BuildPhases

Hey @valentinwinkelmann , if you read the issue tracker, it says it’s “Fixed in 2022.3.63f1, 6000.0.50f1, 6000.1.5f1, 6000.2.0b2”, so it’s simply unreleased as of yet.

Ahhh my bad - Thankyou. then I hope that it will be released soon and then no longer occurs there.

It happended exactly same to me suddenly! Up to yesterday I was building without any problem! but now I recieve Unexpected duplicate tasks and then for just testing some small modifications I have to go through this exhusting process! Is there any update? If the patch of the unity is problem, so why I did not face it up to now and suddenly it happended? Thank you in advance!

The issue has been fixed in version 2022.3.63f1, but it is only available with the Enterprise and Industry passes. Hope it will be fixed in the general version as well.

Absolutely shocking how long we’ve had to wait for a fix to this, only for them to only release to Enterprise and Industry…

Any fix for this in 2022? You can’t intoduce a build breaking bug and then only patch it for enterprise. Builds worked fine before. No updates from staff since April?

@eduardooriz
Not fixed and happens in their own DevOps Build Automation

Is there a workaround if I’m doing “cloud builds” ??

Yeah this same thing is bothering me too

Hey are you planning to fix this or are you seriously only keeping this fix for enterprise? This is a crippling bug, not an enterprise feature.