SpriteKit & Box2D

Hi,

I integrated SpriteKit with Box2D version 3, and they work amazingly well together. I shared videos, code, and implementation notes on the project page:

SpriteKit Box2D

Context

SpriteKit built-in physics engine is based on Box2D, likely from an older 2.x generation. This project uses Box2D 3.x directly.

Box2D 3.0 was first released in 2024 as a major rewrite with a new C API. It brings improved collision handling, better performance, better stability for demanding simulations, and features that are not exposed through SpriteKit’s SKPhysicsWorld.

Box2D 3 is also designed with determinism in mind. SpriteKit's physics implementation is nice to use, but it is not deterministic. See the Determinism section of my SKRenderer Demo for more information about determinism in SpriteKit.

Swift & C

Because Box2D 3 is written in C, this sample app also shows how to mix Swift and C in the same Xcode project. I wrote a tutorial on how to mix Swift with C in an Xcode project.

I hope this is useful to anyone experimenting with SpriteKit physics or external C libraries. Let me know if you have questions or ideas.

SpriteKit & Box2D
 
 
Q