今天遇到一个坑,App在iOS11系统下死活不显示icon。百度了一堆办法不好使。去stackoverflow上面翻了翻,找到一个好使的,特此搬运一下
打开你项目根目录下的Podfile文件。在最下方增加以下代码
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
具体效果可看截图
然后打开终端执行pod install
回到Xcode clear一下。重启Xcode,应该就好了
如果还没好,更新下你的cocoapods,再重新来一遍
stackoverflow地址