How to decide what to put for majorVersion and minor in below code.
I was trying to use sqlite3 with vapor and got stuck here.
import PackageDescription
let package = Package(
name: "Hello",
dependencies: [
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1)
,.Package(url: "https://github.com/vapor/sqlite-driver.git", majorVersion: 1, minor: 0)
,.Package(url: "https://github.com/vapor/sqlite-provider.git", majorVersion: 1, minor: 1)
],
exclude: [
"Config",
"Database",
"Localization",
"Public",
"Resources",
"Tests",
]
)
I am getting error as below when I do vapor build -
Fetching Dependencies [Failed] Check your dependencies' Package.swift
files to see where the conflict is. Error: swift-package: error: The
dependency graph could not be satisfied. The package
(https://github.com/vapor/sqlite-driver.git) with version tag in range
(1.1.0..<1.1.9223372036854775807) is not found. Found tags ([0.0.0,
0.1.0, 0.1.1, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.4.0, 0.4.1, 0.5.0, 0.6.0, 0.7.0, 1.0.0, 1.0.1])
The 'dependency graph' error relates to one of your packages depending on a conflicting version of another package. The error messages tells you to 'Check your dependencies' Package.swift files to see where the conflict is.'
You don't need to include both sqlite-driver and sqlite-provider as the latter already has a built-in dependency on the former. Simply remove the dependency on sqlite-driver from your app's Package.swift. Also make sure to vapor clean afterwards.
import PackageDescription
let package = Package(
name: "Hello",
dependencies: [
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1),
.Package(url: "https://github.com/vapor/sqlite-provider.git", majorVersion: 1, minor: 1)
],
exclude: [
"Config",
"Database",
"Localization",
"Public",
"Resources",
"Tests",
]
)
Note: Vapor is now at version 1.2 so you might want to change the version you are pulling in.
Related
My new Swift project is not building with the latest version of Antlr4.
I have created projects similar projects before (with Antlr 4.10), but I am only getting issues with Antlr 4.11 and 4.11.1 .
I get the following error
https://github.com/antlr/antlr4 # 4.11.1: error: /Package.swift has no Package.swift manifest for version 4.11.1 in https://github.com/antlr/antlr4
Below is my Package.swift file
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "spl-swift",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
//.package(url: "/private/tmp/Antlr4-tmp-1663142993", from: "4.0.0")
.package(url: "https://github.com/antlr/antlr4", from: "4.11.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "spl-swift",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"Antlr4"
]),
.testTarget(
name: "spl-swiftTests",
dependencies: ["spl-swift"]),
]
)
I don't know why I was getting this problem with 4.11.1 but I was able to get it working by downloading release 4.10.1 and using it as a local dependency
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "spl-swift",
dependencies: [
.package(name: "Antlr4", path: "~/Downloads/antlr4-4.10.1"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
//.package(url: "https://github.com/antlr/antlr4", from: "4.11.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "spl-swift",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"Antlr4"
],
exclude: [
"Lang.tokens",
"LangLexer.interp",
"LangLexer.tokens",
"Lang.interp"
]),
.testTarget(
name: "spl-swiftTests",
dependencies: ["spl-swift"]),
]
)
I'm using Xcode12.5 and swift version 5.4. When I try to build my project I get this error: The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax.
My Package.swift file:
import PackageDescription
let package = Package(
name: "NeedleFoundation",
products: [
.library(name: "NeedleFoundation", targets: ["NeedleFoundation"]),
.library(name: "NeedleFoundationTest", targets: ["NeedleFoundationTest"])
],
dependencies: [],
targets: [
.target(
name: "NeedleFoundation",
dependencies: []),
.testTarget(
name: "NeedleFoundationTests",
dependencies: ["NeedleFoundation"],
exclude: []),
.target(
name: "NeedleFoundationTest",
dependencies: ["NeedleFoundation"]),
.testTarget(
name: "NeedleFoundationTestTests",
dependencies: ["NeedleFoundationTest"],
exclude: []),
],
swiftLanguageVersions: [.v5]
)
#if compiler(>=5.4)
package.dependencies += [
.package(url: "https://github.com/apple/swift-format", .branch("swift-5.4-branch"))
]
#elseif compiler(>=5.3)
package.dependencies += [
.package(url: "https://github.com/apple/swift-format", .branch("swift-5.3-branch"))
]
#endif
And then I run : swift run swift-format
After that when I try to build my project I receive the same error:
The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax.
Am I missing something?
From my research so far on this same problem, the issue is that whatever swift tool you are running (swift-format in this case) depends in the SwiftSyntax package and is not compatible with whatever version of Xcode (toolchain) you are using. You likely need to downgrade the version of Xcode you are using/the tool looks for. Still not sure what the best way to do that is though.
I'm trying to import this dependency:
https://github.com/PureSwift/CFreeType
but I am getting this error:
Fetching https://github.com/PureSwift/CFreeType.git
error: dependency graph is unresolvable; found these conflicting requirements:
Dependencies:
https://github.com/PureSwift/CFreeType.git # 1.0.4
The repo has a 1.0.4 tag. Am I doing something wrong?
Here is my Package.swift:
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "SwiftPlot",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SwiftPlot",
targets: ["AGG", "lodepng", "CPPAGGRenderer", "CAGGRenderer", "SwiftPlot", "SVGRenderer", "AGGRenderer"]),
],
dependencies: [
.package(url:"https://github.com/PureSwift/CFreeType.git", .exact("1.0.4")),
],
targets: [
//relevant targets
],
cxxLanguageStandard: .cxx11
)
Im trying to learn the ropes of Twilio. The goal is to send text messages from my app. Im following this getting started guide
At the last step is to run this command in terminal: (yes I have changed SwiftSMSwith my own project name)
swift build && ./.build/debug/SwiftSMS
This command results in the following:
MyMac:MyProject MyName$ swift build && ./.build/debug/myProject Compile
Swift Module 'myProject' (1 sources)
/Volumes/myProject/myProject/Sources/myProject/main.swift:2:8: error:
no such module 'Alamofire'
import Alamofire
^ error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool
-f /Volumes/myProject/myProject/.build/debug.yaml main output:
I have not done any config with Twilio in Xcode yet. As far as I can understand from the guide should this send a message without doing anything in Xcode?
EDIT*:
Package.swift:
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "myProject",
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.0")
],
targets: [
.target(
name: "myProject",
dependencies: ["Alamofire"]),
.testTarget(
name: "myProjectTests",
dependencies: ["Alamofire"]),
]
)
Use this as your Package.swift - you can't simply say "Alamofire" and expect SPM to magically know where to get the sources from.
import PackageDescription
let package = Package(
name: "myProject",
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.0")
],
targets: [
.target(
name: "myProject",
dependencies: ["Alamofire"]),
.testTarget(
name: "myProject Tests",
dependencies: ["Alamofire"]),
]
)
I have following Package.swift file:
import PackageDescription
let package = Package(
name: "MultiTargetTest",
products: [
.executable(
name: "MultiTargetTest",
targets: ["MultiTargetTest"]),
],
dependencies: [
.package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0")
],
targets: [
.target(
name: "MultiTargetTest",
dependencies: ["SwiftyJSON", "IndependentTarget"]),
.target(
name: "IndependentTarget",
dependencies: []),
.testTarget(
name: "MultiTargetTestTests",
dependencies: ["MultiTargetTest"]),
]
)
Here I don't want any dependency on IndependentTarget target, but actually in code I can import SwiftyJSON in IndependentTarget target without any problem.
Here is my code structure:
Here Demo.swift is in IndependentTarget and I have access to SwiftyJSON framework.
How should I define the target IndependentTarget so that it should not have access to dependencies in different target?
Update: I noticed that for first time when I run swift build it gives error but after that it runs fine.
Here's screenshot: