Use SF Symbols system image for static UIApplicationShortcutItem
Asked Answered
A

3

22

When specifying home screen quick actions, UIApplicationShortcutItems, in your Info.plist, is there a way to use a system image from SF Symbols?

The docs noting the available iOS keys doesn't specify a key to do this, besides specifying one of the predefined enum cases from UIApplicationShortcutItemIconType such as UIApplicationShortcutIconTypeSearch.

It is possible to use a system image when creating dynamic quick actions via a new initializer UIApplicationShortcutIcon.init(systemImageName: String). Is there a Info.plist key that allows this for static quick actions?

Alexanderalexandr answered 22/7, 2019 at 4:34 Comment(1)
You could try to get the stock application into your computer, either by extracting them from the ipsw update file or with a jailbroken device, and explore their Info.plist files to see if any of them are using SF Symbols.Bowen
M
19

Use UIApplicationShortcutItemIconSymbolName instead of UIApplicationShortcutItemIconFile in your Info.plist.

Mecham answered 18/5, 2020 at 21:33 Comment(2)
Is this documented anywhere? Hesitant to use it.Redheaded
It's documented here: developer.apple.com/documentation/uikit/menus_and_shortcuts/…Landsturm
G
17

Native but NOT a much compatible way: (read to the end)

There is a poor documented way and that is to use UIApplicationShortcutItemIconSymbolName instead of UIApplicationShortcutItemIconFile in the Info.plist file.


Old but may better way:

Since there are not too many symbols that you need to use statically at the same time, here is the solution:

  1. Select the symbol you need and export it from SF Symbols.app:

Exporting

  1. Import it in the Assets.xcassets:

Assets

  1. Use its name for the key UIApplicationShortcutItemIconFile:

Info.plist

Result

Result


Conclusion

The second method also brings more benefits to your app:

  • Backward compatibility (supporting iOS 12 and below)
  • Forward compatibility! (preventing from breaking changes)
  • Wider support

More description here in these answer

Gorizia answered 12/12, 2019 at 9:49 Comment(1)
Besides the manual effort, the only concern I'd add is that Apple may change (or modify) the images in the future. Depending on the image, this would be very good or very bad, but worth considering before you do this.Lavettelavigne
S
2

I read the docs and tried several methods to get this working but the conclusion I reached is that this won't be possible for two main reasons:

  • SF Symbols are only available for native use on devices running iOS 13 or older.
  • Info.plist file can specify a platform and device type but you can't specify an OS version.

In Apple's documents it's also stated that:

You can use SF Symbols in apps running in iOS 13 and later, watchOS 6 and later, and tvOS 13 and later. To browse the full set of symbols, download the SF Symbols app.

This means that you are able to use these symbols but with a standard way. Here is what you can do:

  • Download the SF Symbols app from here.
  • Export the symbols you'd like to use as SVG files.
  • Add exported SVG files to your assets.
  • Use the asset name for the value of UIApplicationShortcutItemIconFile key.

This may not be the method you'd have hoped but it's a valid solution for using SF Symbols as shortcut icons so I hope this works for you.

Ski answered 12/12, 2019 at 6:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.