xcode-select cannot locate clang, even after installing command line tools - xcode

When I try to run the clang command, I get the following error:
xcode-select: Failed to locate 'clang', requesting installation of command line developer tools.
And then I receive this pop-up:
However, no matter how many times I click "Install" - going through a 15-minute install process - I continue to get the same error.
I have also tried running xcode-select --install however that gives the following error:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
I have also tried manually installing from here.
I'm on an M1 mac running macOS Monterey Version 12.5.
It also yields a core dump:
2022-09-19 10:51:04.669 xcodebuild[1541:17443] [MT] DVTPlugInLoading: Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin), error = Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'" UserInfo={NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, NSDebugDescription=dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle “IDESimulatorAvailability” couldn’t be loaded.}, dyldError = dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0000): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'
2022-09-19 10:51:04.688 xcodebuild[1541:17443] [MT] DVTAssertions: ASSERTION FAILURE in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot2/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-21303/DVTFoundation/PlugInArchitecture/DataModel/DVTPlugIn.m:374
Details: Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin)
Please ensure Xcode packages are up-to-date — try running 'xcodebuild -runFirstLaunch'.
NSBundle error: Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'" UserInfo={NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, NSDebugDescription=dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle “IDESimulatorAvailability” couldn’t be loaded.}
Object: <DVTPlugIn: 0x60000080b7a0>
Method: -loadAssertingOnError:error:
Thread: <_NSMainThread: 0x600002c402c0>{number = 1, name = main}
Hints:
Backtrace:
0 0x000000010653d410
1 0x000000010653caec
2 0x000000010653cc6c
3 0x00000001063eb2ac
4 0x00000001063b1118
5 0x00000001063af528
6 0x0000000181aa01b4
7 0x0000000181aaf414
8 0x000000010658158c
9 0x000000010655d4b0
10 0x00000001063af3c0
11 0x00000001063af5e0
12 0x00000001074372ec
13 0x0000000107436ae0
14 0x00000001074361e8
15 0x0000000104c70324
16 0x0000000104c21e0c
sh: line 1: 1543 Abort trap: 6 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null
clang: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null' failed with exit code 34304: (null) (errno=Invalid argument)
How can I install clang?

Please ensure Xcode packages are up-to-date — try running xcodebuild -runFirstLaunch.
This worked for me.

I had the same problem and updated Xcode, relinked paths etc, which didn't help.
What worked was opening Xcode after the update and accepting the prompt to load essential development tools (for macOS and iOS).
A bit hidden in the error message is also the CLI solution: "Please ensure Xcode packages are up-to-date — try running 'xcodebuild -runFirstLaunch'."

You can also open Xcode, select the default runtime tools (MacOS and iOS in my case), then clang should run as normal.
I believe this is the same as doing #LanderTome's answer, but not able to verify.

After installing XCode 14.1 on MacOS Ventura 13.0.1, my clang didn't work with an error very similar to this, and repeatedly tried to install the XCode command line tools. It turns out that xcode-select was pointing to the command line tools that are part of the full XCode package, and failing to find clang in there. clang is included in the command line tools package, but not in some versions of the full XCode package.
What I did to fix it was:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This switches the location that clang and other tools are run from. If you want to switch back to running them from the XCode package, you can use:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Related

How do I resolve the error: 5 duplicate symbols for architecture x86_64 in Xcode?

I am receiving the error "5 duplicate symbols for architecture x86_64" when attempting to launch my React Native project in Xcode. I am using a MacBook Pro, chip Apple M1 and macOS Monterey v 12.2.1. Has anyone had this issue before and managed to resolve it? Can you please help? I have tried other fixes but these failed to work. Below is my podFile:
Error log:
duplicate symbol '_bridgeRef' in:
/Users/.../Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlob.o)
duplicate symbol '_fsQueue' in:
/Users/.../Build/Products/Debug-iphonesimulator/react-native-blob-util/libreact-native-blob-util.a(ReactNativeBlobUtil.o)
duplicate symbol '_fsQueue' in:
/Users/.../Build/Products/Debug-iphonesimulator/react-native-blob-util/libreact-native-blob-util.a(ReactNativeBlobUtil.o)
/Users/.../Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlob.o)
....
duplicate symbol '_fileStreams' in:
/Users/.../Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlobFS.o)
/Users/.../Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlobNetwork.o)
ld: 5 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I receive the below error if I uninstall rn-fetch-blob, run pod install and then run the app in Xcode:
I need the RNFetchBlob package since I am using it in my code or is there something else I can use as the equivalent? Is react-native-blob-util the equivalent? Can someone help please?
Go to xcode select pods under Targets click on react-native-fetch-blob and
select no common block from yes to no
repeat this process for react-native-blob-utils

