You can add non-PNG assets by editing the JSON representation of the asset manually. The easiest way is to copy an existing asset and modify it:
- Right click on an existing asset and choose Show in Finder
- Copy and paste the existing
.imagesetitem and rename it, e.g.my_image.imageset - Double-click the new
.imageset - Delete any existing images in the folder
- Copy in your JPEG files
- Edit the
Contents.jsonfile, replacing the values for thefilenamekey with your JPEG filenames
Your Contents.json will look something like this:
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "my_image.jpg"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "my_image@2x.jpg"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Be sure to refer to your image by name, without extension:
[UIImage imageNamed:@"my_image"]
This approach will work for GIFs and other assets as they are just copied into the App’s main bundle at build time. It is worth noting that the images end up with a png extension when copied to the bundle, but they still load correctly.