首页 > 解决方案 > NSOSStatusErrorDomain Code=-54 "操作无法完成。" 设置备用应用程序图标时

问题描述

在我的 iOS 项目中,我尝试为我的 iOS 应用程序设置备用图标,并且图像文件(icon_1、icon_2、icon_3)在我的项目包中,而不是在 Assets.xcassets 中。Info.list 像这样:

<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>icon_1</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>icon_1</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
        <key>icon_2</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>icon_2</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
        <key>icon_3</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>icon_3</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
    </dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string>AppIcon</string>
        </array>
    </dict>
</dict>

我将备用图标设置为源代码

[[UIApplication sharedApplication] setAlternateIconName:@"icon_1" completionHandler:^(NSError *error) {}

但是,图标不会更改并出现错误

Error Domain=NSOSStatusErrorDomain Code=-54 "The operation couldn’t be completed."

我该如何解决这个问题?

谢谢 :)。

标签: iosobjective-cios14alternateappicon

解决方案


推荐阅读