By default arc4random is not available in Swift on Linux. In order to enable it:

  • Install the BSD library
    apt-get install libbsd-dev
    dependencies: [
        .package(url: "https://github.com/dudash/swift-package-clibbsd.git", from: "1.0.0"),
    ]
  • Import ClibBSD in Swift files that require arc4random
    #if os(Linux)
        import ClibBSD
    #endif