Question: I'm working with Swift in Ubuntu, and I am getting an error that arc4random is an unresolved identifier. More information on this known bug [here](https://bugs.swift.org/browse/SR-685). Basically, the function only exists in BSD distros. I've tried module mapping header files, apt-getting packages, and I get more and more errors, which is not worth pursuing since this one function is not used very often.

Are there any functions to get pseudo random numbers with an upper-bound parameter that is compatible with Swift in Linux?

Answer: 
I went with something like this for 4-digit random numbers:

```
#if os(Linux)
 srandom(UInt32(time(nil)))
 randomString = String(format: "%04d", UInt32(random() % 10000))
#else
 randomString = String(format: "%04d", Int(arc4random_uniform(10000)))
#endif

```

Edit: Note that the call to `srandom(UInt32(time(nil)))` should be outside a function/loop, otherwise it will produce the same value over and over again
You could try something like this? 

```
    #if os(Linux)
       random()
    #else
        arc4random_uniform()
    #endif

```