Xcode stuck / hangs when compiling source files for Unity project

When building my Unity project for iOS in Xcode, Xcode just stays stuck at “Compiling 286 of 286 source files” forever. During this time, the memory usage keeps growing until the system crashes.

I’m using Unity 5.4.2p4 and Xcode 8.1. I don’t know how to test on iOS now. Any ideas? Thanks!

This is the task that never completes running:

Showing All Messages
CompileC /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp-firstpass_2.o Classes/Native/Bulk_Assembly-CSharp-firstpass_2.cpp normal armv7 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd "/Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio Sky"
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=c++11 -stdlib=libc++ -gmodules -Wno-trigraphs -fno-rtti -fpascal-strings -Os -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.1.sdk -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -miphoneos-version-min=7.0 -g -fvisibility=hidden -fvisibility-inlines-hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -fembed-bitcode-marker -iquote /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/audioky-generated-files.hmap -I/Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/audioky-own-target-headers.hmap -I/Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/audioky-all-target-headers.hmap -iquote /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/audioky-project-headers.hmap -I/Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Products/Release-iphoneos/include -I/Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio\ Sky/Classes -I/Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio\ Sky -I/Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio\ Sky/Classes/Native -I/Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio\ Sky/Libraries/bdwgc/include -I/Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio\ Sky/Libraries/libil2cpp/include -I/Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/DerivedSources/armv7 -I/Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/DerivedSources -F/Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Products/Release-iphoneos -DINIT_SCRIPTING_BACKEND=1 -fno-strict-overflow -include /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/PrecompiledHeaders/Prefix-diondljbljkooaghkektdhbqamzg/Prefix.pch -MMD -MT dependencies -MF /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp-firstpass_2.d --serialize-diagnostics /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp-firstpass_2.dia -c /Users/Chetan/Dropbox/Development/audiosky-build/iOS/Audio\ Sky/Classes/Native/Bulk_Assembly-CSharp-firstpass_2.cpp -o /Users/Chetan/Library/Developer/Xcode/DerivedData/Unity-iPhone-bpzgklgpqhefexbztpigmjvnyunb/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp-firstpass_2.o

I narrowed it down to the ProceduralToolkit Unity library. Once I removed that from my Unity project, it started building in Xcode again.

With XCode 7.3.1 everything works fine, but on XCode 8 and 9, the same problem occurs. We are not using ProceduralToolKit. We are using Unity 5.5

try build your xcode project using xcodebuild command-line tool

> cd <your-project-directory>
> xcodebuild

join the crowd

Wondering if anyone else has had this issue and/or found an alternative solution? I have pretty much the same symptoms…project compiles forever while the memory usage increases over time

I thought it was due to a high volume of ‘Unused variable’ warnings I am now getting after updating to xCode 8.2.1 but apparently they can be safely ignored (although i’m not sure why they’re suddenly appearing). My project is pretty huge so while process of elimination is possible…it’s a really bad idea. How do I properly debug the compiler process?