0

So I just started using RemObject's Swift compiler, Silver, but it doesn't seem to recognize the function arc4random_uniform(). I have tried researching this problem but could not fin an answer. Here is my code:

let randomNumber: UInt32 = arc4random_uniform(100)
println(randomNumber)

The console gives me this error message:

(E46) Unknown identifier "arc4random_uniform"

Is there something wrong with my code, or do I have to import or configure something?

Alex
  • 13
  • 1
  • 7
  • 1
    Leaving aside the ancient `println` (Swift 1.2?), you could try to double-check that you've imported `Foundation` (or `Darwin`). If these are not accessible, you might consider using `random()` accessible by importing `Glibc`. – dfrib Jan 20 '17 at 10:17
  • Whenever I try to import something it gives me an error message: '(E26) Unknown namespace "Darwin" in uses list'. I tried using just the regular print() before but it didn't work and told me to use println(). Maybe it's outdated? – Alex Jan 20 '17 at 10:20
  • I haven't used RemObjects Silver, but it seems your compiler is set to using the ancient Swift 1.2 (or you wouldn't be prompted using the ancient `println(..)`). Regarding `arc4random_uniform`, there is an open bug report, [SR-685](https://bugs.swift.org/browse/SR-685), which describes that there is no `arc4random_uniform()` function in Glibc. See also [this thread](https://developer.ibm.com/answers/questions/317215/having-issues-using-arc4random-uniform.html). – dfrib Jan 20 '17 at 10:25
  • I looked and copied the answer in the forum, but got the same error messages for import and random(). I can't seem to be able to import anything, is that worth another question? – Alex Jan 20 '17 at 11:15

0 Answers0