A lightweight Swift package that gives you access to all available emojis for each iOS version. Additionally, this repository includes a script to fetch all emojis for a specific release from Unicode.org.
The repository includes to different products with different use cases:
EmojiKit
: A Swift Package Manager (SPM) package that provides all available emojis for supported iOS versions. It already includes all supported for all iOS version higher or equal thaniOS 15.0
.EmojiSourceKit
: A script that fetches emoji releases from Unicode.org, parses them and stores them in easy-to-usejson
files.
In most cases it is enough to just use the EmojiKit
for your app. The EmojiSourceKit
is only needed if you want to fetch releases manually or fetch older non-supported unicode versions.
https://github.com/niklasamslgruber/EmojiKit
The SPM package provides an easy-to-use EmojiManager
that parses the stored emoji files and returns them as an Array of EmojiCategory
. Each category is the category that Apple uses on any Apple platform and includes all emojis that are assigned to this category. In total these are 8 categories.
import EmojiKit
let emojisByCategory: [EmojiCategory] = EmojiManager.getAvailableEmojis()
Parameters:
version
: By default theEmojiManager
always returns the highest unicode version that is supported on a user's device. You can also manually specify a version which could lead to some emojis being displayed as'?'
if the unicode version does not match the user's iOS version.showAllVariations
: Many emojis are available in different skin types. By default theEmojiManager
returns only the neutral (yellow) version of each emoji. If you want to receive all version, set this parameter totrue
.at url
: If you don't want to use the emoji files that are already included in this package, you can manually specify the location of your emoji_.json`.
In most cases this part is not necessary if you just want to get the emojis in Swift. If you want to do some manual fetching or your app supports iOS versions below
iOS 15.0
, this chapter is for you.
The main idea behind this script is that there is no full list of supported emojis that can be easily used in Swift. This script fetches the full list of emojis from Unicode.org, parses them and returns a structured emojis_vX.json
file where all emojis are assigned to their official unicode category. The .json
files can be easily parsed afterwards for further usage in any product.
Note Unicode released version 15.1 already, however these Emojis are not yet supported on iOS.
EmojiSourceKit
already contains the new Emojis, but they can't be used on iOS yet. We will release a new version once Apple integrated them.
git clone https://github.com/niklasamslgruber/EmojiKit
To use EmojiSourceKit
as a script from your Terminal, some further steps are required:
- Clone the repository and
cd
into it. - Run
swift run -c release EmojiSourceKit
to build the package. - Move the product into
/usr/local/bin
to make it available systemwide withcp .build/release/EmojiSourceKit /usr/bin/emojiSourceKit
.
Alternatively you can simply run
sh build.sh
to do steps 2. and 3. in one go.
emojiSourceKit download <path> -v <version>
Arguments:
path
: Specify the directory where theemoji_v<version>.json
file should be stored. Only provide the directory like/Desktop
or.
for the current directory, not the whole file path.version (--version, -v)
: Currently only version14
and15
(latest) are supported.
Currently only to Unicode releases are supported (Version 14 and 15). If you want to have access to emojis from older versions, you need to edit the source code manually.
- Add a new enum case to the
EmojiManager.Version
enum. For example for Version 12, you would need to addcase v12 = 12
. Also, add aversionIdentifier
. This should match the release number from Unicode.rog exactly. You can find all releases here. - Modify the
getSupportedVersion
function to return your new enum case for the corresponding iOS version. - Run the script with the
emojiSourceKit download <path> --version 12
argument to get the emojis from the version 12 release. - Add the emoji file to your Xcode project and specify its url as an parameter of the
EmojiManager.getAvailableEmojis(at: <url)
function to access the emojis in Swift.
-
Emojis are rendered as <
?
> in my app:If you're using the
EmojiKit
you're most likely running the App on a device with an iOS version belowiOS 15.0
. That is currently not supported. To still make it work, follow the instructions of runningEmojiSourceKit
with unsupported versions to get all emojis that are supported on your device's iOS version. -
The
EmojiManager
does not return any emojis when using theurl
parameter:In that case make sure that you added the
emojis_vX.json
file to your Xcode project. The file name must match the version you're trying to fetch emojis for, e.g. for version 12 the file name must beemojis_v12.json
. Additionally make sure that your JSON file is added underBuild Phase - Copy Bundle Resources
for each target where you want to use theEmojiManager
.