New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Icons not included in build from Xcode 9 #7003

Closed
harlenn opened this Issue Sep 4, 2017 · 98 comments

Comments

Projects
None yet
@harlenn

harlenn commented Sep 4, 2017

Report

What did you do?

Run project on device from Xcode 9 Beta 6

What did you expect to happen?

Install on device and show included app icon

What happened instead?

Installed on device but app icon was the default as if you had not set any app icons

Note:
If project is run from Xcode 8.3.3 the correct app icon is visible.
If project is run without CocoaPods the correct app icon is visible.

CocoaPods Environment

Stack

   CocoaPods : 1.3.1
        Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
    RubyGems : 2.0.14.1
        Host : Mac OS X 10.12.6 (16G29)
       Xcode : 8.3.3 (8E3004b)
         Git : git version 2.11.0 (Apple Git-81)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 349acd3cdb79892c96f2a0dcba3e187244680d3f

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.2.0
cocoapods-try         : 1.1.0

Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'IconTest' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for IconTest
  pod "DBCamera"
end

Project that demonstrates the issue

https://github.com/harlenn/IconTest

@khomTima

This comment has been minimized.

khomTima commented Sep 8, 2017

I have the same problem, a little research has shown a possible problem:
At first xcode compiles assets in the "Copy Bundle Resources" build step using --app-icon argument.
After that, in step "[CP] Copy Pods Resources" Pods-your_project_name-resources.sh compiles assets from dependencies without --app-icon argument and overwrites Assets.car
Fix: Add --app-icon argument to the assets compilation command in Pods-your_project_name-resources.sh with the appropriate catalog and plist file.

Adding this code to the Podfile should help:

post_install do |installer|
    copy_pods_resources_path = "Pods/Target Support Files/Pods-IconTest/Pods-IconTest-resources.sh"
    string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
    assets_compile_with_app_icon_arguments = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"'
    text = File.read(copy_pods_resources_path)
    new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
    File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
end
@dreampiggy

This comment has been minimized.

dreampiggy commented Sep 10, 2017

Same issue here. Just use the temp solution above. I think it's issue related to Copy Pods Resources in cocoapods because after I remove that build phase, the Application Icon is OK. I want to find the actual issue but i'm not familiar with shell script. Hope for an official solution. 😕

@jshier

This comment has been minimized.

jshier commented Sep 13, 2017

@khomTima Any way to make that generic to every Pods-* value that's generated? In a project with 12 results there, it's a bit awkward.

@oguzgu

This comment has been minimized.

oguzgu commented Sep 14, 2017

@khomTima I tried your solution, but app icon set as Afnetworking (I use Afnetworking) icon, not worked for my project

@powerqian

This comment has been minimized.

powerqian commented Sep 15, 2017

@jshier just loop over all the targets

post_install do |installer|
  installer.aggregate_targets.each do |target|
    copy_pods_resources_path = "Pods/Target Support Files/#{target.name}/#{target.name}-resources.sh"
    string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
    assets_compile_with_app_icon_arguments = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"'
    text = File.read(copy_pods_resources_path)
    new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
    File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
  end
end
@dnkoutso

This comment has been minimized.

Contributor

dnkoutso commented Sep 15, 2017

@khomTima any idea on why it doesn't work for @oguzgu ?

@oguzgu

This comment has been minimized.

oguzgu commented Sep 15, 2017

I found the solution, i also using carthage and afnetworking has an example project in checkout folder. I removed example project and it worked

@jshier

This comment has been minimized.

jshier commented Sep 15, 2017

@powerqian Thanks, that worked! I just didn't know what thing to iterate to get the values that were needed. There are Ruby docs available for this stuff, but little that explains what things are actually for.

@babbage

This comment has been minimized.

babbage commented Sep 15, 2017

Update later: Turned out after much experimenting, my issue was not with Cooapods whatsover. Rather, something seems to have changed in Xcode 9 which meant that pngs that were previously rendered fine as an AppIcon were no longer working. Replacing the images with new pngs, at the same resolutions, that had been created with a different process, resolved my issues. See Stack Overflow discussion.

Original comments: Not sure how helpful this is to post so hesitated, but just to note that I've tried the solution posted above and it hasn't resolved the issue with one of my projects—it still is building without the app icon appearing.

