Using JLFGameplayKit in Swift projects

29 Jul 2015

Short story: I need to figure out how to build JLFGameplayKit as a framework so this just works, but in the meantime, you can use a Bridging Header.

Long story: clone the JLFGameplayKit repository, or download the code in some other way. Copy the JLFGameplayKit directory (where all the library source is, not the demos) into your Swift project.

Then open up your build target and go into the Build Settings panel:

Settings bridging header

Search for “Bridging” to find the “Objective-C Bridging Header” setting. Stick the project-relative path to JLFGameplayKit.h in there.

Now you should be able to just use the classes directly in your Swift code without complaint:

It compiles, at least

Note: I’ve only tested this far enough to make sure that it compiles; I’m about ready to get started on a new demo for obstacle based pathfinding, and that sounds like a good time to give Swift a try. :)