2018.2.5更新:已知新坑,pdf圖片可能會(huì)被拷貝一份,造成運(yùn)行時(shí)讀取圖片崩潰础淤。暫無解決辦法
目前出現(xiàn)問題的情況:Xcode9 ,iOS 11哨苛,使用了CocoaPods鸽凶,就會(huì)出現(xiàn)圖標(biāo)丟失的問題
在podfile文件底部添加以下代碼,即可(在網(wǎng)上找到的方法建峭,都是單Target的玻侥,改良了下)
如果產(chǎn)生圖標(biāo)錯(cuò)亂,原因是你的多個(gè)Target使用的AppIcon的Asset文件名稱相同了迹缀,最好是根據(jù)Target取名即可解決
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