SFSafeSymbols / SFSafeSymbols

Safely access Apple's SF Symbols using static typing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for SF Symbols 4

fredpi opened this issue · comments

As can be seen here, there will be a new version of SF Symbols: SF Symbols 4. Currently, the SF Symbols 4 app isn't available to download, but it probably won't last long until we learn all about it.

This issue can be used to collect ideas / track progress on the SF Symbols 4 support.

I updated

  • layerset_availability.plist
  • name_aliases_strings.txt
  • name_availability.plist
  • symbol_names.txt
  • symbol_previews.txt

from / using the SF Symbols 4 Beta app and regenerated the code. Fortunately, everything went fine, so there's now experimental v4 support: experimental/4.0-support.

I think there are no changes / new features in SF Symbols 4 that require an adaptation of our generator code; but correct me, if I'm wrong.

We just need to update symbol_restrictions.strings and symbol_restrictions_missing.strings. @Stevenmagdy I noticed there's no documentation on how to update them; if I remember correctly you retrieved them from the OS, right? Maybe we can add a file to the Resources folder which describes how to update these two files.

Okay, there is one minor issue:

In the localization_availability.plist, there is an entry square.3.layers.3d.down.forward.slash.rtl, but not an entry for the "base variant" square.3.layers.3d.down.forward.slash. In the SF Symbols app, therefore, the symbol is not shown at all. And indeed, it doesn't exist in the OS (causing a crash). Still, SFSafeSymbols assumes that square.3.layers.3d.down.forward.slash must exist. Same goes for square.3.layers.3d.down.backward.slash.

This can be fixed by making the generator tool ignore localizations if the base variant symbol is not listed in the localization_availability.plist. To avoid conflicts, let's wait until #106 is merged before implementing this. Implementing this fix is also a good first issue, if someone is interested.

I pushed a new commit with the new symbol restrictions file from Xcode 14 Beta. Thanks @Stevenmagdy for documenting the information where to find it (via #108).

Interestingly, the Xbox and PS symbols introduced in SF Symbols v3 are now also restricted despite not representing Apple products:

This symbol may not be modified and may only be used to refer to Microsoft’s Xbox.

This symbol may not be modified and may only be used to refer to Sony’s PlayStation.

To avoid conflicts, let's wait until #106 is merged before implementing this. Implementing this fix is also a good first issue, if someone is interested.

As #106 is now merged, this can now be implemented. I think it's a good first issue, so if someone wants to contribute to this repository, this is a good starting point. If nobody wants to do it, I'll do it before the v4 release.

I have now fixed the issue mentioned above myself.

@fredpi : You know if there is a way to request to add specific symbols.
For example the one for git, I found this: https://github.com/cameronshemilt/MoreSFSymbols#developer

But it would be nice to have them officers.

@Angelk90 SFSafeSymbols is only meant for the native symbols and not for symbols included in the assets. For your use case, I would recommend extending UIImage itself:

extension UIImage {
	static let git = UIImage(named: "git")!
}

imageView.image = .git

You can get that automatically using SwiftGen or R.swift

@Stevenmagdy : In fact I say how can I apply to add it as a native symbol?

@Angelk90 Unfortunately you really can't add native symbols. Even the linked repo couldn't:

It is important to note that you do not use the SFSymbols initialiser (eg. systemName:), but rather the initialiser for images from your assets.

This from their README and in their Usage section you will find Image("symbol.name"), which is the initialiser for the image assets.
SFSafeSymbols just make using the native symbols more convenient and safe, it doesn't add any new symbols.

Hello ✋

@fredpi, could you please refer me to an explanation on how the files in SymbolsGenerator/Resources are generated, or maybe possibly explain ? Thank you.

@vakhid-betrakhmadov This is documented in the 'Updating to a new SF Symbols version' section of the CONTRIBUTING.md. I hope this answers your question – let me know, if you need further help :)

@fredpi , many thanks 🙏, that answers my question