0

Hi i am learning Swift perfect backend i am stuck how to add mongodb dependencies in my project, If someone know how to do please help me

import PackageDescription

let package = Package(
    name: "SwiftBackend",
    products: [
        .library(name: "PerfectMongoDB", targets: ["PerfectMongoDB"])
    ],

    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"),
        .package(url: "https://github.com/PerfectSideRepos/Perfect-CMongo.git", from: "0.0.0"),
        .package(url: "https://github.com/PerfectSideRepos/Perfect-CBSON.git", from: "0.0.0"),
        .package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0")
    ],
    targets: [
        .target(
            name: "SwiftBackend",
            dependencies: ["PerfectHTTPServer" , "PerfectLib" , "PerfectMongoDB"]),
        ]
)
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116

2 Answers2

0

please follow this instruction to add dependencies to your Swift project:

  1. create a blank folder with your project name.
  2. Inside this folder, use swift package init --type=executable to initialize the Package.swift automatically:

In your case, it looks like this:

$ mkdir SwiftBackend && cd SwiftBackend && swift package init --type=executable
  1. modify the dependencies. Should be like this:

    // swift-tools-version:4.0 import PackageDescription

    let package = Package( name: "SwiftBackend", dependencies: [ .package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"), .package(url: "https://github.com/PerfectlySoft/Perfect-MongoDB.git", from: "3.0.0"), ], targets: [ .target( name: "SwiftBackend", dependencies: ["PerfectHTTPServer", "PerfectMongoDB"]), ] )

there may be some warnings but should work without any issues.

PerfectlyRock
  • 405
  • 2
  • 7
  • Hey PerfectlyRock i want ask more question plz ping me if u will be free to ans me... swiftdeveloper11@gmail.com i want to know about deployment of perfect server. – Swift Learner Jun 29 '18 at 06:07
0

i found the ans its `import PackageDescription

let package = Package( name: "SwiftBackend",

products: [
    .library(name: "PerfectMongoDB", targets: ["SwiftBackend"])
],

dependencies: [
    // Dependencies declare other packages that this package depends on.
    .package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"),
    .package(url: "https://github.com/PerfectlySoft/Perfect-MongoDB.git", from: "0.0.0"),
    .package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0")
],
targets: [
    .target(
        name: "SwiftBackend",
      dependencies: ["PerfectHTTPServer" , "PerfectLib" , "MongoDB"]),
    ]

)`

  • Wrong tag Perfect-MongoDB "0.0.0" should be at least "3.0.0" Don't include PerfectLib explicitly, Perfect-HTTPServer has already had it. – PerfectlyRock Jun 29 '18 at 13:12
  • hey PerfectlyRock i need ur help , i am trying to deploy my backend with herkou but stuck in some point not able to recognise what isthe issue :-Build failure: Sorry, only Ubuntu 14.04 is currently supported, – Swift Learner Jun 30 '18 at 05:37
  • I haven't seen users of Perfect+Heroku for two years while Perfect has many many updates; anyway Perfect 3 only support Ubuntu 16.04. You can goto http://perfect.ly to get instant support, anyway. – PerfectlyRock Jun 30 '18 at 13:46