IOS

关注公众号 jb51net

关闭
首页 > 软件编程 > IOS > Xcode9 AppIcon 图标在iOS11上不显示

iOS11上Xcode9 AppIcon 图标不显示

作者:allentsing

升级到iOS11系统下自己的项目桌面app图标不见了,是什么原因呢,经过一番查找,终于发现问题所在,现在分享给大家

实例一:

打开工程目录下:[工程名]/Pods/Target Support Files/Pods-[工程名]/Pods-[工程名]-resources.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}"
fi

修改后:

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

然后重新运行工程即可

实例二:

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

1.加入脚本

platform :ios, '8.0'

target ‘lqz' do
  pod 'MJRefresh'
  pod 'AFNetworking'
  
post_install do |installer|
  copy_pods_resources_path = "Pods/Target Support Files/Pods-[工程名]/Pods-[工程名]-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

您可能感兴趣的文章:
阅读全文