Build Cairo for iOS

Does anyone have any notes or tips on building Cairo for iOS? I’m hoping to use it for rendering SVG to textures and, while it seems doable (or seems to have been done by others), I’m not sure I’m configuring and making the library correctly for the armv7/arm64 architecture.

All I found on Cinder Forums were the conversations back here on the old forum:

Any tips/recipes greatly appreciated! Or if I find a solution or workaround, I’ll share.

Hey - just to confirm, are you not able to use the CinderBlock? It should support iOS.

Building Cairo, particularly on iOS, is quite a chore, so if you can avoid it I would.

The Cairo block isn’t appearing in Xcode automatically for me when I create iOS app via TinderBox, either with my own templates or with the Basic OpenGL template.

After adding in the block, I’m running into a couple issues in cairo-quartz and with font support, will see if I can work around them…

No, I think it seems that I run into the same linking error, that Cairo symbols aren’t found for arm64.

I should note that I was able to get Cairo working in my iOS project when in the simulator, just not once I plugged in an actual iPad.

I’m going to spend the night seeing if I can compile Cairo for iOS, if not, I’d be curious to hear other folks’ approaches for SVG to Cinder texture on iOS. At one point, I began and then left off with NanoVG, and I’ve seen some comments about using CoreAnimation (? I think?) but wasn’t keen on it…

Wow! Well, I’ve learned that I find building libraries for iOS mind-boggling, and confess to mostly banging about like an ape.

But, I just stumbled on this five day old repository on github:

Cloned it, built libraries for both Debug-iphonesimulator and Debug-iphoneos, and merged into one with lipo.

Added that library, along with pixman headers and the libpixman-1.a library* uploaded here:
to my project.
*(It turns out the same fellow from before has an iOS pixman Xcode project as well. )

My project now runs on a connected iPad! But not in the simulator, where I am now missing my required i386 architecture. Perhaps another lipo will fix that…

I confess I don’t know if this passes muster for a release into the apple store, but believe I can at least hobble through an upcoming event…

(I should say also that text in SVGs is appearing, but very small. I’m okay with that at the moment as we’re planning on converting all text in SVGs to outlines anyway.)

Yes, seems to be working but I’ve had to kill all the code in Cairo.cpp, Context::setFont because it relies on cairo_quartz_font_face_create_for_cgfont, which isn’t available in Mr. Ohshima’s iOS build. I believe that’s why any text in SVG appears small/incorrect.

However, it seems like someone might have a solution for getting quartz font support on iOS:

Per Andrew’s question about the CinderBlock, I’m not sure entirely sure if this is interesting or valuable to anyone else, or if I’m the only one who had issues with Cairo on iOS, so going to let it go for now!

I kept coming across this post while trying to build Cairo myself and @planimal’s suggestion is what steered me in the right direction in the first place. I’ve combined Yoshiki Ohshima’s cairo and Henry Song’s cairo for nsgl to make cairo-nsgles. I get 60fps right now running Cairo Gears you can find this work so far here: and here: I’m thinking about exploring LibCinder much more now that I have this built. Once again a big thanks to @planimal there is not much information out there for people trying to test out accelerated Cairo graphics on Apple devices natively.

1 Like

That’s great, I’m glad my stumbling about could help! My Cinder+Cairo-on-iOS setup here is still working 10 months and a few projects later, but I confess I never did get fonts working (still converting everything to outlines, sigh), and I haven’t really profiled the performance, and basically feels like I put duct tape on the whole thing.

When I’m able, will try to check out your work, looks like would be an improvement on my current setup!

Yes the fonts can be problematic- I just tested them on the IPhone and your right in your previous post the Quartz backend is not included so I’m going to create an issue to port those over as well. I got CairoGears running but just tested the fonts and the Quartz backend will need to be moved. Cairo-nsgl is able to use the Quartz backend and TTF fonts then translate them over to the GL surface. Glyphs work too- I made some in InkScape and was able to see them displayed on the GL surface with TTF anti-aliasing. I will go ahead and make an update here when I get some more progress on that.