Error occurring from p.431 code, Swift 4 Version

When I add the code at the top of page 431, I get an error saying:

Type ‘Int’ has no member ‘random’

Any suggestions?

Do you have SKUtils included in your project and your target?

Int+Extensions.swift has a random(_:) function that extends Int

Do you mean SKTUtils?

SKTUtils was included in the file but not the target. After manually adding it the target, the error went away. Thank you.

@salanthonyc - Yes I did mean SKTUtils. Glad you got it fixed.

Xcode 9 has an annoying habit of sometimes not adding imported files to the targets, and of course if the files aren’t included in the target, then they’re not included in your app. Watch out especially for images not importing, as they won’t cause a compile time error.

This topic was automatically closed after 166 days. New replies are no longer allowed.