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.
Media unavailable: SpriteKit-120fps-CADisableMinimumFrameDurationOnPhone.pngIf your project doesn't have an info.plist, create an empty file in your project and name it "info.plist":
Media unavailable: SpriteKit-120fps-CreateInfoPlist.pngAdd it to the build settings in Project > Target > Build Settings > Packaging:
Media unavailable: SpriteKit-120fps-BuildSettings.pngThen add the property:
Media unavailable: SpriteKit-120fps-NewInfoPlist.pngConfigure 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.