Reputation: 2279
I am trying to get the url of an image in my assets folder to use it as the preview for a UIActivityViewController as suggested here. However I am getting nil for the path, even though the UIImage is working. I have checked if the extension is lowercase as suggested in another question and it is indeed. I have also tried using .path
Bundle.main.url(forResource: "emoji-2", withExtension: "jpg") // this is nil
UIImage(named: "emoji-2") // this is not nil
Any ideas what I'm doing wrong?
To confirm, the asset exists in my Assets library
Upvotes: 0
Views: 583
Reputation: 236360
Adding an image to the asset is not the same as adding it to the bundle. If you need an URL you can add it to your project or get the representation data from your image located in your asset, save it to a temporary location and share its URL.
Upvotes: 2