将 frameworks/packages 添加到 Kitura macOS
Adding frameworks/packages to Kitura macOS
我正在尝试按照此处所述扩充示例 Kitura 服务器端应用程序:http://www.kitura.io/en/starter/gettingstarted.html。按说明工作。然后我尝试添加 Kitura-Stencil 包 (package.swift):
let package = Package(
name: "Kitura-macOS",
dependencies: [
.package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.1.0")),
.package(url: "https://github.com/IBM-Swift/Kitura-StencilTemplateEngine.git", .upToNextMajor(from: "1.7.0")),
.
.
],
targets: [
.target(name: "Kitura-macOS", dependencies: [ .target(name: "Application"), "Kitura" , "HeliumLogger", "KituraStencil"]),
.target(name: "Application", dependencies: [ "Kitura", "CloudEnvironment","SwiftMetrics","Health", "KituraStencil"])
.
.
]
)
我添加了一些代码来使用 Stencil
import KituraStencil
.
router.add(templateEngine: StencilTemplateEngine())
.
try response.render("test.stencil", context: context2).end()
这在我从命令行 build/run 时起作用:
.build/debug/Kitura-macOS
open Kitura-macOS.xcodeproj/
# (add code as described)
swift run Kitura-macOS
但是当我尝试从 XCode 中 build/run 时,它找不到 Kitura-Stencil。
No such module 'KituraStencil'
我想我需要将它作为框架添加到构建阶段中,但无法在任何地方找到它来添加。
您必须在更新项目结构后重新生成 Xcode 项目,例如在添加依赖项、添加新源文件等之后
您需要重新生成 Xcode 项目:
swift package generate-xcodeproj
这是对 package.swift 文件进行任何更改所必需的。
我正在尝试按照此处所述扩充示例 Kitura 服务器端应用程序:http://www.kitura.io/en/starter/gettingstarted.html。按说明工作。然后我尝试添加 Kitura-Stencil 包 (package.swift):
let package = Package(
name: "Kitura-macOS",
dependencies: [
.package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.1.0")),
.package(url: "https://github.com/IBM-Swift/Kitura-StencilTemplateEngine.git", .upToNextMajor(from: "1.7.0")),
.
.
],
targets: [
.target(name: "Kitura-macOS", dependencies: [ .target(name: "Application"), "Kitura" , "HeliumLogger", "KituraStencil"]),
.target(name: "Application", dependencies: [ "Kitura", "CloudEnvironment","SwiftMetrics","Health", "KituraStencil"])
.
.
]
)
我添加了一些代码来使用 Stencil
import KituraStencil
.
router.add(templateEngine: StencilTemplateEngine())
.
try response.render("test.stencil", context: context2).end()
这在我从命令行 build/run 时起作用:
.build/debug/Kitura-macOS
open Kitura-macOS.xcodeproj/
# (add code as described)
swift run Kitura-macOS
但是当我尝试从 XCode 中 build/run 时,它找不到 Kitura-Stencil。
No such module 'KituraStencil'
我想我需要将它作为框架添加到构建阶段中,但无法在任何地方找到它来添加。
您必须在更新项目结构后重新生成 Xcode 项目,例如在添加依赖项、添加新源文件等之后
您需要重新生成 Xcode 项目:
swift package generate-xcodeproj
这是对 package.swift 文件进行任何更改所必需的。