Search code examples
swiftmacoskitura

Adding frameworks/packages to Kitura macOS


I am trying to augment the sample Kitura Serverside application as described here: http://www.kitura.io/en/starter/gettingstarted.html. Works as stated. I then try to add the Kitura-Stencil package (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"])
      .
      .
    ]
)

I add some code to use Stencil

import KituraStencil
 .
router.add(templateEngine: StencilTemplateEngine())
 .
try response.render("test.stencil", context: context2).end()

This works when I build/run from the command line:

.build/debug/Kitura-macOS
open Kitura-macOS.xcodeproj/
# (add code as described)
swift run Kitura-macOS

But when I try to build/run from within XCode, it can't find Kitura-Stencil. No such module 'KituraStencil' I think I need to add it in Build Phases as a framework, but can't find it anywhere to add.


Solution

  • You have to regenerate your Xcode project after you update your project structure, for example after adding a dependency, adding a new source file, etc.