I have been trying for days to add the fluent-mysql dependancy to my vapor project in order to query my separate mysql database from within the project. However I always seem to get some sort of error eg when I try vapor update
it never completes. (I have left it for hours in the past), I also tried swift package update
but that had the same error. I am now at the point where vapor update
works however I am still getting two errors 'mysql/udf_registration_types.h' file not found with <angled> include; use "quotes" instead
'mysql/udf_registration_types.h' file not found with <angled> include; use "quotes" instead
and Could not build Objective-C module 'CMySQL'
the only thing I have changed from the vapor web template is package.swift
which is now this:
import PackageDescription
let package = Package(
name: "iPadLocator",
products: [
.library(name: "App", targets: ["App"]),
.executable(name: "Run", targets: ["Run"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.2.0")),
.package(url: "https://github.com/vapor/leaf-provider.git", .upToNextMajor(from: "1.1.0")),
.package(url: "https://github.com/vapor/fluent-mysql.git", .upToNextMajor(from: "2.0.0"))
],
targets: [
.target(
name: "App",
dependencies: ["Vapor", "LeafProvider", "MySQLDriver"],
exclude: ["Config", "Database", "Public", "Resources"]
),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App", "Testing"])
]
)
Thanks in advance for any help in advance. This is my first stackOverflow question so sorry if it is awful. I am running vapor Toolbox 3.1.7
and Vapor framework 2.4.4
, I have both mysql
and cmysql
installed and up to date.
Do you want to use Vapor 2 or Vapor 3? (Ignore the version of the toolbox). If you want Vapor 2 then what you have is correct - you just need to change the dependency from MySQLDriver
to MySQLProvider
.
If you want Vapor 3 then you need to change all your dependencies to something like
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "TILApp",
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/fluent-mysql.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/leaf.git", from: "3.0.0-rc"),
],
targets: [
.target(name: "App", dependencies: ["FluentMySQL", "Vapor", "Leaf"]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App"]),
]
)
The reason you are getting those errors is because Vapor 3 does not contain “Droplet” “Resource”or “ResourceRepresentable” types. Good news is that you successfully installed the vapor 3 dependencies bad news is it looks like in order to use them you will have to make your project vapor 3 ish. Good news, vapor 3 is more performance then Vapor 2.
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.