red character 'A' without the horizontal bar Achraf Kassioui

Enable 120fps in SpriteKit

Blog / Apple Dev,

By default, SpriteKit renders at 60 fps on all Apple devices. To enable 120 fps on supported devices, follow the steps below.

Configure info.plist

Find the info.plist file in your project, add CADisableMinimumFrameDurationOnPhone to the project's property list, and set its value to true.

SpriteKit-120fps-CADisableMinimumFrameDurationOnPhone.png

If your project doesn't have an info.plist, create an empty file in your project and name it "info.plist":

SpriteKit-120fps-CreateInfoPlist.png
1. Create info.plist.

Add it to the build settings in Project > Target > Build Settings > Packaging:

SpriteKit-120fps-BuildSettings.png
2. Add info.plist to the build settings with the right path to the file.

Then add the property:

SpriteKit-120fps-NewInfoPlist.png
3. Add the refresh rate property in the new info.plist.

Configure SKView

Set the desired frame rate on either SpriteView or SKView:

// SpriteView
struct ContentView: View {
    var body: some View {
        SpriteView(
            scene: MyScene(), // A reference to the SpriteKit scene
            preferredFramesPerSecond: 120 // Framerate
        )
    }
}

// SKView
let skView = SKView()
skView.preferredFramesPerSecond = 120 // Framerate

SpriteKit will automatically adapt its rendering speed to the maximum supported rate on the device. A SpriteKit view running on a 60Hz display will target 60fps. If that view is moved to a 120Hz display, SpriteKit will target 120fps.