0 Replies
      Latest reply on Feb 2, 2018 8:48 PM by agaus
      agaus Level 1 Level 1 (0 points)



        SKAction: Error loading sound resource: "audio/1.mp3"

        Code (GameScene.swift):


        import GameplayKit
        class GameScene: SKScene {
            var count = 0
            override func didMove(to view: SKView) {
            func infiniteLoop() {
                let number = count % 3 + 1
                let playLetter = SKAction.playSoundFileNamed("audio/\(number).mp3", waitForCompletion: true)
                self.run(playLetter, completion: {
                    self.count += 1


        Audio Files:


        Reproducing The Error:

        The error appears to be reproducible by simply making a new iOS game in Xcode, copying the "audio" (assets) folder linked above into the root of the project, and copying the code above into the GameScene.swift file. After getting to "250" in the console the error will likely appear.



        After cycling through two or more audio files 250 times, the app fails to load the audio resource. I encountered this problem while making a spelling game which cycles through images and audio files in a similar manner. The problem originally presented itself by failing to load both the image files and the audio files after the app being used for ~15 minutes. I've managed to strip the app down to this core code and still trigger the error regardless of whether I simulate on my computer, simulate on my iPad, or even export and install (Ad Hoc) on my iPad.


        I'm new to Swift and am hoping there is something simple at play here. Please let me know if you have any suggestions on how to fix this error.