11

After I used migration assistant to migrate data from my old mac to a new one I can no longer use Xcode command line tools. Whenever I run any xcodebuild command in terminal (even xcodebuild with no parameters) I get the following error:

dyld: Library not loaded: @rpath/DVTFoundation.framework/Versions/A/DVTFoundation
  Referenced from: /usr/bin/xcodebuild
  Reason: image not found
Abort trap: 6

When I run which xcodebuild I get /usr/bin/xcodebuild.

When I run xcode-select -p I get /Applications/Xcode.app/Contents/Developer.

Strangely, if I go to /Applications/Xcode.app/Contents/Developer/usr/bin and call ./xcodebuild I do not get the error above.

Here is what I tried:

  1. Installing command line tools using xcode-select --install.
  2. Uninstalling command line tools located in /Library/Developer/CommandLineTools/.
  3. Performing sudo xcode-select --switch /Library/Developer/CommandLineTools/.
  4. Performing sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/.

None of these resolves my problem.

I am running Xcode 9.4.1 and macOS High Sierra 10.13.5.

UPDATE 1

I tried following this guide to uninstall Xcode and all command line build tools completely. The strange thing is, once I followed all the steps, running xcodebuild command produced the same result as before. And xcodebuild was still located in /usr/bin.

UPDATE 2

If I install command line tools using xcode-select --install and go to /Library/Developer/CommandLineTools/usr/bin running xcodebuild from that location does produce the same error. So, running xcodebuild which comes pre-installed with Xcode produces no error, but the one from the command line tools does produce the error. It is puzzling and also suggests that when I try to remove all command line tools, the ones left in my /usr/bin are the ones which do not come with Xcode.

I tried deleting them, but I am unsuccessful even with the sudo command.

UPDATE 3

I've found a workaround. To ensure that xcodebuild command uses the tool located in /Applications/Xcode.app/Contents/Developer/usr/bin rather than the one located in /usr/bin, I added the following line to my .bash_profile:

export PATH="/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH"

This approach works, but my question remains. I do not understand why I had this problem in the first place. I have double checked - my PATH does not contain /Applications/Xcode.app/Contents/Developer/usr/bin on my old Mac and everything works just fine there.

Looks like for some reason, xcodebuild located in /usr/bin got corrupted and couldn't get updated in any way.

Community
  • 1
  • 1
Andriy Gordiychuk
  • 6,163
  • 1
  • 24
  • 59
  • Error is not related to build command. xcodebuild not getting framework path correctly. Similar issue may be helpful https://stackoverflow.com/questions/24993752/os-x-framework-library-not-loaded-image-not-found – Vishal Rajole Jul 05 '18 at 15:15
  • @VishalRajole I doubt that this issue is related to the framework path. When I run xcodebuild with no arguments in an empty folder it shouldn't try to build anything. – Andriy Gordiychuk Jul 06 '18 at 17:46
  • 1
    @AndriyGordiychuk have you found any solution? I got this issue as well after upgrading my Macbook and migrating all the data onto it – Andrey Gordeev Aug 16 '18 at 15:33
  • Весьма забавно, что одна и та же проблема (и, кажется, редкая) появилась в одно и то же время у людей со схожими именами :) – Andrey Gordeev Aug 16 '18 at 16:03

0 Answers0