swiftherokukitura

Kitura Swift App not compiling on Heroku


Create a Kitura app locally and compiles and builds successfully. But when attempting to deploy to heroku after a while, I get the following output:

/tmp/build_cbc1c98480abd8ace78731a677031c0a/.build/checkouts/Kitura.git--211144618449703330/Sources/Kitura/RouterRequest.swift:56:33: error: use of unresolved identifier 'RegularExpression'remote: let regex = try RegularExpression(pattern: pattern, options: [.caseInsensitive]) remote: ^~~~~~~~~~~~~~~~~ remote: Foundation.NSRegularExpression:1:12: note: did you mean 'NSRegularExpression'? remote: open class NSRegularExpression : Foundation.NSObject, NSCopying, NSCoding {

The version of swift used is 3.1 and I specified the same version when pushing to heroku via the .swift-version file.

This is the Package.swift used

Version of Kitura used is 1 major 7 minor

Trying other versions of swift e.g. 3.1.1 results in hanging - to the point that heroku cancels due to timeout. Any help will be much appreciated. Thanks


Solution

  • First, please note that you experience discrepancies of Swift on Mac and on Linux. You probably checked it on your Mac, while Heroku runs Linux.

    Second, RegularExpression was replaced by NSRegularExpression in this pull request https://github.com/IBM-Swift/Kitura/pull/1107. You should not experience this problem starting from Kitura 1.7.4. It means that you probably use Kitura version before 1.7.4, that could happen if you have Package.pins file that specify an old Kitura version. You can either remove that file, or run swift package update to update it.

    To verify the actual version of the Kitura package used, cd to .build/checkouts/Kitura.git-XXXXXXXXXXX directory, run git tag there and check the latest tag.