Asset Catelog issue with multiple targets
Asked Answered
J

4

13

I have a project with multiple targets. Assume the targets are named Target-A, Target-B and so on. For every target I have a different asset catalog of App Icons. They are named as AppIcon - A, AppIcon - B and it goes on for all the targets. I have assigned respective asset catalogs to all targets, but it only shows the icons for Target-A when i run on the device / simulator. For all other targets it does not set any icons and shows iOS 7 default placeholder icon. Please help!

Jamisonjammal answered 21/10, 2013 at 7:32 Comment(0)
C
6

When you are adding the app icon image please note while adding app icon-1 to Test target then select only test target not Test copy target same for Test copy target.

enter image description here

Also add row for "Icon file" in both the plist and specify your app icon names.

enter image description here

enter image description here

Please check following screen shots you will get some ideas.

enter image description here

enter image description here

Carton answered 21/10, 2013 at 7:54 Comment(1)
Had the same problem. I forgot to add asset catalog to my second target as shown at the first screenshot. Thanks too much!Premiere
W
16

If you're using PODs in your project, then you have to edit "Pods-resources.sh" and remove "xcassets" commands (see attached picture). enter image description here

Weldon answered 23/1, 2014 at 13:7 Comment(1)
Absolutely right, this is a bug in cocoapods (Issue #1546 on Github github.com/CocoaPods/CocoaPods/issues/1546) I use a build script that deletes these lines (you can find it in this link)Padnag
C
6

When you are adding the app icon image please note while adding app icon-1 to Test target then select only test target not Test copy target same for Test copy target.

enter image description here

Also add row for "Icon file" in both the plist and specify your app icon names.

enter image description here

enter image description here

Please check following screen shots you will get some ideas.

enter image description here

enter image description here

Carton answered 21/10, 2013 at 7:54 Comment(1)
Had the same problem. I forgot to add asset catalog to my second target as shown at the first screenshot. Thanks too much!Premiere
S
4

The easiest way for me was to add multiple "App Icon" in the same xcassets file. With this technique, I had no problem with Cocoapod :

  1. Open your xcassets file
  2. Right click on the left column
  3. Click "New App icon"

Then you can easily select the correct "App Icon" for each target.

Shadwell answered 9/2, 2015 at 10:20 Comment(0)
G
2

So I wrote a script to delete all those lines which are pointed out by Lukapple.Paste the code to run Script in the xcode project after Target Dependencies.

echo "run script to remove Pods-resources.sh"
file_name="${PROJECT_DIR}/Pods/Target Support Files/Pods/Pods-resources.sh"
function remove_wrapper_extensions {cat "$1" | awk 'BEGIN { suppress_output = 0; } /^if \[\[ -n/ { suppress_output = 1; } (!suppress_output) { print $0; } /^fi$/ { suppress_output = 0; }' > "${1}.1"}
function remove_case_statement {cat "$1" | awk 'BEGIN { suppress_output = 0; } /\s*\*\.xcassets\)$/ { suppress_output = 1; } (!suppress_output) { print $0; } /;;/ && (suppress_output) { suppress_output = 0; }' > "${1}.2"}
remove_wrapper_extensions "$file_name"
remove_case_statement "${file_name}.1"
rm "${file_name}"
rm "${file_name}.1"
mv "${file_name}.1.2" "$file_name"
chmod +x "${file_name}"
Guttersnipe answered 20/3, 2015 at 10:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.