2

SlackKit我用Swift写了一个 Slackbot 4.0我遵循了Peter Zignego的一个非常简单易懂的教程

他在Heroku部署了他的机器人

所以出现的第一个问题是我使用了一个数组扩展,它给我一个给定集合中的随机项:

extension Array {
    /// Picks `n` random elements (partial Fisher-Yates shuffle approach)
    subscript (randomPick n: Int) -> [Element] {
      var copy = self
      for i in stride(from: count - 1, to: count - n - 1, by: -1) {
          copy.swapAt(i, Int(arc4random_uniform(UInt32(i + 1))))
      }
      return Array(copy.suffix(n))
    }
}

使用此代码,我没有任何构建问题,我想将我的代码推送到,Heroku但在运行时抛出部署会发生错误:

error: use of unresolved identifier 'arc4random_uniform'

搜索后我发现了一个 Swift 报告的Bug并将我的代码更改为:

extension Array {
    /// Picks `n` random elements (partial Fisher-Yates shuffle approach)
    subscript (randomPick n: Int) -> [Element] {
        var copy = self
        for i in stride(from: count - 1, to: count - n - 1, by: -1) {
            #if os(Linux)
                copy.swapAt(i, Int(random() % (i + 1)))
            #else
                copy.swapAt(i, Int(arc4random_uniform(UInt32(i + 1))))
            #endif

         }
         return Array(copy.suffix(n))
    }
}

现在我的代码已成功推送和部署Heroku

但是当我想在我的Slack频道中启动机器人时,例如:

rf24-dev-mac-1:support-dialer konstantin$ heroku run:detached slackbot
Running slackbot on ⬢ support-dialer... done, run.1246 (Free)
Run heroku logs --app support-dialer --dyno run.1246 to view the output.

并运行输出命令我得到这个:

2017-09-25T13:37:27.762135+00:00 heroku[run.1246]: Starting process with command `.build/release/support-dialer`
2017-09-25T13:37:28.335452+00:00 heroku[run.1246]: State changed from starting to up
2017-09-25T13:37:29.842073+00:00 heroku[run.1246]: Process exited with status 127
2017-09-25T13:37:29.779834+00:00 app[run.1246]: .build/release/support-dialer: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
2017-09-25T13:37:29.856440+00:00 heroku[run.1246]: State changed from up to complete

所以我不知道我能做些什么来解决这个问题,因为它不会启动 Slackbot,当我点击部署链接时,Heroku它也说有一个错误。

4

0 回答 0