Inspecting the build intermediates and products directories, I can see that the AppIcon resources are included in the .app bundle, and that the AppIcon resources are listed in the assetcatalog_generated_info.plist, yet inspecting the Assets.car with cartool shows that there is an AppIcon entry but there are no image resources are listed under it. Not sure why or exactly where the process is failing.

@MaximusMcCann

This comment has been minimized.

MaximusMcCann commented Sep 19, 2017

I've added the above to post_install, but am still receiving rejections from Apple :/.
If I comment out the Copy Pods Resources Phase the upload works. But I have other problems as it's obviously missing some resources. fwiw

@MaximusMcCann

This comment has been minimized.

MaximusMcCann commented Sep 19, 2017

Note, make sure you're on cocoapods v1.3.1. That was my issue above.

@rpassis

This comment has been minimized.

rpassis commented Sep 19, 2017

#7003 (comment)

The answer regarding Carthage above has put me in the right direction.

I have a Carthage checkouts folder with RxSwift. Inside the checkout there's a RxExample app - this folder also contains an assets bundle file called Images.xcassets with RxSwift app icons inside it.

My own bundle has a Images.xcassets assets bundle and when building the RxSwift Images.xcassets overwrites my own Images.xcassets. I have no idea why but my current work around is to remove the RxExample folder from the checkout directory and everything works but this is not ideal when building using our CI server since we always bootstrap and build from Carthage sources.

@MaximusMcCann

This comment has been minimized.

MaximusMcCann commented Sep 19, 2017

I am actually finding the above solution does not work. It appeared to work once yesterday, but the last 8 hours have made me conclude it's not a proper solution. I am able to successfully validate the Archive only if I comment out the Copy Pods Resources phase :/

@matmartinez

This comment has been minimized.

matmartinez commented Sep 19, 2017

I tried the workaround above with no luck. I've also tried exporting all my icons again, as @babbage recommended, but the iTunes Connect errors persist. There are several people reporting this on the Apple Developer Forums as well.

@brandons

This comment has been minimized.

brandons commented Sep 20, 2017

@matmartinez I discovered my issue was because I was on what I thought to be the High Sierra GM. As of writing this the only High Sierra build available is a "GM Candidate." I don't think they green lighted it yet. Changing the build information in your archive to spoof Sierra fixed the issue for me.

Outlined here.
https://forums.developer.apple.com/thread/86290

First of all make sure that you’re on the latest version of Sierra and than archive your app as usually. Once your app was archived right click it and choose show in Finder. Open the package contents and open this file inside of it: /Products/Application/yourApp.app/info.plist
In there you have to change all the DTXXX Values to be the same as in the latest version of Xcode 8.

DTXcode - “0833”
DTSDKName - “iphoneos10.3"
DTSDKBuild - “14E8301”
DTPlatformName - “iphoneos”
DTCompiler - “com.apple.compilers.llvm.clang.1_0”
DTXcodeBuild - “8E3004b”
DTPlatformVersion - “10.3”
DTPlatformBuild - “14E8301"

@matmartinez

This comment has been minimized.

matmartinez commented Sep 20, 2017

@brandons thanks for the help! Does your app behave as it was linked against iOS 11? I tried changing just the BuildMachineOSBuild key, but it doesn't have any effect.

@brandons

This comment has been minimized.

brandons commented Sep 20, 2017

@matmartinez Yes, we are compiled against iOS 11. For me, changing to the values above allowed me to submit. I think it only has an affect on transmitting it to iTC. Our build processed fine with TestFlight and is awaiting App Store review.

@MaximusMcCann

This comment has been minimized.

MaximusMcCann commented Sep 20, 2017

My solution was different. Had to comment out one of the install_resource lines in Pods-NAME-resources.sh file. It was a pod called Ambassador. After commenting out that single line everything uploaded fine. Fortunately, we did not need the resources it provides, but that could be an issue for someone else...
fwiw, The line commented out, for each configuration:

  #install_resource "${PODS_ROOT}/Ambassador/Ambassador.bundle"
@Dengz

This comment has been minimized.

Dengz commented Sep 20, 2017

