SolvedCocoaPods App Icons not included in build from Xcode 9

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

47 Answers

โœ”๏ธAccepted Answer

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

Other Answers:

@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

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

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

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

More Issues: