Xcode 9 Catalina

Question or issue on macOS:

After upgrading to Catalina from Mojave, Setuping: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk in the env.

With the Catalina upgrade, my Xcode did not automatically update to 11.1. The App Store kept trying to update Xcode each night through automatic updates. On its own, it never succeeded. Once it reported it could not download Xcode: Unable to Download App. 'Xcode' could not be installed. Please try again later. I am working on a clean install of Catalina and Xcode 11. If you are trying an upgrade, or using a different version, your experience may be different. If you run into problems post a comment and I’ll do what I can to help out. And so, without further ado Install MacOS Catalina; Install XCode 11; Launch XCode. Agree to the license agreement. 5 years ago, I started writing an enterprise marketing design and publishing app supporting the web and mobile apps. With the release of Xcode 9, about 2 years ago, I made the jump to 64-bit and the effort was manageable, including the effort to fix compatibility with several libraries that were not updated.

Xcode 12: macOS Catalina 10.15.4 (Intel-based Mac) iOS 14 macOS 10.15.6 tvOS 14 watchOS 7 DriverKit 19: x8664 armv7 armv7s arm64 arm64e: iOS 9-14 iPadOS 13-14 macOS. I am thinking of buying an older Mac MD101LL/A just for Xcode development. That is why I asked about Catalina on this older model. I have 2 Macs now, but neither have enough free storage to support XCODE. So my follow up question was whether this older model MD101LL/A with 4 MB memory and 500GB disk would run Xcode and which version.

I’m unable to compile a program that use header.

Xcode 9 Catalina

I tried changing CFLAGS, CCFLAGS, CXXFLAGS to point to the MacOSSDK Location that change nothing

for example the macro: isless is present in the global namespace and on my computer:

Even the cmath header include it:

And my command line have the option -isystem /usr/local/include

This should work…

How to solve this problem?

Solution no. 1:

I am having the same problem while trying to target iOS (both on my MacBook Air and on GitHub Actions runner) and here are a few more thoughts on the problem even though I’m not familiar enough with Apple’s ecosystem to suggest a proper solution. The original command line was coming from CMake in cpprestsdk, but once I boiled it down to essentials, here is a short repro.

  1. Create file cmath-bug.cpp with the only line in it:
  1. Run (newlines in front of some arguments are for reading convenience, remove them)

When I run it, i get the familiar to many facing the same issue:

The only 2 include directories I pass on my original command line exist and are:

But the interesting bits here are the non-existing include directories it reports as well as the include directories it ends up searching eventually and their order. My guess is that additional directories not mentioned on the command line are inserted by Apple Clang’s driver based on some Apple-specific logic.

You can see from the reported error that the <cmath> header is found at: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath and at line 304 of it you can see:

Judging from the fact that in that same folder /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ there is a file math.h that provides the necessary definitions, e.g.:

the authors of <cmath> were expecting the math.h from that same folder be included first and then the #include_next <math.h> directive find the system-specific math.h. That is not what’s happening in reality however.

If you look at the first 2 entries in searched directories:

you see that system-specific include directory ends up being above the Clang-injected standard library directory, which is why the system-specific math.h is being found, not the one in the same folder as the rest of the standard library headers. This is likely the case because if I explicitly add the standard library include directory to my command line BEFORE the other two directories -isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 the problem goes away and I am able to compile the file. That’s not what Clang’s driver or whatever else is involved here does automatically: it adds that standard library directory via -internal-system (not sure what’s the semantics of that internal flag) and it adds it AFTER the system directory.

Now if you look at the list of ignored directories, the very first entry in that list is:

of which the trailing c++/v1 part does not exist on my machine, making me wonder whether the iPhone SDK installation was supposed to create a symbolic link c++ inside the existing part of the path to point to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++ directory to make the whole thing work.

Anyways, this what I think is happening and I wonder if anyone knows how to properly fix this?

Thank you!

P.S. For the context:

Solution no. 2:

I’m curious: What compiler are you using? What’s the value of CMAKE_OSX_SYSROOT?

I’m fairly convinced this is the result of a wrong CMAKE_OSX_SYSROOT. I had the problem you’re describing when using python bindings for clang (where CMake doesn’t manage the compiler call), but I managed to recreate the error in CMake by doing:

I solved my problem by following the answers to this question: Cannot compile R packages with c++ code after updating to macOS Catalina.

Xcode 9 Not Working On Catalina

To summarise: On Catalina, /usr/include is purged and protected by SIP. Thus, any project that expects the C headers to be found there will fail to compile. If I remember correctly, Apple recommends to file bug reports to projects that expect C headers in /usr/include.

You must point the build system of the code you’re trying to compile to the right headers:

(1) Make sure Xcode is up to date. There’s no telling what an outdated Xcode on Catalina might do to your build environment.

(2) Use the -isysroot /sdk/path compiler flag, where /sdk/path is the result of xcrun --show-sdk-path. I’m not sure what CMake’s best practice is, but try doing

or

If that solves the problem, you may want to look for a better way to do this in CMake.

