Reputation: 9733
I am trying to install SocketIO into my swift 4 iOS project using the swift package manager. The Package.swift file looks like this:
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyApp",
dependencies: [
.package(url: "https://github.com/socketio/socket.io-client-swift", .upToNextMajor(from: "12.0.0"))
]
)
On command line when I type 'swift build' the packages are fetched but there is an error:
"warning: no targets to build in package"
When I try to import SocketIO in my app I get:
"No such module 'SocketIO'" error.
This is my first time using Package Manager. Just wondering how to resolve this and whether or not I need to add targets myself in the Package.swift file?
Not sure if I set up Package Manager correctly initially. Also wondering if there is a way to uninstall and reinstall Package Manger? Or is it just a matter of replacing the Package.swift file in the project directory.
Upvotes: 4
Views: 2321
Reputation: 1821
I had the same issue.
I found documentation for SPM v4.
By this link
So, you should try this:
// 1.0.0 ..< 2.0.0
.package(url: "/SwiftyJSON", from: "1.0.0"),
// 1.2.0 ..< 2.0.0
.package(url: "/SwiftyJSON", from: "1.2.0"),
// 1.5.8 ..< 2.0.0
.package(url: "/SwiftyJSON", from: "1.5.8"),
// 1.5.8 ..< 2.0.0
.package(url: "/SwiftyJSON", .upToNextMajor(from: "1.5.8")),
// 1.5.8 ..< 1.6.0
.package(url: "/SwiftyJSON", .upToNextMinor(from: "1.5.8")),
// 1.5.8
.package(url: "/SwiftyJSON", .exact("1.5.8")),
// Constraint to an arbitrary open range.
.package(url: "/SwiftyJSON", "1.2.3"..<"1.2.6"),
// Constraint to an arbitrary closed range.
.package(url: "/SwiftyJSON", "1.2.3"..."1.2.8"),
// Branch and revision.
.package(url: "/SwiftyJSON", .branch("develop")),
.package(url: "/SwiftyJSON", .revision("e74b07278b926c9ec6f9643455ea00d1ce04a021"))
Upvotes: 0
Reputation: 17695
Could you try the following:
.Package
instead of .package
majorVersion: 12, minor: 0
instead of .upToNextMajor
import PackageDescription
let package = Package (
name: "MyApp",
dependencies: [
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 12, minor: 0)
]
)
If successfully built the following will be created:
Package.resolved
will contain the packages used.build
hidden directory is created, these will contain the build files.https://swift.org/getting-started/#using-the-package-manager
Upvotes: 1