Is it possible to add assets other than PNG files to an Xcode Asset Catalog?
When I drag JPEG files into an Asset Catalog they aren't accepted by the UI.
Is it possible to add assets other than PNG files to an Xcode Asset Catalog?
When I drag JPEG files into an Asset Catalog they aren't accepted by the UI.
As of Xcode 6.1 JPG images can now be added to an asset catalog. The steps to add are:
heart.jpg
heart@2x.jpg
heart@3x.jpg
)It appears you can now drag and drop JPEGs in Xcode 6.0 Beta
Try this. Quickly import resource scripts to resolve import speed and rename issues. https://github.com/qdvictory/happyxcasset
You can also rename your image.jpg to image.png if you don't want to change the Contents.json file. You can then add the images to the asset catalog, even though internally they are still jpeg files. You can even slice them using Xcode.
When the application is compiled, all assets go into the Assets.car file. I haven't verified if at this point they get converted to png.
In Xcode 6.x you can drag and drop jpegs to the asset catalog. If creating a UIImage from the asset make sure you use the .jpg extension like so:
If the extension is not included, the image will just appear white/blank.
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:
.imageset
item and rename it, e.g.my_image.imageset
.imageset
Contents.json
file, replacing the values for thefilename
key with your JPEG filenamesYour
Contents.json
will look something like this:Be sure to refer to your image by name, without extension:
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.