Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run Swift Package Manager (macOS 10.14.4)

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 
like image 913
ToddX61 Avatar asked Mar 30 '19 14:03

ToddX61


People also ask

How do I install Swift package manager?

To create a new Swift package, open Xcode and select File > New > Swift Package. Choose a name and select a file location. Select “Create Git repository on my Mac” to put your package under version control. On completion, the Swift package opens in Xcode and looks similar to a standard Xcode project.

Does Swift package manager support iOS?

In WWDC19, Apple announced the support for Swift Package Manager for all of Apple's platforms, including iOS.

How do I open Swift package manager in Xcode?

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.

Does Swift have a package manager?

The Swift Package Manager is a tool for managing the distribution of Swift code. It's integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. The Package Manager is included in Swift 3.0 and above.

What is swiftc command in Swift?

Swift scripts and macOS apps Swift compiler 101, you can create, build and run a Swift file using the swiftc command. Consider the most simple Swift program that we can all imagine in a main.swift file:

Is there a way to import the Swift Foundation into AppKit?

If you have multiple Swift versions installed on your system, you can use the env shebang to go with the first one that's available in your PATH. It's not just Foundation, but you can import AppKit or even SwiftUI.

How to build and run a swift program in Swift?

Swift compiler 101, you can create, build and run a Swift file using the swiftc command. Consider the most simple Swift program that we can all imagine in a main.swift file:

How to print a program in Swift?

Consider the most simple Swift program that we can all imagine in a main.swift file: print("Hello world!") In Swift if we want to print something, we don't even have to import the Foundation framework, we can simply compile and run this piece of code by running the following:


2 Answers

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

like image 76
Salavert Avatar answered Sep 28 '22 07:09

Salavert


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.

like image 32
ToddX61 Avatar answered Sep 28 '22 05:09

ToddX61