I have added all required icons in asset catalogs as well as in my application, but it is not showing icon on simulator
问题:
回答1:
Check This Link App Icon not showing up, although I have added in Xcode 5
This might be an XCode 6 bug that the added icons are not actually included in the app bundle, but you can work around it by going to Build Phases, expand Copy Bundle Resources, then press the "+" sign in the bottom to manually add the icon files to this category.
In addition iOS 5/6 seems to have a bug that the screen doesn't update the app icon even if the icon files are included in the bundle. To work around it you can drag the app icon into a folder, then iOS will update the appearance of it.
回答2:
iOS 11 Xcode 9
If you're using CocoaPods, stop right there!
Problem:
Basically there is some difference in the way Xcode 9 / iOS 11 adds the asset files and some weird meddling that CocoaPods gets up to which result in the icon files not being included.
Fix:
Copy and past this snippet into you podfile (I know...it's ugly):
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
Be sure to change "IconTest" value in the path name on the second line to your project name. Run 'pod update' and voilà there's ye app icon back.
Source
This fix comes from the Cocoapods team. See thread here: https://github.com/CocoaPods/CocoaPods/issues/7003
回答3:
On the iPhone 7, iPhone 8 & iPhone X simulators (Xcode 9, iOS 11), my app icon would not display if it contained certain colours!
Below are two icon images, 60pt@2x, both using the AdobeRGB colour profile. I generated these with ImageMagick - the only difference is that they are a different colour.
Icon A: #74B3BE
This icon appears fine in the simulator (iPhone 8)
Icon B: #E58921
This icon does not work in the simulator:
Adding a single pixel of Icon B's colour into Icon A would also cause it to stop working.
Removing the AdobeRGB colour profile from the icon fixes the problem, but results in washed out colours. The solution I used is to first convert the icon to the sRGB profile (I used ImageMagick).
It remains to be seen whether this is an issue on a physical iPhone 8 / iPhone X, since they are not yet available for sale. Other simulated hardware such as iPhone 6s did not exhibit this problem even though it was running iOS 11.
Addendum: during my testing (I've lost over a day on this!) I also observed pixel density metadata in the icons affecting whether the icon appeared in the simulator. 72dpi would work, and 150dpi would not. Unfortunately I changed the offending project and have not been able to reproduce that case since.
回答4:
Just delete the application from simulator, clean project (hit CMD + K
) and run again
回答5:
Had the same problem.
You should also check if you have the correct value for the key "Asset Catalog App Icon Set Name" under "Project -> Build Settings".
In my case it was empty (just ""). When I added the correct value (section were the linker will find the app icon in Assets.xcassets), in my case "AppIcon", everything works as expected.
As I had many resources in that Assets.xcassets, I rearranged some of the resources in different sections etc. so the AppIcon section was not in the "root directory" of the catalog. Maybe this was the reason for the problem.