首页 > 解决方案 > Xcode 默认 gcc (mis) 配置为为 iOS 而不是 macOS 编译

问题描述

看来 Xcode 10.2.1 破坏了我的gcc安装。例如,如果我尝试编译一个简单的文件:

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

运行它我得到:

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

gcc -v正在报告:

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

跳出来的选项是:

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

我最近安装了 iOS 模拟器,我假设这样做会导致这种情况。这是预期的行为吗?如果没有,有什么办法可以让我gcc再次为 macOS 而不是 iOS 编译。

我曾尝试删除并重新安装 Xcode 命令行工具,但无济于事。我想解决方案是完全卸载并重新安装 Xcode,我有点犹豫。

标签: xcodegcccompiler-errorsdyldmach

解决方案


推荐阅读