0

I have an iPhone app (iOS/Swift) Xcode project. I have an image called map_pin_icon.svg saved to my Desktop (from wikicommons @ https://commons.wikimedia.org/wiki/File:Map_pin_icon.svg).

I drag and drop it into my Xcode project's Assets.xcassets folder, and it shows up in the list. When I click on map_pin_icon in the list (below the app icon set) and it says the image set has a Universal image for Any/Any size, but the icon it shows is the blank file icon, not the icon in the image file. If I select the Universal image and press spacebar it shows the correct icon in a "quick view" window.

In ViewController.swift I have in viewDidLoad():

    let theImage = UIImage(named: "map_pin_icon.svg")
    if(theImage == nil) {
        print("NIL IS NOT ALLOWED")
    } else {
        print("\(theImage)")
    }
    let theImageView = UIImageView(image: theImage)

And sure enough when I run the simulator (iOS 8.0 on iPhone 4s, which is my minimum desired compatibility device) I get the following output log:

    NIL IS NOT ALLOWED

Where am I going wrong? Thanks in advance.

1 Answers1

0

iOS does not natively portray SVG images as the basis of a UIImage. Without some third-party library, you're not going to be able to use this image.

matt
  • 515,959
  • 87
  • 875
  • 1,141