I just moved the "Copy Bundle Resources" to the last step in the Build Phases, and the app icon showed up in iOS11 devices.

@rpassis

This comment has been minimized.

rpassis commented Sep 20, 2017

Ok here's my theory after spending a whole day investigating this.

For some reason, the "copy pod resources" build phase script is recursively looking through the project root folder and then running actool's processing steps on it. During this recursive look it happens to find xcassets that may or may not be included in the project (i.e. my Carthage checkouts folder is one example) and these get copied into the app bundle.

What's changed in Xcode 9 is that inside the app bundle, the actual icons seem to live outside the compiled Assets.car file regardless of whether you used an asset catalog or not.

So when building the IPA, every time Xcode's build tool finds a matching icon name inside a an xcassets file (i.e. AppIcon) it will extract and copy it to the app bundle root folder, which may result in overwriting the correct one.

For those of you seeing no icon (instead of the wrong icon), can you do a recursive search on your project folder to see if you can find any Pods or libraries that include xcassets, and if any of these contains an icon file that matches your own icon name (i.e. AppIcon).

Here's a sample of what the copy resources script finds when searching for xcassets inside my project. Note that the Carthage checkout folder is NOT part of the project itself, it just happens to live inside the project folder.

/Users/[username]/app/Carthage/Checkouts/RxSwift/RxExample/RxExample/Images.xcassets
/Users/[username]/app//Pods/Kite-Print-SDK/Kite-SDK/PSPrintSDK/KitePrintSDK.xcassets
/Users/[username]/app/Resources/Images.xcassets

@MaximusMcCann

This comment has been minimized.

MaximusMcCann commented Sep 20, 2017

@rpassis interesting thoughts. Certainly some funky stuff going on. I set the script to set -x to see what was happening and noticed it never entered the below loop, for us. Which then led me to the install_resource lines. I do see an Assets.car file in the culprit's bundle, but there is no AppIcon or name conflicting file that I can see. Hope this stuff helps others out there!

if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
then
  # Find all other xcassets (this unfortunately includes those of path pods and other targets).
  OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
  while read line; do
    if [[ $line != "${PODS_ROOT}*" ]]; then
      XCASSET_FILES+=("$line")
    fi
  done <<<"$OTHER_XCASSETS"

  printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"
else
  echo "NOT USING ACTOOL LOOP"
fi
@stuartkhall

This comment has been minimized.

stuartkhall commented Sep 21, 2017

It was a High Sierra issue for me. I managed to work around this by running below over the .xcarchive before submitting.

find Products/ -name Info.plist -print0 | xargs -0n1 plutil -replace BuildMachineOSBuild -string 16A323

@s9027059

This comment has been minimized.

s9027059 commented Sep 21, 2017

@rpassis You are the hero!

@ghost

This comment has been minimized.

ghost commented Sep 22, 2017

It was caused by High Sierra GM here. I could upload after doing @brandons steps. It complained tho. Once said App Store 1024px icon was missing and once said it had alpha channel, while it hadn't. But the build has processed and I could submit it.

@ivanperalta

This comment has been minimized.

ivanperalta commented Sep 23, 2017

For me, after review any workaround listed unsuccessfully, just created a new icon assets including PNG and Display P3 versions, and that fixed the issue. Just in case this other approach help anyone.

@meyumeapps

This comment has been minimized.

meyumeapps commented Sep 24, 2017

I'm on High Sierra as well. My app also has Apple Watch extension and none of the above worked for me :(

@babbage

This comment has been minimized.

babbage commented Sep 24, 2017

A further post in the non-Cocoapods-but-issue-related thread on StackOverflow is pointing the finger at the png colour space for some users, for App Icons that previously worked but now do not, so this is another thing to check if you're still having issues...

@sommestad

This comment has been minimized.

sommestad commented Nov 3, 2017

@the-scott-davis Setting the Icon Set Name in build settings made the icon show up (which is a big step forward).
But unfortunately does not really work for us, since we want to re-use the same build and distribute it with slightly different metadata (icons etc). The search continues...

@Disco-Inferno

This comment has been minimized.

Disco-Inferno commented Nov 5, 2017

Just to perhaps help those smarter than me in troubleshooting this one:

