can I use svg image file in xcode?

Can I use svg image file for iPhone application in xcode any version . If its possible so how I will do it? Anyone any idea about it?

It’s hard to answer this without more information. For example, if you bundle an SVG in your app then it’s trivial to load that into a web view. However, you can’t use an SVG as an app icon.

In what context do you wont to use this SVG?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

If you mean use an SVG with UIImage (or NSImage on mac) I don't believe it is supported. You could load it in a WebView, as Quinn mentioned. Not sure how well that will work out. There is a third party open source library SVGKit you could look at.

Hello mobiweb29,



Yes you can render .svg files in your application. I have created one application for map that shows data of population in respective country by clicking on country on map.

Here is sample example of rendering svg into app. Some other libraries are their in market. You can find and use according to your requirements.
https://github.com/ArthurGuibert/FSInteractiveMap



Note that : I don’t know that Apple Inc. approve your app on store or not. App which I have created it was for our personal use. I didn’t upload that app on store.

You CANNOT use a SVG directly.


However, there are two indirect options:

1- In Illustrator, convert your SVG to PDF and import the vector image file into an asset catalog in your XCode project

2- Import your SVG file into PaintCode. Generate the Core Graphics code (either Objective C or Swift) and use that in your project.

Yes, as of Xcode 12.

From Apple's Xcode 12 release notes:

Asset Catalogs
New Features
Added support for Scalable Vector Graphic (SVG) image assets. These preserve their vector representation with deployment targets of macOS 10.15 or later, iOS 13 or later, and iPadOS 13 or later. (18389814)
If you add the SVG to your assets folder, you can then use the SVG with UIImage(named:), but I haven't found a way to use SVG data, for example downloading SVG as Data and then using UIImage(data:) doesn't work for some reason.
@nathan_day. This may be of interest:
https ://www.avanderlee .com/xcode/svg-image-assets/
can I use svg image file in xcode?
 
 
Q