|
| 1 | +#objc-assetgen |
| 2 | + |
| 3 | +Xcode 5 has an awesome new feature called "[asset catalogs](https://developer.apple.com/technologies/tools/features.html)", allowing you to specify all of your image variants and resizable cap insets in a single place. |
| 4 | + |
| 5 | +Unfortunately, to get the full benefits, you have to set your deployment target to iOS 7; otherwise, Xcode will dutifully put all of the images into your app bundle but totally ignore all of your resizable insets with only a build warning. |
| 6 | + |
| 7 | +But shucks! The important and awesome part is the editor, and it puts all of the data out in super-readable JSON. We should be able to do a poor man's version that reads in the data and spits out some code to give you most of the benefits. |
| 8 | + |
| 9 | +##Usage |
| 10 | + |
| 11 | +Call`objc-assetgen` with the`.xcassets` paths as arguments from the directory into which it should output the code. |
| 12 | + |
| 13 | +For an asset catalog named "Foo" containing image sets "Bar" and "Baz", you'll get`WQFooCatalog.h` and`WQFooCatalog.m`, with class methods`+ (UIImage *)imageForBar` and`+ (UIImage *)imageForBaz`. Put them in your DerivedSources folder and you're good to go. |
| 14 | + |
| 15 | +##Command-line options |
| 16 | + |
| 17 | +There are none. The class prefix is hardcoded as`WQ` and the output directory is hardcoded as the current one. We should fix this. |
| 18 | + |
| 19 | +##Future plans |
| 20 | + |
| 21 | +Maybe swizzle`+[UIImage imageNamed:]`? |