Of course, if you’re adventurous, you could also disable SIP, as suggested in the answer to my question: /usr/include missing on macOS Catalina (with Xcode 11)

Solution no. 3:

Using the command:

my #include <…> search sequence:

The reason of #include error is described below:

  • #include<cmath> resides in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
  • It includes <math.h>.
  • It searches /usr/local/include directory as this is the first directory to search. There is a math.h in /usr/local/include/c++/9.3.0/ directory
  • It tries to use this.
  • But expectation was to use the math.h of the same directory /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
  • The math.h of /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 include math.h of /usr/local/include using #include_next<math.h>
  • As wrong math.h is included/linked with /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath, the compilation error happens

The fix:

Install Xcode 9 On Catalina

  1. If we can alter the search order of #include<...> to search /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 at first, it can be fixed.

  2. Using #include</Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h> instead of <math.h> in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath

I have followed the #2 option and build is successful now!

And thanks to solodon for the detailed answer. I followed the answer to fix the issue.

Solution no. 4:

It is possible your copy of Xcode is corrupted. Check with codesign:

This happened to me, and the problem was corrupted Xcode. Reinstalling fixed it.

Something had modified the following:

math.h was empty in all the above places.

Solution no. 5:

I have just got this error when trying to compile gRPC after recently upgrading to 10.15.4 and Xcode 11.4 and I started to look at all the solutions offered (here and Can’t compile a C program on a Mac after upgrading to Catalina 10.15), and tried a few of them (though not trying to recreate /usr/include as that would violate the separation that Apple were trying to create) – nothing seemed to work.

I then looked closely at the actual complier invocations that the make process was producing and noticed that there was an explicit

that was ultimately causing the includes to happen in the wrong order – removing this explicit include path allowed the compilation to succeed with a default install of catalina, Xcode and the Xcode command-line tools, as you would expect, no other tricks/compiler flags needed.

Solution no. 6:

@solodon’s analysis is spot on. The issue is likely that the cmath file is including the wrong version of math.h based on the search order of the header files. At least, this is what was happening to me when I was getting the same error.

Xcode 9 Catalina

Scan your compiler output for #include <...> search starts here:. You can also force this output from the command line with (source):

It should look something like this:

Notice that the paths with Toolchains come before those with Platforms. If in your case the order is reversed, you need to figure out what in your configuration is causing this. For me, it was an explicit setting of CPLUS_INCLUDE_PATH in my login script.

Offending code:

This was part of my attempt to work around Xcode 11 no longer providing the installation package for the SDK header files. After removing this code, I was able to successfully include cmath in my C++ code.

If you came here looking for solutions to this issue, you may require a different solution but hopefully this helps to shed light on what seems to be the root cause of this issue, header file search path order.

Solution no. 7:

You may try to use the CommandLineTools SDK rather than the XCode.app SDK.

I fix this problem when I compiling PointCloudLibrary (PCL)

Also, reinstall XCode.app and CommandLineTools may help.

Solution no. 8:

@mkl ‘s solution helps to fix the similar issue on my side. Thanks.

Issue and solution on my side

I got the same issue to compile a project on basis of PCL. The solution is to set CommandLineTools SDK CMAKE_OSX_SYSROOT.

I tried @mkl’s solution to do it in CMakeLists.txt, it doesn’t work. So that I can only set it by cmake .. -DCMAKE_OSX_SYSROOT='/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk'

Another thing to mention: there are two versions of command line SDKs in my MacOS:

xcrun --show-sdk-path gives out the default one, but actually only MacOSX10.14.sdk works on my side.

Discussion of the similar issue in PCL’s repo:
https://github.com/PointCloudLibrary/pcl/issues/2601#issuecomment-621889211

Difference between SDKs

I don’t know much about cmake and SDKs in c++. The difference I noticed in cmake building log from different SDKs as following:

/Library/Developer/CommandLineTools/SDKs/MacOSX:

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

On default:

Seems like the issue happens on SDK choice for Opengl.

How to do it in CMakeLists.txt?

Xcode 9 Catalina Island

Appreciated it if anyone could advice.

Solution no. 9:

Reinstalling Xcode, command tools and homebrew,
and

sudo rm -rf /usr/local/include

fixed this issue for me.

Solution no. 10:

I found that inside my project I have file math.h. After rename it the problem was disappear. Seams cmath include my file instead of system.

Hope this helps!

I am attempting to bring a Swift 3.x application up to date to the latest version of Swift by executing conversions in old versions of Xcode. This has brought me to Xcode 9.x.x. So, I attempted to install Xcode 9.x.x on a 16-inch MacBook Pro running Catalina 10.15.2. I tried both 9.4.1 and 9.3.1. Both failed with error:

Catalina


I suppose AppKit in 10.15.2 no longer possesses the symbol expected by Xcode. Am I correct to conclude Xcode 9.x.x is not supported on Catalina?


Xcode 9 catalina free

Xcode 9 Catalina Download

If this is the case, how can I obtain a copy of High Sierra or Mojave to run Xcode from there? I understand I may not be able to run these operating systems natively on the 16-inch MacBook. Is it possible to run these older OS versions in a VM?