Build MEX from C/C++ in Matlab R2017b in Catalina 10.15.2 with Xcode 9.4.1

Getting the following error in Matlab R2017b:
Error using mex
dyld: Symbol not found: _OBJC_IVAR_$_NSFont._fFlags
Referenced from: /Applications/Xcode.9.4.1.app/Contents/SharedFrameworks/DVTDocumentation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit
Expected in: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
in /Applications/Xcode.9.4.1.app/Contents/SharedFrameworks/DVTDocumentation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit
xcrun: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
xcrun: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
I've downloaded the older version of Xcode 9.4 that supposed to be compatible with Matlab R2017.b and set the path to it:
> xcode-select -p
/Applications/Xcode.9.4.1.app/Contents/Developer
any suggestions would be grand!

Failed to build iOS app (Xcode Version 9.4.1 (9F2000), Flutter 0.5.1)

It is a test-drive example "https://flutter.io/get-started/test-drive/#terminal"
I have got the following error, please comment how to resolve this issue.
Xcode's output:
↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
clang-3.5: error: unknown argument: '-gmodules'
clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
Command /usr/local/bin/clang-omp failed with exit code 1
clang-3.5: error: unknown argument: '-gmodules'
clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
Command /usr/local/bin/clang-omp failed with exit code 1
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
error: the following command failed with exit code 1 but produced no further output
CompileC /Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner_vers.o /Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/DerivedSources/Runner_vers.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
clang-3.5: error: unknown argument: '-gmodules'
clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
Command /usr/local/bin/clang-omp failed with exit code 1
clang-3.5: error: unknown argument: '-gmodules'
clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
Command /usr/local/bin/clang-omp failed with exit code 1
Could not build the application for the simulator.
Error launching application on iPhone 7 Plus.
I have resolved the issue as the following:
If you look at the question carefully, it triggered an outdated version of clang 3.5, I uninstalled an outdated version and installed a new one.
remove clang-omp from os x
$ brew uninstall clang-omp
After uninstall clang-omp, flutter installer required to update to the latest version. Actually, I did the update before but I did it again.
$ flutter upgrade
I try to run flutter again but it cannot be compiled. It was missing clang-omp
$ flutter run
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
error: can't exec '/usr/local/bin/clang-omp' (No such file or directory)
Command /usr/local/bin/clang-omp failed with exit code 71
error: can't exec '/usr/local/bin/clang-omp' (No such file or directory)
Command /usr/local/bin/clang-omp failed with exit code 71
Because it required an updated version of clang during compilation. I installed llvm
$ brew install llvm
and update the PATH accordingly.
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
Compile the application again, it was compiled successfully.
$ flutter run
Launching lib/main.dart on iPhone 7 Plus in debug mode...
Starting Xcode build...
├─Assembling Flutter resources... 1.1s
└─Compiling, linking and signing... 8.6s
Xcode build done. 11.3s
Syncing files to device iPhone 7 Plus... 3.9s
🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on iPhone 7 Plus is available at: http://127.0.0.1:8100/
For a more detailed help message, press "h". To quit, press "q".
Initializing hot reload...
Reloaded 0 of 391 libraries in 486ms.

Installing XCode command line tools fails

I'm trying to install the command line tools on Yosemite but I'm getting the following error:
$ xcode-select --install
dyld: Symbol not found: __cg_png_create_info_struct
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libPng.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Trace/BPT trap: 5
What is causing this error and how do I fix it?

dyld: Symbol not found: _os_release

I rarely build anything from source, so I really have no idea what's going on here, but have done good few hours of googling and still can't solve it...
I have installed xcode from app store, downloaded newest lua and here is what happens:
cd lua-5.3.0
make macosx
dyld: Symbol not found: _os_release
Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Expected in: /usr/local/terrame/lib/libSystem.B.dylib
in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
make: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
make: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
I then run
xcode-select -r
and still get
dyld: Symbol not found: _os_release
Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Expected in: /usr/local/terrame/lib/libSystem.B.dylib
in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
If I then once again try
make macosx
the first error comes back at me:
dyld: Symbol not found: _os_release
Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Expected in: /usr/local/terrame/lib/libSystem.B.dylib
in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
make: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
make: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
I have tried installing an extension to Lua before, called terrame (terrame.org) so that's what the folder path refers to...
EDIT (answering comments)
which make
/usr/bin/make

Resources