查看: 1478|回复: 0

[IOS开发教程] iOS11上Xcode9 AppIcon 图标不显示

发表于 2017-12-27 08:00:00

实例一:

打开工程目录下:[工程名]/Pods/Target Support Files/Pods-[工程名]/Pods-[工程名]-resources.sh这个文件,替换最后一段代码:

修改前:

  1. printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text
  2. --notices
  3. --warnings --platform "${PLATFORM_NAME}"
  4. --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS}
  5. --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  6. fi
复制代码

修改后:

  1. 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"
  2. fi
复制代码

然后重新运行工程即可

实例二:

在Xcode9下新建一个工程看一下, 设置图标是显示的, 但是假如CocoaPod就不显示了. 多方查询发现
图标不显示主要是cocoaPod出现了问题, 需要在podfile文件加入以下脚本 [标红的地方]

1.加入脚本

  1. platform :ios, '8.0'
  2. target ‘lqz' do
  3. pod 'MJRefresh'
  4. pod 'AFNetworking'
  5. post_install do |installer|
  6. copy_pods_resources_path = "Pods/Target Support Files/Pods-[工程名]/Pods-[工程名]-resources.sh"
  7. string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
  8. 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"'
  9. text = File.read(copy_pods_resources_path)
  10. new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
  11. File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
  12. end
复制代码



回复

使用道具 举报