Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode5 xcassets - how to bulk replace images?

Tags:

xcode

ios

xcode5

Say I have a project with 100 images that I've imported into a folder inside the main Images.xcassets file. Then I go and get updates for 67 of those images from my graphics designer - is there an easy way to push those image updates into the xcassets folder?

As it stands, I'm opening the xcassets file in Xcode, and for each of the images that's changed I'm dragging the new image into the little 2x or 1x box - I have to do that 67 times! I can't just drag/drop the files in Finder (the old way) because every image in the xcassets folder has its own subfolder. If I don't use the xcassets file for my images, I can easily update the files by doing this. But xcassets are supposed to "make managing your assets much simpler."

Fine - so what am I missing?

like image 878
Mete Avatar asked Sep 25 '13 13:09

Mete


3 Answers

No need for Ruby, you can run this shell script to find files in a origin folder (where your updated images are), find files with the same name in your destination folder (.xcassets folder) and overwrite them with the updated version. Works great!

find ORIGIN FOLDER PATH NAME -name '*.png'  | while read f; do   f2=$(find DESTINATION     FOLDER PATH -name "${f##*/}");   [[ $f2 ]] && cp "$f" "$f2"; done
like image 89
user3199112 Avatar answered Nov 15 '22 21:11

user3199112


I don't think you're missing anything. Assets folders are simply not well thought through. They introduce a few benefits, but a lot more flaws.

Take for example launch image. You can't set the same retina and retina 4-inch launch images for different iOS versions via assets without Xcode duplicating the files. I guess we have no other option but to submit enhancement requests via bug reporter and hope...

like image 26
2 revs Avatar answered Nov 15 '22 21:11

2 revs


i wrote a ruby script to automate this task. Please follow the below link. https://gist.github.com/shirishgone/8036382

like image 25
Shirish Gone Avatar answered Nov 15 '22 22:11

Shirish Gone