"gtest/gtest.h" not found in TypeRef.cpp while compiling the compiler

Hi Developers,

I was trying to compile the swift compiler with Xcode 12.4 and macOS 11.2 installed (I didn't have the command line tool installed)

However, during the compilation process, the following error popped up:

/Users/yujian/Code/swift-source/swift/unittests/Reflection/TypeRef.cpp:15:10: fatal error: 'gtest/gtest.h' file not found

#include "gtest/gtest.h"


1 error generated.

(For the full error message including the command invoked by the utils/build-script, please click here)

I tried to solve this by installing google test on my Mac and now gtest/gtest.h is located in /usr/local/include.

However, when I tried to build the swift compiler again, the same error popped up again.

I used the following command to build the compiler:

utils/build-script --skip-build-benchmarks \
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
--sccache --release-debuginfo --swift-disable-dead-stripping --test \

and here's the link to the output of utils/update-checkout --dump-hashes

Could you please help me with this? Thank you!

Update: The error still exists in a clean build

1 Like

I don't know exactly the problem but trying to narrow it down maybe you could test if that still happens if you build without --test flag


Hi @LucianoPAlmeida

Thank you for your reply.

I have switched to build with ninja and everything works fine now.

Thank you again for your help!

Terms of Service

Privacy Policy

Cookie Policy