App 图标不展示问题修复

升级到 Xcode 9之后,同学们会发现更新 cocoapods 库之后再运行App应用图标展示不出来了。经过一番调研,最终问题指向了 (加入你的项目名称是QQMusic, 且 Target 同名):$(PROJECT_DIR)/Target Support Files/Pods-QQMusic/Pods-QQMusic-resources.sh 。

目前解决方案有两种:
1、打开该 sh 文件替换最后一段为以下脚本

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"
fi

2、在podfile文件中添加以下脚本

post_install do |installer_representation|
    # 解决 cocoapods 每次更新库之后图标不展示问题
    copy_pods_resources_path = "Pods/Target Support Files/Pods-SuYun/Pods-SuYun-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)
    end

你可能感兴趣的:(App 图标不展示问题修复)