更改iPad的备用图标 [英] Changing alternate icon for iPad

查看:349
本文介绍了更改iPad的备用图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPad上更改应用程序图标时遇到问题。一切都在iPhone上工作正常但在iPad上我收到此错误:

I have a problem with changing app's icon on iPad. Everything is working fine on iPhone but on iPad I get this error :


[default]无法将$ iGName设置为AI-Gorgosaurus
...:0>错误:错误
域= NSCocoaErrorDomain代码= 4文件不存在。
UserInfo = {NSUnderlyingError = 0x600000248a30 {错误
Domain = LSApplicationWorkspaceErrorDomain Code = -105iconName未找到
CFBundleAlternateIcons条目
UserInfo = {NSLocalizedDescription = iconName未在$ b中找到$ b CFBundleAlternateIcons entry}}} App图标因文件
不存在而失败。

[default] Failed to set preferredIconName to AI-Gorgosaurus for ...:0> error: Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist." UserInfo={NSUnderlyingError=0x600000248a30 {Error Domain=LSApplicationWorkspaceErrorDomain Code=-105 "iconName not found in CFBundleAlternateIcons entry" UserInfo={NSLocalizedDescription=iconName not found in CFBundleAlternateIcons entry}}} App icon failed to due to The file doesn’t exist.

我搜索了广告发现我需要在 CFBundleIconFiles 中添加 ~ipad ,但仍会收到相同的错误!。

I searched ad found that I need to add ~ipad in CFBundleIconFiles but still get the same error!.

以下是代码:

  func changeIcon(to name: String?) {
        //Check if the app supports alternating icons
        guard UIApplication.shared.supportsAlternateIcons else {
            return;
        }

        //Change the icon to a specific image with given name
        UIApplication.shared.setAlternateIconName(name) { (error) in
            //After app icon changed, print our error or success message
            if let error = error {
                print("App icon failed to due to \(error.localizedDescription)")
            } else {
                print("App icon changed successfully.")
            }
        }
    }

我刚刚在另一个项目上测试过并且工作正常!!!但不是我目前的项目为什么?!你知道吗?

I just tested on another project and works fine !!! but not on my current project why ?! have you any idea?

推荐答案

我注意到你的plisy有
UIPrerenderedIcon设为NO

What I have noticed that your plisy has UIPrerenderedIcon set to NO

将其更改为是

问题可能在于渲染

编辑1:添加.png扩展名,看看是否有帮助

Edit 1: add the .png extension see if it helps

编辑2:尝试将新图标文件名更改为ipadAlternate.png,然后在plist中更改为相同它看起来与你的plist和图标文件本身存在某种不匹配

EDIT 2: Try changing the new icons filename to ipadAlternate.png and then change to the same in the plist as it looks like there is some kind of mismatch with your plist and the icon file itself

编辑3:你是否清理了DerivedData文件夹。我刚才遇到了一个问题,没有任何帮助清理项目等但我尝试删除/ Users / YOURUSERNAME / Library / Developer / Xcode / DerivedData /文件夹中的所有内容,它又开始工作了。值得一试。

EDIT 3: Have you cleaned the DerivedData folder. I had an issue a while ago and nothing helped cleaning the project etc. but I tried deleting everything in the /Users/YOURUSERNAME/Library/Developer/Xcode/DerivedData/ folder and it started working again. It is worth giving a go.

编辑4:尝试从编辑3执行步骤。然后重新启动项目并从中删除所有替代图标文件选择移至垃圾箱和然后用CMD + SHIFT + K来清理nexr CMD + B来构建。
接下来将图标添加到检查目标是否正确的位置,并在需要时复制项目。由于某种原因,xcode丢失了你的文件跟踪,它显示错误没有文件。
如果这样做无济于事,请尝试上述步骤,但首先尝试将整个项目移动到另一个文件夹。

EDIT 4: Try doing step from EDIT 3. Then restart your project and delete all the alternative icon files from it choose move to trash and thenCMD+SHIFT+K to clean nexr CMD+B to build. Next add the icons back where they were check if target is selected correctly and copy items if needed selected. For some reason xcode lost track of your file and it is showing error no file. if that will not help then try the above steps but first try moving the whole project to a different folder.

编辑5:还有一个想法您可以自己尝试,尝试删除当前项目中的plist文件(在删除之前保留它的备份副本)然后启动一个新项目,其中图标更改工作正常并将该项目中的plist添加到此项目中。检查图标更改是否有效,如果是,则添加您在上一个项目中所有缺少的密钥。

EDIT 5: There is one more idea which you might try for yourself, try deleting the plist file in the current project (keep a backup copy of it before deleting) then start a new project where the icon changing works fine and add the plist from that project to this one. Check if the icon changing works if yes then add all the missing keys you had in the previous project.

警告:这是最后的手段,但这必须有效。启动一个新项目并使用您想要的图标进行设置,检查它们是否先工作,然后从项目中添加所有不起作用的代码和依赖项,只是不要覆盖PLIST文件。

WARNING: This is a last resort but this must work. Start a new project and set it up with the icons which you want alternating check if they work first then add all the code and dependencies from the project where it doesn't work just don't override the PLIST files.

编辑6:尝试从模拟器或您尝试使用的设备上删除应用程序并重新安装它,整个问题可能与更新和应用程序以前版本的剩余部分有关。

EDIT 6: Try deleting the app from the simulator or the device you are trying it on and reinstall it the whole issue might be with the update and the leftovers from the previous version of the app.

编辑7:尝试将项目复制到另一台mac,看看问题是否仍然存在。您使用哪个xcode版本?如果它是Xcode 9,也许可以在Xcode 10 beta

EDIT 7: Try copying the project to another mac and see if the problem persist. Which xcode version are you using?? If it is Xcode 9 perhaps try it in the Xcode 10 beta

这篇关于更改iPad的备用图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