简体   繁体   English

使用分叉的 swift 包作为 Vapor 项目的依赖项

[英]Using a forked swift package as a dependency for Vapor project

I've forked a server-side swift package for Firebase realtime db connectivity: ferno and I'm trying to use it as a dependency in my Package.swift like so:我已经为 Firebase 实时数据库连接分叉了一个服务器端 swift 包: ferno ,我试图将它用作我的Package.swift的依赖项,如下所示:

.package(url: "git@github.com:3sidedcube/ferno.git", .branch("jwt3")),

however when running vapor xcode I get an error like so:但是,当运行vapor xcode我收到如下错误:

Error: Could not generate Xcode project: Completed resolution in 8.33s
error: terminated(128): git -C /Users/simonmitchell/Coding/Device-Monitor/.build/checkouts/ferno.git--4002215034454709000 checkout -f 155fa23f2f2d985dbee20072e560b095f61d7b63 output:

I've checked the docs for swift packages and this should all be kosher, so why isn't it working?我已经检查了 swift 软件包的文档,这应该都是 kosher 的,那么为什么它不起作用呢? Is this a limitation of swift package manager?这是 swift 包管理器的限制吗? Or of Vapor?还是蒸气?

There are times when the package build needs to be cleared or reset to get things back on track.有时需要清除或重置包构建才能使事情重回正轨。 The build can be reset with one of the following:可以使用以下方法之一重置构建:

vapor

vapor clean
vapor update
# Updating [Done]
# Changes to dependencies usually require Xcode to be regenerated.
# Would you like to regenerate your xcode project now?
y/n> y
# Generating Xcode Project [Done]
# Select the `Run` scheme to run.
# Open Xcode project?
y/n> y
# Opening Xcode project...

swift package manager快速包管理器

swift package reset # Reset the complete cache/build directory
swift package update
# Fetching https://github.com/vapor/vapor.git
# Fetching https://github.com/vapor/fluent-sqlite.git
# Fetching git@github.com-MY-SSH-HOST:3sidedcube/ferno.git
# ...

swift package generate-xcodeproj
# generated: ./Hello.xcodeproj
open Hello.xcodeproj/

manual build removal手动构建删除

rm -Rf .build
rm -Rf Hello.xcodeproj

Also, in my experience, Swift Package Manager .package(url: "git@github.com…) protocol expects an SSH key pair setup for use with a remote service for both public and private repos. However, the .package(url: "https://github.com…) protocol does not need this setup because https provides a secure transport layer.此外,根据我的经验,Swift Package Manager .package(url: "git@github.com…)协议需要一个 SSH 密钥对设置,用于公共和私有存储库的远程服务但是, .package(url: "https://github.com…)协议不需要这个设置,因为https提供了一个安全的传输层。

ssh key pair ssh 密钥对

If not already done,create and setup a public/private ssh key pair for GitHub.如果尚未完成,请为 GitHub 创建和设置公共/私有 ssh 密钥对。

~/.ssh/config ~/.ssh/config

### GITHUB-MY-SSH-HOST
### ADD REPOSITORY: git@github.com-MY-SSH-HOST:_USER_NAME_/_REPOSITORY_NAME_.git
Host github.com-MY-SSH-HOST
  HostName github.com
  User git
  IdentityFile ~/.ssh/github_privatelocal_rsa
  UseKeychain yes
  AddKeysToAgent yes
  PreferredAuthentications publickey

Note: More recent macOS systems require UseKeychain & AddKeysToAgent to work with Keychain.app注意:较新的 macOS 系统需要UseKeychainAddKeysToAgent才能与Keychain.app

Package.swift包.swift

Expressly declare the defined MY-SSH-HOST in the package git command.在 package git命令中明确声明定义的MY-SSH-HOST

.package(url: "git@github.com:3sidedcube-MY-SSH-HOST/ferno.git", .branch("jwt3"))
],
targets: [
    .target(name: "App", dependencies: ["FluentSQLite", "Vapor", "Ferno"]),
// …

I have discovered this was simply me not knowing enough about the swift package manager.我发现这只是我对 swift 包管理器的了解不够。 After deleting the .build directory and re-trying it all seems to be working properly.删除.build目录并重新尝试后,似乎一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM