17

I want to render SVG images in iPhone without using a UIWebView. How can I do that?

I have checked these 2 links:

http://www.splashdust.net/2010/09/svgquartzrenderer-a-basic-iphone-sdk-compatible-svg-renderer/ https://github.com/splashdust/SVGQuartzRenderer

The above project on Github shows 102 errors showing UIKit framework missing and others and I are also not able to add that framework. I think the application is for MacOS not for iOS.

http://maniacdev.com/2011/05/open-source-library-to-render-svg-graphics-as-core-animation-layers/
https://github.com/mattrajca/SVGKit

The project on the above url shows the error when i build the project.

Target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iPhoneOS' platform.

Does anyone know how to solve that? Or other useful working examples that I can use for that? I want to render SVG's on iPhone.

UPDATE: I have got working SVGKit working by reading instructions. But when I tried to make project working which iI downloaded from Github (https://github.com/splashdust/SVGQuartzRenderer ) I got following errors:

1) UIKit/UIKit.h: No such file or directory (I am not able to add it using add existing framework)
2) Libxml/tree.h: No such file or directory
3) Expected specifier-qualifier-listbefore 'xmlParserCtxtPtr'. Does anyone know that how to resolve it and make it work?

The Guardian
  • 374
  • 1
  • 7
  • 22
nehal
  • 297
  • 2
  • 5
  • 12

3 Answers3

20

Jason Morrissey, author of the extremely excellent Alien Blue app, the best iOS Reddit client on the store (can you tell I'm a fan? I'm also a beta tester.) recently put up his SVGKit framework, which renders SVG images as Core Animation layers. I haven't used it, but I know it exists.

And then, look... if you're just getting lots of errors when you bring in other people's classes, my strong suspicion is that you're not following their "how to use" instructions. They'll mostly tell you what frameworks are required and what platforms they support. Every time I've tried to use something like this and had a compilation bloodbath, I've gone back and found some installation instruction step I missed.

dcow
  • 7,765
  • 3
  • 45
  • 65
Dan Ray
  • 21,623
  • 6
  • 63
  • 87
6

I just managed to compile SVGFlashRenderer. For iOS you need to open the project from the directory SVGRendererTouch. And don't forget to separately download contents of the lib/MROGeometry dir from github (just follow the link in the source tree).

P.S. For me, the best working solution was SVGKit, but not the version from Jason Morissey (mentioned in another answer), but a fork from reklis. It has many bugs fixed and works in a much more correct way.

Zeroid
  • 101
  • 1
  • 6
0

It's easy.

SVGKImage *svgImg = [SVGKImage imageNamed:@"add-control-panel"];
SVGKFastImageView *imgView = [[SVGKFastImageView alloc] initWithFrame:CGRectMake(10, 100, 420, 280)];
imgView.image = svgImg;
[self.view addSubview:imgView];
tianglin
  • 226
  • 3
  • 14