Compiling universal binaries breaks autocomplete on Visual Studio Code

Hi!

During the past days I’ve faced an issue with autocomplete con Visual Studio Code and the cause that I found is pretty strange so I will share it with you.

My setup:

  • Intel Macbook with macOS Monterey 12.3.1
  • Visual Studio Code with CMake and C++ extensions
  • JUCE 6.1.6 as a submodule of my project, added with the following cmake code:
include(FetchContent)
FetchContent_Declare(
        JUCE
        GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
        GIT_TAG 6.1.6  
)
FetchContent_MakeAvailable(JUCE) 

As I was saying in the beginning, some days ago the autocomplete function of my editor stopped working. Every JUCE-related objects and functions were underlined as errors and not found, but the project was still compiling without problems.

I’ve done nearly everything I could imagine: clean install of VSC, clean install of VSC extension (I’ve also tried to install older versions of them), clean clone of the repo, new repo with a copy of my code… Nothing worked. All my other JUCE projects did not have the same issue, the only difference was that in my last project I had just added the option to compile for both ARM and x86.

This is the code that I added to compile universal binaries:

if (APPLE)
    set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif()

This was actually working and I was able to compile universal binaries, that were perfectly running.

I’ve tried to remove that code and everything went back to normal! Autocomplete was back, objects and functions were recognized etc… Then I noticed that with that option enabled in PluginProcessor.h file I had this error:


It’s in Italian, basically it’s saying that there are errors related to the file “endian.h”, it says that it’s impossibile to open the error code “endian.h”, which is a dependency of juce_audio_processors.h. For this reason VSC was not able to properly load the JUCE library and therefore use autocomplete correctly.

Someone has an idea of why is this happening? I’ve resolved my issue by simply adding another flag and putting it in AND with APPLE in the if statement, and I set that true only when I want to compile for ARM, but I’m still curios to know the actual reason behind this problem.

Also been having this same issue, I’ll try removing the architectures argument and see if that fixes it for me as well.

edit: This has indeed fixed my IntelliSense issues. Curious what the root of this issue is.