-When I tried to add a new icons png's to the icon set, it failed with the same error.
-I deleted the entire assets set, grabbed an assets set from a similar app, pasted it into the current bundle then it then worked fine!!! (So nothing wrong with Xcode or its settings).

I checked some icon files and played around to figure out what was wrong.

Turned out to be: When I saved the new icons as PNG files in Photoshop, I didn't do it properly.
I clicked on the existing filename to over-write (xxxx.png) and hit enter, without specifically setting the format to PNG in the drop-down box.

After I did this, happy days!

Maybe it helps someone in the slim chance they are doing the same.

@HassanSE

This comment has been minimized.

HassanSE commented Nov 7, 2017

In my case, assigning sRGB (instead of Adobe RGB) profile to AppIcons worked.

@dollar2048

This comment has been minimized.

dollar2048 commented Nov 8, 2017

I had trouble with compiling Unit tests target in a "multi-project" workspace.
the workaround is to check for "UnitTestsTarget":

post_install do |installer|
    installer.aggregate_targets.each do |target|
        if target.name != "UnitTestsTarget" then
            puts "adding app icons for #{target.name}"
            copy_pods_resources_path = "Pods/Target Support Files/#{target.name}/#{target.name}-resources.sh"
            string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
            assets_compile_with_app_icon_arguments = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"'
            text = File.read(copy_pods_resources_path)
            new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
            File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
       end
    end
end
@fjtrujy

This comment has been minimized.

fjtrujy commented Nov 30, 2017

Hello,
In my case none of the solution suggested above worked.
But I have found a tricky behaviour that make it works.

We were using the Server & Bots to auto-generate our binaries/archives, there we found that the icons were missings.
Today we have tried to generate our binaries/archives using the manual approach, it means from Product -> Archive, and magically it works!! it include the images!!

So weird.... anyway I'm pretty sure that this is not an CocoaPods issue, this is something else, either OSX or Xcode.

Thanks in advance!!

@ChristopherDrum

This comment has been minimized.

ChristopherDrum commented Dec 1, 2017

@fjtrujy This is exactly what I have discovered today. The server bot archive is missing icons, though the build log seems to show that icons were generated from the .xcassets and individual icons with proper names exist in the intermediate build files. However, the final .xcarchive and .ipa have no icons, and so icon validation fails.

However, if I go into the bot's checkout directory, open the workspace, and Product > Archive, I get a perfect .xcarchive from the exact same code that created the bad archive. So, I might add a bot post-integration script that does the Archive manually via xcodebuild (something I already do to build for enterprise distribution).

  • My project doesn't use CocoaPods
  • I've set to sRGB color space.
  • My icons have no alpha channels
  • AppIcon set name is unique and being pointed to in Build Settings.
  • Deleted extraneous icon-related entries in Info.plist
  • I completely deleted and re-created the AppIcon .xcasset from scratch

Being discussed lightly here: https://forums.developer.apple.com/thread/91752

@chenyongMAC

This comment has been minimized.

chenyongMAC commented Dec 13, 2017

I have the same error above, but something special for me.The resources.sh file in Pods has a command like this OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d). You must make sure your icon's xcassets is exist in this path($PWD).

@cocosribbons

This comment has been minimized.

cocosribbons commented Jan 15, 2018

I came across a very simple solution that somehow fixed this problem problem for my build.

  1. renaming the AppIcon folder name from "AppIcon" to "AppIcon-1",
    or, in Xcode's Images.xcassets folder, create an new AppIcon folder by opening the contextual menu > App Icons & Launch Images > New iOS App Icon,

  2. Load the correctly sized images into the new folder (that is named other than "AppIcon"),

  3. Rebuild.

@aarefin

This comment has been minimized.

aarefin commented Feb 1, 2018

@cocosribbons It doesn't work for me - Xcode 9.2 (9C40b) / High Sierra 10.13.2 (17C205)
2018-02-01 17 34 44

@LightMan

This comment has been minimized.

LightMan commented Feb 21, 2018

I have investigate this issue for a few hours. For the moment I have realised this:
The problem happens when a pod has a resource of type .xcassets.
I don't see the line in the build log when the .xcassets from the pod are supposed to be copied, I can see other logs like the bundles.
In /Pod/Target Support Files/Pods/Pods-resources.sh I have commented all the lines that contain install_resource with xcassets files , removed the whole if there all the lines are commented.
Moved the .xcassets that I need from the pod folder to my project folder, I need them and you should too.

