27

When I try 'swift package' in a terminal window, the following is displayed:

dyld: Library not loaded: @rpath/llbuild.framework/Versions/A/llbuild
Referenced from: /Library/Developer/CommandLineTools/usr/bin/swift-package 
    Reason: image not found
    Abort trap: 6

I thought maybe it had to do with updating to Xcode 10.2 and Swift 5? I've never messed around with the package manager before updating. And I'm no shell guru, either.

Anyway, here's the 'swift version' output if it's relevant:

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
ToddX61
  • 683
  • 6
  • 12

2 Answers2

58

I fixed my problem by opening "Xcode > Preferences > Locations > Command Line Tools" was not filled so I chose one from list

enter image description here

Salavert
  • 761
  • 5
  • 5
  • 3
    Same here. Worked great. Thanks a lot! – geohei Jun 17 '19 at 22:41
  • 2
    Note that even if you're not trying to run your swift application in xcode this will fix it. I'm building my swift app with atom and command line but opening xcode, going to preferences, and changing this fixed the problem globally. – rayepps Jul 05 '19 at 04:28
  • 1
    This worked. The latest Xcode version ought to be the default setting for Command Line Tools. – Greg Sep 26 '19 at 22:57
23

Coincidentally, I found the solution after trying to install MacPorts, which gave me the error:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

The solution (from here) was to:

Point xcode-select to the Xcode app Developer directory using the following command: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Command 'swift package' then ran as expected.

ToddX61
  • 683
  • 6
  • 12