0

I am working with SVGKit in swift Project. I properly imported SVGKit Framework and 3rd party resources folder into my project by following (https://github.com/SVGKit/SVGKit).

I created a folder with sets of .svg images inside the project and i am using the following code to load image into testIcon(ImageView).

let lockImage: SVGKImage = SVGKImage(named: "LockIcon.svg")
let lockImageLocal: UIImage = lockImage.uiImage
testIcon.image = lockImageLocal

But i am receiving the following error,

** Assertion failure in +[SVGKImage imageWithSource:], /Users/fss/Downloads/SVGKit- 2.x/Source/SVGKImage.m:229

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: newSource != nil'

Please let me know how to mention path of .svg image(which is inside my project) to SVGKImage image class or how to resolve this problem.

Lal Krishna
  • 15,485
  • 6
  • 64
  • 84
user7413163
  • 205
  • 1
  • 4
  • 15

1 Answers1

0

please remove .svg from image name. This method named: doesn't need extension.

Or you can try this way too...

Swift 4

if let imagePath = Bundle.main.path(forResource: "imageName", ofType: "svg")     
{
  let lockImage: SVGKImage = SVGKImage(contentsOfFile: imagePath)
  let lockImageLocal: UIImage = lockImage.uiImage
  testIcon.image = lockImageLocal
}

Obj-c type

NSString *imagePath = [NSBundle mainBundle][ pathForResource:@"imageName" ofType:@"svg"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
Mahendra
  • 8,448
  • 3
  • 33
  • 56