I just started with swift 3 and made a simple app in xcode using Swift 3.0. Now i want to add a third party library using Swift Package Manager. I am following installation method given in this link. I created Package.swift
file which looks like this
import PackageDescription
let package = Package (
name : "SwiftPM",
dependencies : [
.Package(url: "https://github.com/ArtSabintsev/Siren.git", majorVersion: 1)
])
but i get error No such module "PackageDescription"
The Swift Package Manager and Xcode are orthogonal. That is, you can't expect to compile Package.swift in Xcode; it simply won't work. Instead, until Xcode supports the package manager, you need to have two distinct builds - one with the package manager and one with Xcode.
So, using the Swift Package Manager, once you've defined Package.swift and formulated your directory structure as expected by the package manger, you perform simply:
swift build
Then for Xcode, you create an Xcode project that uses your source code, but not Package.swift. You'll need to clone the Siren.git project, explicitly - into your Xcode build's source files.
Swift 3/4
Navigate to your project folder through a terminal and run these commands swift package init --type library
first and then swift package generate-xcodeproj
Refer to the solution in this link:
https://forums.kodeco.com/t/server-error-no-such-module-packagedescription/177438
Command:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
For other people who faced the same error as this:
Package.swift
syntaxI got this error because Xcode hadn't parsed Package.swift
fully yet, because of syntax errors.
In my case, I had a .target(name: "name-of-target", dependencies: [""])
. As soon as I removed the empty dependency string ( ""
) , Xcode immediately parsed the file, and the error disappeared. Remember to save the file though.
swift package generate-xcodeproj
is deprecated, shown by the error message when using it: warning: Xcode can open and build Swift Packages directly. 'generate-xcodeproj' is no longer needed and will be deprecated soon.]
More information about what that is, and why its gone here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.