That's all right now. I guess there has to be some kind of bug when copying .xcassets from pods and then AppIcon.xcassets in iOS11, because this only happens to me with iOS11.

@Dids

This comment has been minimized.

Dids commented Mar 9, 2018

Just to chime in on this, I managed to solve this by going to Build Phases, then moving [CP] Embed Pods Frameworks and [CP] Copy Pods Resources before Copy Bundle Resources.

This way my resources don't get lost/overwritten, and everything seems to still work as expected.

@dnkoutso

This comment has been minimized.

Contributor

dnkoutso commented Mar 15, 2018

Seems like a duplicate bug gave me a good reproducible case #7511

Going to see if I can work on a fix for this one.

@dnkoutso

This comment has been minimized.

Contributor

dnkoutso commented Mar 19, 2018

Marking this for 1.5.0 with #7526 as the fix.

@dnkoutso

This comment has been minimized.

Contributor

dnkoutso commented Mar 19, 2018

Fix has been merged for 1.5.0.

@tylermilner

This comment has been minimized.

tylermilner commented Mar 30, 2018

Just upgraded to 1.5.0.beta.1 and my app icon is back. Thanks for the fix!

@monibu1548

This comment has been minimized.

monibu1548 commented Apr 8, 2018

If you build xcarchive at Xcode Server, it will help you.

https://forums.developer.apple.com/thread/91752

image

@sirghi

This comment has been minimized.

sirghi commented May 10, 2018

I'm on 1.5.0 and I still see this issue.

I have a project that uses mixed cocapods and carthage, and one of the carthage checkouts has a demo project which has an AppIcon folder. And that one gets overwritten over the app icon.

Don't think Carthage is to blame, cause it should work ok irrespective of what project structure one might have. The script should be made a bit more smart.

@manwinder123

This comment has been minimized.

manwinder123 commented May 10, 2018

I am on CocoaPods 1.5.2 and I was having the following issues: ITMS-90022, ITMS-90023, ITMS-90704 when I tried to upload to the app store after archiving. I've tried pod deintegrate and pod install on xCode 9.2 (9C40b). I uninstalled 9.2 and installed xCode 9.1 (9B55). Ran pod deintegrate and pod install on the same project, archived and uploaded to the app store with no issues. I tried switching the png pictures with jpg but that didn't fix anything on 9.2, I uninstalled and re-installed 9.2 but still had issues.

I am running Sierra 10.12.6

I was able to get 9.1 from https://developer.apple.com/download/more/

HalfdanJ pushed a commit to googlecreativelab/justaline-ios that referenced this issue May 30, 2018

HalfdanJ pushed a commit to googlecreativelab/justaline-ios that referenced this issue May 30, 2018

@nightwolf-chen

This comment has been minimized.

nightwolf-chen commented Sep 13, 2018

I have the same problem, a little research has shown a possible problem:
At first xcode compiles assets in the "Copy Bundle Resources" build step using --app-icon argument.
After that, in step "[CP] Copy Pods Resources" Pods-your_project_name-resources.sh compiles assets from dependencies without --app-icon argument and overwrites Assets.car
Fix: Add --app-icon argument to the assets compilation command in Pods-your_project_name-resources.sh with the appropriate catalog and plist file.

Adding this code to the Podfile should help:

post_install do |installer|
    copy_pods_resources_path = "Pods/Target Support Files/Pods-IconTest/Pods-IconTest-resources.sh"
    string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
    assets_compile_with_app_icon_arguments = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"'
    text = File.read(copy_pods_resources_path)
    new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
    File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
end

Works for me. In my case there was a resource in dependency has same name as the one in the main bundle which causes override problem.

@phips28

This comment has been minimized.

phips28 commented Oct 22, 2018

pod: 1.5.3
Xcode: 10

Somehow archive found other AppIcon files from other libraries and has overridden my AppIcons.

QuickFix: just renamed my AppIcon to AppIconSomethingUnique and selected it as App Icon Source in settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment