How do I nicely wrap a C library (SDL)?

OK, here’s a quick question: Do the types you care about support retain and release semantics? Looking at the SDL docs, I see SDL_CreateWindow and SDL_DestroyWindow, but nothing like SDL_Retain or SDL_Release.

If not, bridging them to Swift as classes is going to be problematic because Swift objects (and Objective-C objects, and CF objects) all require that.

As an aside: I wish Apple would spend more effort in improving this
aspect of using Swift outside of Apple platforms.

That’s not something I can help with, other than to suggest that you raise your concerns over on Swift Evolution.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like