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
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.
In WWDC19, Apple announced the support for Swift Package Manager for all of Apple's platforms, including iOS.
To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.
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.
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:
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.
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:
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:
I fixed my problem by opening "Xcode > Preferences > Locations > Command Line Tools" was not filled so I chose one from list
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With