Unable to run Swift Package Manager (macOS 10.14.4)
Asked Answered
I

2

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
Infeudation answered 30/3, 2019 at 14:23 Comment(0)
S
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

Schmaltz answered 24/5, 2019 at 8:48 Comment(3)
Same here. Worked great. Thanks a lot!Fugleman
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.Enzymology
This worked. The latest Xcode version ought to be the default setting for Command Line Tools.Mete
I
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.

Infeudation answered 31/3, 2019 at 11:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.