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.
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.
- Use the same asset catalog for both targets.
- Check that it is included on both targets (check target membership using file inspector).
- On each target select the appropriate name of asset (icons).
This shall work, I'm using it with 8 targets so...
Btw, I discover that sometimes launch-image isn't working when using few targets so you may need to duplicate then select it (Xcode bug).
In my case I am using cocoa pods. The cocoa pods script Pods-resources.sh somehow caused the problem. removing the asset parts from the script solved the problem.
Make sure to clean your project and delete derived data folder.
Parts to be deleted can be found here:
After much frustration, I have clean, successful, separate images assets. Here's what worked for me:
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.
Next, I deleted that catalog from my project using the option to remove references.
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.
As in 2, I removed the catalog with a remove references delete.
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.)
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.
Then in XCode I selected each target and used the General tab to properly specify the image catalog for each target.
I'm running with several targets where each has their own asset catalog file, with both AppIcon, LaunchImage and a custom I use in storyboard for backgrounds.
It sounds like the same problem I had, when selecting the asset catalog for App Icons and Launch Images it took the wrong one when building. I solved it by modifying the "Target Membership" for each assets catalog, the .xcassets file. It's set so each xcassets file only have the target it's related to. Thereby only one target is selected per asset catalog. Now it's the right AppIcon and LaunchImage that's available for each target.
I used @user216661 solution, but in my case I didn't have to do steps 2-7.
I created an asset folder with specific name for specific target (in my case, one asset folder per target). Then I added the images to those xcassets folders by dragging & dropping them from Finder. The same for icons and launch images. I didn't have to customize graphics names for each target.
In this solution, you don't store any graphics outside asset folders.
How about just modify the assets in build setting option.For me,it worked.