I want to add a new dependency to vapor, but this error comes out - unknown package 'Web3' in dependencies of target 'App'; valid packages are: 'vapor', 'fluent', 'fluent-postgres-driver', 'jwt', 'Web3.swift'
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "w3-wallet-backend",
platforms: [
.macOS(.v10_15)
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),
// 👤 Authentication and Authorization framework for Fluent.
.package(url: "https://github.com/vapor/jwt.git", from: "4.0.0"),
// 💰 blockhain Swift framework.
.package(url: "https://github.com/Boilertalk/Web3.swift.git", from: "0.5.0"),
],
targets: [
.target(
name: "App",
dependencies: [
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
.product(name: "Vapor", package: "vapor"),
.product(name: "JWT", package: "jwt"),
.product(name: "Web3", package: "Web3"),
.product(name: "Web3PromiseKit", package: "Web3"),
.product(name: "Web3ContractABI", package: "Web3")
],
swiftSettings: [
// Enable better optimizations when building in Release configuration. Despite the use of
// the `.unsafeFlags` construct required by SwiftPM, this flag is recommended for Release
// builds. See <https://github.com/swift-server/guides/blob/main/docs/building.md#building-for-production> for details.
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
]
),
.executableTarget(name: "Run", dependencies: [.target(name: "App")]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
]
)
Package name is equal to its repository name, so in your case it should be
.product(name: "Web3", package: "Web3.swift"),
.product(name: "Web3PromiseKit", package: "Web3.swift"),
.product(name: "Web3ContractABI", package: "Web3.swift")
Related
I'm preparing the SPM package, with resources folder. When I compile it for device, it work ok and I got successful. But when I try to build to simulator, I got error: ... bundle format unrecognized, invalid, or unsuitable
What can be wrong?
Tried to make Resource folder empty - no result.
Package.swift
defaults variants with delete DerivenData - no result.
let package = Package(
name: "GPUVideo",
platforms: [
.macOS(.v10_13), .iOS(.v13),
],
products: [
.library(
name: "GPUVideo",
targets: ["GPUVideo"]),
],
dependencies: [
],
targets: [
.target(
name: "GPUVideo",
dependencies: [],
exclude: ["Metal"],
resources: [
.copy("Resources")
])
]
)
Solved by change: .copy on .process
resources: [
.process("Resources")
])
It is unclear to me why its helps
I have SDK that installed with SPM. It works as expected from Xcode 13.2 but on Xcode 13.3 I got this error.
import PackageDescription
let package = Package(
name: "AAA",
products: [
.library(
name: "AAA",
targets: ["AAA"]),
],
dependencies: [
],
targets: [
.binaryTarget(
name: "AAA",
path: "artifacts/BBB.xcframework"
),
.testTarget(
name: "AAATests",
dependencies: ["AAA"]),
]
The artifact name has to match the target name (This is a new Xcode 13.3 thing).
Since your artifact name is BBB.xcframework, the example below should work for you:
let package = Package(
name: "BBB",
products: [
.library(
name: "BBB",
targets: ["BBB"]),
],
dependencies: [
],
targets: [
.binaryTarget(
name: "BBB",
path: "artifacts/BBB.xcframework"
),
]
)
In my case, the only way to solve this was by downloading earlier Xcode version (13.2) from https://developer.apple.com/download/all/
I have the following Package.swift:
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "my-vapor-project",
platforms: [
.macOS(.v10_15)
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent-mysql-driver.git", from: "4.0.0-rc"),
.package(url: "https://github.com/apple/swift-package-manager", .branch("master")),
],
targets: [
.target(name: "App", dependencies: [
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentMySQLDriver", package: "fluent-mysql-driver"),
.product(name: "Vapor", package: "vapor"),
.product(name: "SwiftPM", package: "swift-package-manager")
]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
]
)
When I save the file, Xcode attempts to resolve the dependencies automatically, and I get the following error and warning:
Showing All Messages
/Users/sluther/Projects/my-vapor-project/Package.swift:
product dependency 'SwiftPM' in package 'swift-package-manager' not
found
: dependency 'SwiftPM' is not used by any target
It turns out that at the time of writing, Swift Package Manager could not be included as a dependency when using Swift Tools Version 5.2 which removed the old syntax for defining Product dependencies. Switching the Swift Tools Version to 5.1 resolved the issue.
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "my-vapor-project",
platforms: [
.macOS(.v10_15)
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent-mysql-driver.git", from: "4.0.0-rc"),
.package(url: "https://github.com/apple/swift-package-manager", .branch("master")),
],
targets: [
.target(name: "App", dependencies: [
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentMySQLDriver", package: "fluent-mysql-driver"),
.product(name: "Vapor", package: "vapor"),
"SwiftPM"
]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
]
)
I am trying to create a package for iOS using Swift Package Manager.
I have a Package.swift that looks like this -
import PackageDescription
let package = Package(
name: "MyPackage",
platforms: [.iOS(.v12)],
products: [
.library(name: "MyPackage", targets: ["MyPackage"]),
],
dependencies: [
.package(url: "https://github.com/yannickl/AwaitKit", from: "5.0.0"),
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.0.0"),
.package(url: "https://github.com/OAuthSwift/OAuthSwift", from: "2.0.0")
],
targets: [
.target(name: "MyPackage", dependencies: []),
.testTarget(name: "MyPackageTests", dependencies: ["MyPackage"]),
]
)
But my project does not build, my classes that reference these dependencies say they do not exist and I also get a warning in Xcode that there are no targets using these dependencies.
I tried to update targets as follows -
targets: [
.target(name: "MyPackage", dependencies: ["AwaitKit","KeychainAccess","OAuthSwift"]),
.testTarget(name: "MyPackageTests", dependencies: ["MyPackage"]),
]
But this made no difference?
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"]),
]
)
please follow this instruction to add dependencies to your Swift project:
create a blank folder with your project name.
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
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.
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"]),
]
)`