Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with using multiple asset catalogs in XCode 5

I have one app that has 2 variations that only differ in branding. For each version I have an AppIcon and LaunchImage in an asset catalog. I've created a different target for each version. In the second version when I try and select AppIcon in the second asset catalog it just defaults to the first one. Removing the first asset catalog seems to resolve it but I would prefer a less 'hacky' solution.

like image 754
Mark Horgan Avatar asked Oct 21 '13 13:10

Mark Horgan


2 Answers

After much frustration, I have clean, successful, separate images assets. Here's what worked for me:

  1. I used XCode to create an image catalog for the first target (File, New, File, Asset). It has a membership for that target only. As Mark Horgan suggested, I named the internal appIcon & launchImages, if only to make it easier for myself.

  2. Next, I deleted that catalog from my project using the option to remove references.

  3. I repeated step 1 and created an image catalog for the 2nd target. It has a membership for that 2nd target only. Assigning the catalog to my target was tricky because XCode only offered "Don't Use Image Catalog" as an option. I choose that option, and then XCode offers "Use Asset Catalog". I chose my new catagot. Again I named the internal appIcon & launchImages to reference the 2nd target, so I could recognize it.

  4. As in 2, I removed the catalog with a remove references delete.

  5. Departing XCode for a moment, I opened a Finder window and located my two different images.xcassets files which had been put in different directories by XCode. I renamed those files to each reference their target. (I also moved them into the master folder, but of course that's a preference.)

  6. Back in XCode, I (re)added the xcassets files, one at a time, ensuring they were appropriately added to their target and copied to resources.

  7. Then in XCode I selected each target and used the General tab to properly specify the image catalog for each target.

like image 181
user216661 Avatar answered Sep 28 '22 18:09

user216661


I think the best solution I've come up with so far is to rename assets in subsequent asset catalogs. For example you might have 2 asset catalogs that contain assets named AppIcon and LaunchImage. In the 2nd asset catalog I've renamed AppIcon and LaunchImage to AppIcon1 and LaunchImage1. So now I can select them in the 'General' section of the target's build settings.

like image 43
Mark Horgan Avatar answered Sep 28 '22 16:09

Mark Horgan