Adding image by following method solved my problem.
- Right click on project in xcode and select
Add Files to "project name"
. - Select your image file from computer local disk.
- In the pop-up window make sure you select
Copy items into destination group's folder
andCreate Folder References for any added folders
andAdd to targets
. - click
Add
.
Then with bellow code i can retrieve my image.
For Objective-C version
[[NSBundle mainBundle] pathForResource:@"imageName" ofType:@"png"];
For Swift 4.0 version
Bundle.main.path(forResource: "imageName", ofType: "png")