Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render SVG images in iphone without uiwebview?

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?

like image 217
nehal Avatar asked Jul 07 '11 12:07

nehal


People also ask

Can we use SVG image in iOS?

SVGs will be supported on devices running iOS 13 and up. On devices below iOS 13, it appears SVGs will be converted to PNGs since they're not a supported format. SVGs are typically the preferred asset type for Web and Android platforms.

Can we use SVG in Swift?

For using SVG, you only need to drag them in your assets folder and then you can use them in your project file by using UIImage class named constructor.


1 Answers

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.

like image 124
Dan Ray Avatar answered Oct 11 '22 18:10

Dan Ray