Can anyone give me some clue on how can I resolve circular dependency?
What is the circular dependency youâre getting? If you could show your Package.swift and error message that would be great!
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: âMeadowsViewWebâ,
platforms: [
.macOS(.v10_15),
],
products: [
.executable(name: âServerâ, targets: [âServerâ]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/JohnSundell/Ink.git", from:"0.5.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.5.0"),
.package(name:"Prelude",
url: "https://github.com/pointfreeco/swift-prelude.git", .revision("9240a1f")),
.package(url: "https://github.com/JohnSundell/Plot.git", from:"0.8.0"),
.package(url: "https://github.com/vapor/postgres-kit.git", from:"2.0.0"),
.package(name: "Web",
url: "https://github.com/pointfreeco/swift-web.git",
.branch("master")),
],
targets: [
.target(
name: "API",
dependencies: [
"Models",
.product(name:"Fluent", package:"fluent"),
.product(name: "Vapor", package: "vapor"),
]
),
.target(
name: "MeadowsViewWeb",
dependencies: ["API",
.product(name: "HttpPipeline",
package: "Web"),
"Models",
"Prelude",
.product(name: "Vapor",
package: "vapor"),]
),
.target(
name: "Models",
dependencies: [
.product(name: "Vapor", package: "vapor"),
]
),
.target(name: "Server",
dependencies: ["MeadowsViewWeb",]
),
.target(name: "Views",
dependencies: ["MeadowsViewWeb",
]
),
.testTarget(
name: "MeadowsViewWebTests",
dependencies: ["MeadowsViewWeb"]),
]
)
Here is my Package.swift file
when I initialize UserController in config.swift file. Compiler gives this error
Whatâs the error? I canât see anything attached
Error: Cannot find âUserControllerâ in scope
UserController is defined in API directory, while config is inside MeadowsViewWeb directory.
Both API and MeadowsViewWeb directory are the same level of hierarchy wrt directory structure
So assuming youâre getting the error in MeadowsViewWeb
you need to import API
and also make sure the UserController
is public
Do you get the same error from the command line? And does anything in your API do import MeadowsViewWeb
?