2

It appears Xcode 10.2.1 has broken my gcc installation. For example, if I try to compile a simple file:

int main() {
    printf("Hello, world!\n");
    return 0;
}

And run it I get:

dyld: mach-o, but built for simulator (not macOS)
Abort trap: 6

gcc -v is reporting back with:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The option that jumps out there being:

--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/c++/4.2.1

I've recently installed the iOS simulator and I'm assuming doing so has lead to this. Is this expected behaviour? If not, is there any way I can get my gcc to compile for macOS again rather than iOS.

I've have tried deleting and reinstalling the Xcode Command Line Tools, to no avail. I imagine the solution is to completely uninstall and reinstall Xcode, which I'm a bit hesitant to do.

Cœur
  • 37,241
  • 25
  • 195
  • 267
RichieAHB
  • 2,030
  • 2
  • 20
  • 33
  • Mine reports `/MacOSX10.14.sdk/`. Try `xcode-select --install` (idea from https://stackoverflow.com/questions/39762289/issue-with-executing-a-out-file-c-macos-sierra-10-12-1). – Cœur Jul 05 '19 at 01:58
  • This was (part of) the method I used to reinstall the command line tools, which had no effect. – RichieAHB Jul 05 '19 at 07:17
  • On reinstalling Xcode this issue remains ... – RichieAHB Jul 05 '19 at 16:21
  • Mac version is 10.14.3 and the desired version of Xcode is ideally just the stable latest, so 10.2.1 I think! – RichieAHB Jul 05 '19 at 16:28
  • Maybe try to update your system to macOS 10.14.5? – Cœur Jul 05 '19 at 16:34
  • Related: [GCC with-gxx-include-dir is set to iOS 11.4 simulator](https://apple.stackexchange.com/questions/329446/gcc-with-gxx-include-dir-is-set-to-ios-11-4-simulator) – Cœur Jul 05 '19 at 16:40
  • 1
    So it's fixed although I don't currently have Xcode re-installed. Deleting everything, a reboot and then I need to `xcode-select --reset`, which has fixed it thus far. Now to ruin it all with Xcode. Thanks for you help! – RichieAHB Jul 05 '19 at 16:52

0 Answers0