Elardus Erasmus
Elardus Erasmus

Reputation: 135

Jpeg images in Xcode project reported to to be invalid

After upgrading (Swift and Xcode - some time ago already), I now have a warning for every .JPG image in my project (I have 200+ JPG images in the project):

The image set "Image1" references a file "Image1.JPG", but that file does not have a valid extension.

How do I get rid of the warnings/fix the root cause of the issue?

Upvotes: 4

Views: 1708

Answers (3)

user2332921
user2332921

Reputation: 369

To rename hundreds of image extensions in one go: In Xcode right click an image > Show in Finder > change to List view (or press ⌘+2) > highlight / select all folders with .imageset > press right arrow to expand all in one go > now select all folders including all image files inside > right click > Rename X items > Replace Text > Find: .JPG Replace With: .jpg.

Upvotes: 0

Laura Ruival
Laura Ruival

Reputation: 31

To clarify, it's true that you need to use a lowercase .jpg extension, but you don't have to import all of the images again. You can just rename the image files in the imageset folder to have a lowercase extension and edit the contents.json file associated with it to reference the lowercase .jpg extension.

Upvotes: 1

Ozgur Vatansever
Ozgur Vatansever

Reputation: 52173

It looks like .JPG is not a valid file extension for Xcode 7. Try changing all .JPG to .jpg and the problem should be gone.

Same rule applies to images with .PNG extensions too.

Upvotes: 6

Related Questions